Tagged: TDD

Unit. Integration. Acceptance.

Confused about which kind test to implement in your development process?

The following types of tests are complementary. Some of them address the system from the user’s perspective, others form the developer’s point of view. This is why I don’t know many practical cases where focusing on one type of testing  is sufficient.

Unit Testing

As the name suggests this type of test is performed for the smallest units of source code.

UnitTest
Characteristics:

  • Simple as possible
  • Repeatable
  • Consistent
  • Fast execution
  • Easy to debug
  • Few external factors
Because of these characteristics, some restrictions emerge when creating unit tests.

Restrictions:

  • Don’t access the network
  • Don’t spin up a thread
  • Don’t use the file system
  • Don’t use the database
  • … in short, don’t use any dependency when it’s initialization or manipulation is not straight forward or it’s time consuming. If any such dependency is needed in your unit tests, mocking is the way to go.

The shortcoming of this type of testing is that it addresses small blocks of functionality. The unit tests don’ t cover the aspects of how the entire system performs.

Integration Testing

This type of tests is build upon the unit tests. It concerns the system resulted as the combined blocks of code, that were already tested with unit tests..
It’s main advantage is that it can find bugs produced by the environment.

IntegrationTestsCharacteristics:

  • Can use threads
  • Can use system dependent values that change dynamically (such as DateTime.Now)
  • Can use external dependencies
  • Can access the network
  • …can use whatever is required to ensure the correct functionality of all the code, in whatever production environment.
The shortcoming of this type of testing is that they don’t test the complete desired functionality. The code works fine in the tested environments, but did we implemented all the desired features? This is why a third type of testing is needed.

Acceptance Testing

AcceptanceTests

These are the tests which ensure that the program provides the functionality the end user is expecting. The term “executable specifications” is often used to describe this kind of tests.

The tests are made based upon the user stories and address the system as a black-box  If the acceptance tests pass, it means that the program meets the user requirements.

Of course, there are a lot more type of tests than the ones this post concerns. However, when building the foundation of testing the source code, I think a good starting point is provided by the above three.

Advertisement