Step 4. Adding the Isolated Attribute to Tests
Because it is impossible to predict whether each test runs alone or in a group and in which order the tests will be run, the result of a test run should not depend on the order of execution. In addition, a test cannot rely on data and objects created by another test (such as behavior and fake objects left from other tests) which ran previously.
Typemock Isolator provides the [Isolated] attribute that instructs Typemock Isolator to clean up the result of the test after the test is completed.
You can use this attribute on the following levels:
• Test assembly
• Test class
• Test
Using the [Isolated] attribute at the test level overrides the behavior set on the class or assembly level. Therefore, you can set a general behavior and define a different behavior for specific cases.
The easiest way to use the [Isolated] attribute is to define it on the assembly level. In this case, the behavior will be defined for the entire assembly. If a special behavior is required for a class or test level, you can add the [Isolated] attributed to this class or test.
The following samples show how you can use the [Isolated] attribute on different levels.