Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top