Is it a UNIT Test or Integration?

I am working on a school project, and I am exploring testing opportunities for Android applications.

On this page: http://developer.android.com/resources/tutorials/testing/helloandroid_test.html Google writes about unit testing. Is this really a unit test? A Unit test will not integrate all classes and will not test in this context.

So I believe that this is not a Unit test, but an integration test. What do you think?

+4
source share
3 answers

I do not think that there is a general opinion about what unit test is, so it's hard to say. Although some may argue that this should be a very small unit of code (for example, a method), which is quite restrictive, especially considering the fact that with a passing test refactor, you can put this code in several methods or even classes.

Roy Osherov 's definition is as follows:

A unit test is a quick, built-in memory, sequential, automatic and repeatable test of a functional unit of work in a system.

A unit of work is any functional scenario in a system that contains logic. it may be functions, or it may cover several classes and functions, and this provides the internal or commercial value of the system under test.

'Fast' and 'in-memory', IMO, most importantly, separating this from the integration test. If you do this, I think Google tests are really unit tests.

+2
source

A test is not a unit test if:

  • He is talking to the database.
  • It communicates over the network.
  • It relates to the file system.
  • It cannot work simultaneously with any of your other unit tests.
  • To run it, you need to do special things in your environment (for example, edit configuration files).
+1
source

Hi fellow coders.

I would like to add that, in my experience, it is best to check the behavior of an object if it does what you need so that (for your problem domain), be it one method or more, to pass the test, I know that this may sound like simple testing methods, but there is one more thing. A good book to read to help understand this is Natha Price and Steve Freeman's โ€œGrowing Object-Oriented Test-Driven Softwareโ€.

All in all, a good question and excellent answers. Keep it up.: -)

0
source

All Articles