What is Object Mocking and when do I need it?
Many people use Mock Objects when they are writing unit tests. What is a Mock Object? Why would I ever need one? Do I need a Mock Object Framework?...
Many people use Mock Objects when they are writing unit tests. What is a Mock Object? Why would I ever need one? Do I need a Mock Object Framework?...
I just keep stumbling through mocking... The latest disaster was not grokking that I need to actually push results inside a mock object of IEnumerable... Here's a sample (demonstration only of IEnumerable, not actually good Interaction-based testing!): using System; using System.Collections.Generic; using Rhino.Mocks; using MbUnit.Fra...
So, in Java, the first line of your constructor HAS to be a call to super... be it implicitly calling super(), or explicitly calling another constructor. What I want to know is, why can't I put a try block around that? My specific case is that I have a mock class for a test. There is no default constructor, but I want one to make the ...
Mocking sealed classes can be quite a pain. I currently favor an Adapter pattern to handle this, but something about just keeps feels weird. So, What is the best way you mock sealed classes? Java answers are more than welcome. In fact, I would anticipate that the Java community has been dealing with this longer and has a great deal...
What's the best framework for creating mock objects in Java? Why? What are the pros and cons of each framework? ...
How do you unit test a HttpModule in asp.net given that HttpApplication and HttpContext do no implement an interface ? ...
So I'm working on some legacy code that's heavy on the manual database operations. I'm trying to maintain some semblance of quality here, so I'm going TDD as much as possible. The code I'm working on needs to populate, let's say a List<Foo> from a DataReader that returns all the fields required for a functioning Foo. However, if I want ...
I have a coworker who writes unit tests for objects which fill their fields with random data. His reason is that it gives a wider range of testing, since it will test a lot of different values, whereas a normal test only uses a single static value. I've given him a number of different reasons against this, the main ones being: random ...
So the controller context depends on some asp.net internals. What are some ways to cleanly mock these up for unit tests? Seems like its very easy to clog up tests with tons of setup when I only need, for example, Request.HttpMethod to return "GET". I've seen some examples/helpers out on the nets, but some are dated. Figured this would b...
I want to start using mock objects on my next C# project. After a quick google I've found there are many: NMock EasyMock.NET TypeMock Isolator Commercial / Paid Rhino Mocks Moq So my question is: what one is your favourite .NET mocking framework and why? ...
I have a basic understanding of mock and fake objects, but I'm not sure I have a feeling about when/where to use mocking - especially as it would apply to this scenario here. ...
Does anyone have any experience with Mock Object frameworks in C++? I haven't been able to find much. It appears Google will be open sourcing theirs soon, so I guess it may be best to wait for that, but still interested to hear of others. Just an update the Google's gMock has been out for a while now. ...
A while ago I read the Mocks Aren't Stubs article by Martin Fowler and I must admit I'm a bit scared of external dependencies with regards to added complexity so I would like to ask: What is the best method to use when unit testing? Is it better to always use a mock framework to automatically mock the dependencies of the method being t...
Say I have an interface IFoo which I am mocking. There are 3 methods on this interface. I need to test that the system under test calls at least one of the three methods. I don't care how many times, or with what arguments it does call, but the case where it ignores all the methods and does not touch the IFoo mock is the failure case. I...
Multiple approaches exist to write your unit tests when using Rhino Mocks: The Standard Syntax Record/Replay Syntax The Fluent Syntax What is the ideal and most frictionless way? ...
The code private SomeClass<Integer> someClass; someClass = EasyMock.createMock(SomeClass.class); gives me a warning "Type safety: The expression of type SomeClass needs unchecked conversion to conform to SomeClass<Integer>". ...
When I originally was introduced to Mocks I felt the primary purpose was to mock up objects that come from external sources of data. This way I did not have to maintain an automated unit testing test database, I could just fake it. But now I am starting to think of it differently. I am wondering if Mocks are more effective used to com...
My motto for Java is "just because Java has static blocks, it doesn't mean that you should be using them." Jokes aside, there are a lot of tricks in Java that make testing a nightmare. Two of the most I hate are Anonymous Classes and Static Blocks. We have a lot of legacy code that make use of Static Blocks and these are one of the annoy...
Hello, I use a stream reader to import some data and at the moment I hardcode a small sample file in the test to do the job. Is it sensible to use Mock Objects with this and how ? ...
Which one do you use (if you use the listed ones) and what do you love and even hate about it? ...