Functional tests

Definition
Code that tests the correctness of individual functions, modules, and the full system.
Functional tests

How does it work?

A functional test is commonly automated (run by a test-platform). It calls a function of the system with common inputs and edge case inputs, and checks if the outputs match the outputs you'd expect.

Most major programming languages provide a testing framework that helps you to set up and run tests.

  • unit tests tests of individual functions
  • integration tests testing the cooperation of two modules
  • system tests tests of the full system

When should you use it?

A commonly heard advice is to strive for "100% code coverage", which means that each and every line of code should be "touched" by at least one test. And that tests take take time, but fixing bugs takes even more time in the end.

However, testing everything has the disadvantage that writing the application takes at least twice the amount of time. A method that is more time-effective consists of assessing the risk of the failure of each function, and testing only functions with an unacceptable risk.

Problems

  • Writing tests takes time in the short run and this slows down the time to ship your application
  • Not writing tests takes time in the long run that goes into debugging code

Links