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?
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.
Yup, my every test double name consist of variable name and suffix mock. In that case, it is easier to setup its behavior.
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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?
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.
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.
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
.