Unit tests in C ++

Is it good to break all dependencies with interfaces to make the class verifiable? This is associated with significant runtime overhead due to many virtual calls instead of regular method calls.

How does test-based development work in real C ++ applications? I read "Working Effectively with Legacy Code" and liked it quite helpful, but did not get up to speed up the practice of TDD.

If I do refactoring, this happens very often, so I have to completely rewrite the unit test due to massive logical changes. My code very often changes the basic logic of data processing. I see no way to write unit tests that do not need to be changed in a lot of refactoring.

Maybe someone can point me to an open source C ++ application that uses TDD to learn by example.

+5
source share
7 answers

Update : see this question.

I can answer only some parts:

Is it good to break all dependencies with interfaces to make the class verifiable? This is associated with significant runtime overhead due to many virtual calls instead of regular method calls.

- , (!). , ( ). , , .

"" TestAccessor, . . ( .)

. , . , , , , .

, , unit test - . . , .

, . , , .

, , , , , . , , , - , , .

, . , . .

, .

+5

, #if "" C ++, , , , . , .

, , , . , .

+3

, , . , ( , ), , , . , typedefs, .

+1

- , , , , . , , , . , .

- , . - , , . , , . , , , , , , , .

+1

, ? - .

, , .

, , unit test - . . , .

, . , , .

, TDD, :

  • ,
  • ,
  • , , , , .

, , . , . , ++ - , , .. ..

, ++, . TDD, .

+1

, , unit test - .... , .

, . Unit test, , , . , . , .

[] , testable?

, . TDD, .

- .

, . , ( " , , " ). . - , ? , , , .

, . , , . - . , , . , " , ?"

0

- .

, , ( ) . , , .

, , , . , , . ( , ).

0

All Articles