Unit independence

A unit test should basically be a unit, it should be designed and written in a form that allows it to run independently. The unit under test, in this case a method, should have been written to depend subtly on other methods. If possible, the data needed by the methods should be taken through the method parameters or should be provided within the unit, it should not have to request or set up data externally for it to function.

The unit test should not depend on or be affected by any other tests. When unit tests are dependent on each other, if one of the tests fails when run, all other dependent tests will also fail. All the needed data by the code under test should be provided by the unit test.

Similar to the Single Responsibility ...

Get C# and .NET Core Test Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.