Software Developer how-to

How to Write a Unit Test

Tests protect code from future breakage.

Updated By the Career Education Institute Curriculum Team
Quick answer

Tests protect code from future breakage. In short: pick; set; call, then complete the remaining steps below.

Step by step

  1. Pick one function or behavior.

  2. Set up the input data.

  3. Call the function.

  4. Assert the expected output.

  5. Test edge cases such as empty or invalid input.

  6. Run tests automatically in CI.

Safety reminders for software developers

  • Protect credentials and never commit secrets to code
  • Follow secure coding practices
  • Use ergonomic setups and take screen breaks
  • Test changes before deploying to production

Source code · Git · Pull request · API · Front end · Back end: see the full software developer glossary.

More software developer how-to guides

Enroll in trainingTake fit quiz