I am currently writing tests using TDD, and I came across several queries.
Usually, when writing unit tests, I always used 1 statement on unit tests, as this is what is defined as good practice, and it is easy to understand why your test fails.
In TDD, it’s also good practice to do the same, if so, then for the effective design of 1 method using TDD I’m going to end up with more than 1 unit test - since I would really need more than 1 claim.
Another problem is what am I really claiming?
I could argue that I think a return object could be?
So I would need to create a return type (can be complex with many properties) and make sure that they match the statement, it can be technically affirmative.
Or another way would be to ensure that my layouts that I did along the way are actually called ie ru MOQ, I could do the following
myServiceMock.Verify(x => x.ItemsReceived(), Times.Once());
Thus, I can guarantee that the method will be called ONLY ONCE on my layout, it is actually really classified as a statement. Thus, it returns to the original request: 1 assert per unit test, so I will need to create additional unit tests to ensure that other methods are called for other mocks.
What are everyone else doing here?
You state that methods are called in mocks or that return values are as expected.
, , -, .