Tim Driven Development | Test until the fear goes away
SCEA, PMP, read my blog: www.yegor256.com
Yegor Bugayenko wrote:Instead of mocking it's better to use fake objects
Yegor Bugayenko wrote:As a rule of thumb, try to stay as far away from mocking frameworks, as you can.
Tim Driven Development | Test until the fear goes away
Time Cooke wrote:It depends on what you define as a unit. If your ImplementationClass, A, B, and C all work together to perform a single 'unit' of functionality in your application then you might want to test them all together using the production versions of each class.
Tim Cooke wrote:Your tests should describe a function in terms of your problem domain, not in terms of the implementation
Yegor Bugayenko wrote:As a rule of thumb, try to stay as far away from mocking frameworks, as you can.
Yegor Bugayenko wrote:Instead of mocking it's better to use fake objects. I've published an article on this subject a few weeks ago
SCEA, PMP, read my blog: www.yegor256.com
SCEA, PMP, read my blog: www.yegor256.com
Tim Driven Development | Test until the fear goes away
SCEA, PMP, read my blog: www.yegor256.com
Carl McGraw wrote:Generally that is as complex as my structure gets. I try to follow SRP enough such that I've never run into a case that I had to return multiple levels of mocks (normally just a mock that returns a stub, that stub is just confirmed that it is passed around).
Doing this I've been able to test all potential return values from expected to null and with throwing potential exceptions. But I am worried that it isn't good practice to do this.
Junilu Lacar wrote:There's no rule that says all your tests for one particular class have to be in one unit test class. So, my approach would be to separate whitebox tests from blackbox tests. This way, if your implementation changes, only the test class with the whitebox tests needs to be changed.
Carl McGraw wrote:These tests most certainly are "verifying" types, and as such I think they are still "beginner" types of tests.
I haven't been able to really take the leap and have my design be informed by the tests yet. I feel like if I get enough practice writing tests though eventually things will click.
Junilu Lacar wrote:If your mocking gets too complicated, then your object relationships are likely too complicated as well. If your test code requires a lot of complicated setup to test one small behavior, then there may be problems with your abstractions.
SCEA, PMP, read my blog: www.yegor256.com
keep an eye out for scorpions and black widows. But the tiny ads are safe.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|