Test Anatomy

part 4

Maintainability

what makes tests maintainable?

4 A

arrange
act
assert
annihilate

Atomic

tests should be independent
of their order

Simple

tests should be short
easy to understand
assert only one use-case scenario

Logic-less

tests should not contain:
conditionals / loops

Refactor

tests are just code

Dispel Magic

numbers & strings
7 > DAYS_IN_WEEK = 7
"asdasd" > "country name"
"xx" > NAME_WITH_2_LETTERS = "xx"

Reliability

what makes tests reliable?

Code Coverage

ignore code coverage
test business logic
use code coverage for validation

Cover Branches

cyclomatic complexity
edge cases

Trust

you should trust your tests
green = "it works"

Q & A

Thank You

Testing part 4: Anatomy

By Andrei Pfeiffer

Testing part 4: Anatomy

  • 798