Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Some or all of the tests I write and run are checks for consistency e.g. assert that if I create a new user account, that the account that was created actually has the same name as the name that was submitted in the registration. And now for checking that I implemented a pagination correctly, I suppose I can check that for any given large resultset, getting the "next page", sometimes repeated times and not only once, will eventually lead to the same last page as getting the last page directly (which is done another way than stepping through one page at a time, going directly to the last page in done by using the reversed order and getting the first page from the reversed order.

In our projects we try to follow test-driven development but sometimes I think it is not exact whether a test is a unit test or an integration test when in fact both the integration tests and the unit tests are mostly or only "constistency checks". I didn't see any other type of test than for consistency (both the unit tests and the integration tests do assertions), but it seems that mocking is used more in integration tests than in unit tests and than a unit test is smaller and for a single component or method while an integration test is "larger", but that is still not an exact difference.

So what kind of a test is a consistency check? Is it a unit test or an integration test?

share|improve this question
Is the title supposed to be appended at the end of your text for it to become a question? :) – Pierre Arlaud Feb 17 '14 at 10:04
I beg to differ: I use mocking in unit tests to separate the unit, whereas in integration tests I want to integrate actual components, hence, do not want a mock. – Frank Feb 17 '14 at 14:26

I don't know if 'consistency check' is the appropriate name for the kind of tests you describe, really what you describe is simply just a test.

Whether or not it is a unit test or an integration test is really a function of the dependencies/state that the method under test has, and how those dependencies/state are managed.

With your example, if your method under test calls into some service and you mock or fake the service that it's using, then you're more likely writing a unit test. If you're using a legitimate implementation of the service then it's an integration test.

Similarly, if there is some kind of global or external state that your method under tests refers to and you mock/fake that, then you are again writing a unit test.

It's easy to think of the differentiation in the context of code coverage. If your test only covers lines in the method under test, and test code, then it's a unit test. If it covers other code, then it's an integration test (or an incorrectly written unit test).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.