chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
+1 vote
What is the difference between the [TestCleanup] and [Isolated] attributes?
What is Isolate.CleanUp() do and when should I use it?
asked by Noob (2.1k points)

1 Answer

+1 vote
[TestCleanup] is an MS-Test attribute, equivalent to [TearDown] in NUnit. These attributes annotate test-runner methods, that run after every test and cleans up its side-effects.

Isolate.CleanUp()is a function which cleans up any behavior set with Isolator's APIs in the test. It should be called at the end of each test. It could be called inside a [TestCleanup] method.

[Isolated] is an Isolator attribute that you assign to a test or the whole test class. It runs initialization before tests, and cleans up after the test. It is the equivalent of calling Isolate.CleanUp().

[Isolated] class is the same as [Isolated] every method in the class.

*[Isolated] can only be assigned to test methods or classes.
**we recommend using [Isolated] on the whole test class over using Isolate.CleanUp() in a [TestCleanup] method.
answered by NofarC (4k points)
...