Software Testing Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 23: Line 23:


=Test Double=
=Test Double=
A test double is meant to replace a real external dependency in the unit test cycle. This may be necessary either because the external dependency is unavailable, or the interaction with it is slow.
A test double is meant to replace a real [[#External_Dependency|external dependency]] in the unit test cycle. This may be necessary either because the external dependency is unavailable, or the interaction with it is slow.

Revision as of 00:40, 16 July 2021

Internal

Overview

Automated testing provides an effective mechanism for catching regressions, especially when combined with test-driven development.

Test-Driven Development

Automated Test

An automated test verifies an assumption about the behavior of the system and provides a safety mesh that is exercised continuously, again and again, in an automated fashion, in most cases on each commit in the repository. The benefits of automated testing and that the software is continuously verified, maintaining its quality. Another benefit of tests is that they serve as documentation for code.

Unit Test

Unit testing is the testing of the smallest possible part of software, such a single method, a small set of related methods or a class. In reality we test logical units - which can extend to a method, a single class or multiple classes. A unit test has the following characteristics:

  • It should be automated.
  • It should be fast - not more that a few milliseconds to finish execution.
  • It should be self-contained and runnable in isolation, and then in any order as part of the test suite. The unit test should not depend on the result of another test or on the execution order.One should understand what is going on in a unit test without having to look at other parts of the code.
  • It should not depend on database access, file access or any long running task. If the presence of external dependencies are necessary to test the logic, they should be provided as test doubles.
  • It should be time (time of the day, timezone) and location independent.
  • It should be meaningful. Getter or setter testing is not meaningful.
  • It should be usable as documentation: readable and expressive.

External Dependency

Integration Test

Integration test depend on real external dependencies, such databases, and they are inherently slower than the unit tests. Integration tests should be automated, but they should run outside the continuous unit test feedback loop.

Test Double

A test double is meant to replace a real external dependency in the unit test cycle. This may be necessary either because the external dependency is unavailable, or the interaction with it is slow.