Question

I am almost sure that they are. But I need to confirm that.

class Foo {
  Bar fieled;
  [Test]
  public void bar() {
    field.DoSomething();
  }

  [Test]
  public void baz() {
    field.DoSomethingElse();
  }
}

In theory both methods can use shared field, then we have unpredictable result. Right? I am particularly interested in NUnit and XUnit frameworks.

Was it helpful?

Solution

XUnit.NET creates single test object instance per test method, as described here http://xunit.codeplex.com/wikipage?title=WhyDidWeBuildXunit&referringTitle=Home

So shared field in test class is not an issue even if tests are executed concurrently, assuming you dont use static fields. For other frameworks im not sure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top