Is there any good book or material which covers C# unit testing using mocks in depth?
While performing unit testing, make sure that all the unit tests are independent. If having any dependencies, then unit tests can get affected when there are any changes or enhancements. Also, it can result in complexities for the test cases to run and debug. Hence, always make sure that unit test cases are independent. 2.
A well-constructed unit test can be used as documentation, which is updated each time the test is run. Because each unit test is a standalone function, it can test different parts of a project without waiting for others to be completed.
– While executing the test cases, the unit test frameworks help to flag and report the failed test cases. Also, based on the failures in the test cases, the unit test frameworks help to stop the related testing. What are Unit Testing best practices? 1. Ensure Unit Tests are independent of each other:
A unit test case works with something specific about a functionality, it doesn't cover it entirely. It's a bad practice to create something called testAllThings and call every method in the namespace. Another important aspect of a unit test is that it works with the use case in isolation.
How about The Art of Unit Testing. This is .NET specific, and should be fairly up to date.
There is a rather good book describing how to use NUnit and NMock to do C# unit testing:
Pragmatic Unit Testing in C#
There are lots of documents on the nmock web site:
http://www.nmock.org/tutorial.html http://www.nmock.org/advanced.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With