質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top