...

/

Unit Testing Best Practices

Unit Testing Best Practices

Learn the fundamental best practices when writing unit tests.

Introduction

Writing test cases is somewhat easier than writing application code. However, it is easy to forget the dos and don’ts when writing test code. Fortunately, many best practices are considered universal when writing test code. These practices are transferable and applicable from one test project to the next. We will look at the most important ones below. Each best practice has a quiz question to further test your understanding of that particular section.

Tests must exclude control structures

The application code handles control structures and the test code tests them. If the test code handled control structures, it too would be prone to failure. We do not want failure-prone tests because this would defeat the purpose of testing.

Testing the tests

1.

Can you think of a quick way to check if your tests are written incorrectly?

Show Answer
Q1 / Q1
Did you find this helpful?

Select a

...