Oh. My favorite subject :-) Where to start ...
According to xUnit Test Samples by Gerard Mesaros (Unit Testing Book)
- Tests should reduce risk, not introduce it.
- Tests should be easy to run.
- Tests should be easy to maintain. the system is developing around them
Some things to make it easier:
- Tests should only fail due to one reason. (Tests should check only one thing, avoid multiple statements, for example.)
- . ( )
- (
, , ui
.)
:
. . , , , .
AAA. , , , .
, ,
, ,
. .
Mocks Stubs
, .
Stubs - , , . , . Mocks , , . Mocking , - . , , .