Allow for assembly setup and teardown #111

Closed
giggio opened this Issue Jun 4, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@giggio

giggio commented Jun 4, 2014

Similar to what is find in AssemblyInitialize for MsTest or SetUpFixture in NUnit, allow some code to run before any test in a specific assembly run, and after all of them have ran.

The main reason to ask for that is because of integration tests, where we usually need to do some preparation on the environment before any tests can run, like write some files, migrate a DB, bring up a web server, etc. And to clear it all up at the end.

Also, it is very hard to migrate from other framework that already support this.

I am aware that there are workarounds. I understand that it is possible to create some static class with a static constructor and call it somehow, or maybe have all test classes inherit from a base test class and do the setup there. But this means have to mix setup concerns with test concerns, which is not good design. Also, again, it is a lot of work when migrating from some other framework and you have hundreds of tests.

@bradwilson

This comment has been minimized.

Show comment
Hide comment
@bradwilson

bradwilson Aug 2, 2014

Member

After discussing this, we have decided that we are opting not to do this. Thank you for the suggestion, though.

Member

bradwilson commented Aug 2, 2014

After discussing this, we have decided that we are opting not to do this. Thank you for the suggestion, though.

@bradwilson bradwilson closed this Aug 2, 2014

@ewilde

This comment has been minimized.

Show comment
Hide comment
@ewilde

ewilde Feb 9, 2015

@bradwilson I struggling to enable some scenarios without this kind of feature. Here is what i do with nunit during an integration test.

[SetUpFixture]
    public class RunOncePerNamespace
    {
        [SetUp]
        public void Setup()
        {
           // Setup databases and services
        }

        [TearDown]
        public void TearDown()
        {
            // Shutdown databases and services
        }
    }

What are the workarounds in xunit the enable this type of thing ? Care to share why you opted out of doing this?

ewilde commented Feb 9, 2015

@bradwilson I struggling to enable some scenarios without this kind of feature. Here is what i do with nunit during an integration test.

[SetUpFixture]
    public class RunOncePerNamespace
    {
        [SetUp]
        public void Setup()
        {
           // Setup databases and services
        }

        [TearDown]
        public void TearDown()
        {
            // Shutdown databases and services
        }
    }

What are the workarounds in xunit the enable this type of thing ? Care to share why you opted out of doing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment