What attribute should a good unit test have?

Unit test should

  • produce a deterministic result
  • to be independent
  • be valid
  • ...

What other characteristics should the test have?

+3
source share
9 answers

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 , - . , , .

+7

: A-TRIP

+3
+1
  • : (CI).
  • : ( ).
  • : , .
  • . .
  • : , , , ..
+1

, , - small. A unit test . . . unit test IMO 10 . , , . .

, - , ... , unit test.: -)

+1

, , . , , , .

0
  • .
  • ( X , Y ..).
  • . , , .
  • -.
  • .
0

A unit test : .

0

unit test, :

  • .
  • , (, ).

, , . , unit test. , , , , .

source:

0

Source: https://habr.com/ru/post/1615650/


All Articles