0

I'm using MbUnit + Gallio. I know that MbUnit has attributes which can be applied to methods which should run:

  1. [FixtureSetUp] - before each fixture
  2. [FixtureTearDown] - after each fixture
  3. [SetUp] - before each test
  4. [TearDown] - after each test

But, say, I run several fixtures at once. And I would like to run a piece of code after ALL fixtures have already been run.

Is it possible to do it?

4

1 回答 1

0

找到了解决方案。它非常简单优雅。您只需使用 [AssemblyFixture] 属性创建一个单独的类,并使用 [FixtureSetUp] 和 [FixtureTearDown] 属性定义 2 个方法。他们将在整个夹具套件之前和之后被调用。

    [AssemblyFixture]
    public class FixtureAssemblyClass
    {
        [FixtureSetUp]
        public void BeforeRunAssembly()
        {

        }

        [FixtureTearDown]
        public void AfterRunAssembly()
        {

        }
    }
于 2013-01-22T08:37:58.197 回答