Question

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?

Was it helpful?

Solution

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).

OTHER TIPS

To expand on Steven Evers' answer - I believe that Steven's definitions of unit and integration tests are correct and consistent with my understanding and experience. I've also heard the term "consistency check" before, but never in the context of a test.

When I've heard the term "consistency check", it's usually in the context of the running system. There are different types of checks. Validations are typically executed when something is created or modified and may be one form of consistency check. However, other consistency checks may run outside of these changes to ensure that the state has not changed. For example, a consistency check may check one or all records to make sure that they were not modified by an external application or human directly in the database. Consistency checks may also exist between systems to ensure that they share the correct representation of the state of the system and to indicate when they do not.

Licensed under: CC-BY-SA with attribution
scroll top