loading...

Writing Unit Test

princecurie profile image Onwubiko Chibuike ・1 min read

Alt Text
Photo by Ferenc Almasi on Unsplash

What is a unit test?

A unit test is a check to ensure that a function works as expected. It is written during the software development process.

Why the unit test?

  • Makes it easier to add a new feature or delete a feature.
  • The developer refactors with more confidence.
  • Bugs are found earlier during development.
  • Makes debugging easier.
  • It improves code quality.

Tips to keep in mind when writing unit test

  • The function/module should contain all input(s) needed as parameters.
  • The function/module should return an output.
  • Do not test any external module, library or function for example the database, an API etc.

Discussion

markdown guide