DEV Community

Discussion on: Questions from conducting TDD workshops

Collapse
 
devmonte profile image
Grzegorz Jońca

Do you prefer to use one test class for class with logic or class with tests for one method which is being tested? And second - do you strictly use naming convention for test doubles?

Collapse
 
meanin profile image
Paweł Ruciński
  1. As always, it depends. If class with logic is small enough, I prefer one test class per one tested class. Otherwise, I am creating one class with tests for some similar use cases to group them in reasonable bunch.

  2. Yup, my every test double name consist of variable name and suffix mock. In that case, it is easier to setup its behavior.

Thanks for questions.

Collapse
 
markschweiger15 profile image
Mark Schweiger

I try to follow the SRP, a class should have no more than one responsibility - So usually my test class covers one class with logic - so it should have at least one method.

I usually add fake/mock as a prefix e.g. fakeProductController.