Software Testing, Test Coverage, Quality Assurance

Naufal
HappyFresh Fleet Tracker
2 min readNov 7, 2019
https://insights-images.thoughtworks.com/TDDInsightspost_f57abdf33d2a1f4328e2c3c3fc8322cd.png

Rapid development and adaptation is a trait that is no longer optional in the software engineering field. With changes that come and go on a daily basis, we need a reliable and potent method of assuring that quality is maintained in our code.

Enter TDD

Test-Driven Development or TDD is a development process that relies on the success of specific test cases, which gates features and changes from being delivered until they reach a certain criteria.

The TDD process performs under a rapid, short-term development cycles where requirements are formulated onto the test cases which needs to be passed to define them as deployment-ready.

Development

In implementing the proper practice of TDD in our software development, there are some guidelines that we could heed, mainly the RED/GREEN/REFACTOR development cycle.

  • RED

A unit test is generated based on a requirement, usually to fulfill a feature needed by the software. This unit test will be made such that it fails and will continue to do so until the requirement is met

  • GREEN

The production code is then made by the team to first meet the criteria set by the test assuring that any line of code, fresh or refactored, will not break the functionality of the feature.

  • REFACTOR

The working code is then refactored to improve maintainability. At this phase, improvements towards the architecture, factorization, and presentation is made.

Clean Unit Tests

TDD does not guarantee perfectly functioning code as long as the unit tests behind each requirement is not optimal, as the test code is as important if not more than the production code.

A clean test must follow these principles to assure quality:

  • Independent, each unit tests are not dependent on other features.
  • Repeatable, as any environment must be compatible to reproduce them.
  • Self-Validating, a test must have a binary result (Success or Fail) to assure quick and easy conclusion

Test-Driven Development might seem time consuming or even unproductive to an adept developer or those who are unfamiliar with the process. In reality, TDD reduces the need to refactor and debug broken codes that are inevitable when changes are verbose and code responsibility is held by multiple developers.

In the end, maintaining a reliable and exquisite product is priority, and TDD is an excellent assurance of that goal.

--

--