Naming Tests
Learn some good practices for naming tests in this lesson.
Using a consistent and meaningful naming strategy
A well-named test will help us quickly identify which test is failing and the area of the actual code that the problem might be in.
A well-named test will contain the following:
- What is being tested.
- The input to the thing being tested or the state of the thing being tested.
- The expected output or expected behavior.
It is helpful to have a naming convention for tests. This guarantees that the above aspects of a test are covered in the name. If the naming is consistent, we will very quickly understand the aspects of any test.
An example naming convention is as follows:
{thing being tested} should {expected output / behaviour} when {input / state}
Get hands-on with 1200+ tech skills courses.