I\'m using more unit tests in my projects and reading all the information I can online and am getting confused by a lot of the terminology. As a result I\'m probably using these
I've read (and heartily recommend) The Art of Unit Testing by Roy Osherove. He uses a simplified set of terminology.
To paraphrase his book ...
Integration Test - any test that reaches outside of the current process or object to interact with something else
Interaction Test - a test on the way that objects work together
State Test - a test on the results produced by an operation
Fake - any stand-in object that's used instead of the real thing
Stub - a stand-in object that provides a dependency required by the code under test
Mock - a stand-in used to check the results of the test
Note that here both Stubs and Mocks can be provided by a Mocking framework - the distiction is as much about how they're used as the technology used.
When it comes to mocks vs. fakes vs. stubs, there are actually a few different ways that people interpret them. I usually borrow the meanings defined by Martin Fowler:
Interaction testing is a general term that refers to unit tests which ensure that the interaction between objects is correct (making sure that expected methods are called). This is opposed to state (or classical) testing, which doesn't care what happens in the methods, so long as the resulting state is correct. These types of testing are compared in Fowler's article that I linked above.
Integration testing really isn't an aspect of unit testing, it is a level above the unit tests. It takes different units and verifies that they work together correctly.
this is an excellent book: http://xunitpatterns.com/
see: http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html
and http://xunitpatterns.com/XUnit%20Terminology%20Crossreference.html
Fowler did of course a great work at differentiating Mocks and Stubs but, to me, the XUnit Test Patterns book is the reference and I'd suggest to check Mocks, Fakes, Stubs and Dummies for a comprehensive comparison.
Yeah, I know, this is confusing and that's why I'd suggest checking Mocks and Stubs aren't Spies, then let’s spy and finally Mockito - The New Mock Framework on the Block too.
Regarding the different types of tests, a simplified explanation could be (this is not an exhaustive list):
All these types are useful and not exclusive, they actually just don't have the same intent.
This article from MSN Magazine explains the terms and goes into some detail with examples and some source code.
Basically these are the test doubles: