Question

I want to use NUnit to run GUI / integration tests. What I would like to do is to initialize some custom reporting (from GUI-testing framework we use) before all tests and to run export of the reports after the whole suite has been run.

Is there some "super" setup method or practice to solve this problem?

I thought about running a special "TestFixture" before and after all other tests, but that is quite poor idea. Another way would be to run some scripts afterwards but that doesn't solve the problem with pre-run initialization of logging.

Était-ce utile?

La solution

You can use the [SetUpFixture] attribute to instantiate a class before all tests are run. The constructor of this class will be called first. If this class implements IDisposable, then the Dispose method will be called after all tests are run.

Here's an example:

[SetUpFixture]
public class IntegrationSetUpFixture : IDisposable
{
    public IntegrationSetUpFixture()
    {
        // runs before all tests
    }

    public void Dispose()
    {
        // runs after all tests
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top