Independent & Side-Effect-Free
Test Independence
Tests should not depend on data from other tests.
You've seen examples of tests relying on the same piece of data created by test setup.
Sharing the data creation code simplifies writing tests and reduces duplication,
while keeping the tests independent.When tests are independent, we can run any subset of the tests, in any order.
We create freedom to move and ease of writing, and avoid wasting time chasing
weird test failures.
(Reading...)
Formatting Hints:
To format... | use this markup: |
---|---|
source code | {source:lang=java|lineNumbers=false}...{source} (Supported languages: java, cpp, csharp, c, python.) |
bold text | __some text__ |
italicized text | ~~some text~~ |
underlined text | @@some text@@ |
a method or class name | ``myMethod(...)`` |