Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:13:42+00:00 2026-06-12T07:13:42+00:00

I want to do some integration tests on my project. Now I am looking

  • 0

I want to do some integration tests on my project. Now I am looking for a mechanism that allow me execute some code before all tests begin and execute some code after all tests ends.

Note that I can have set up methods and tear down method for each tests but I need the same functionality for all tests as a whole.

Note that I using Visual Studio, C# and NUnit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:13:43+00:00Added an answer on June 12, 2026 at 7:13 am

    Annotate your test class with the NUnit.Framework.TestFixture attribute, and annotate you all tests setup and all tests teardown methods with NUnit.Framework.TestFixtureSetUp and NUnit.Framework.TestFixtureTearDown.

    These attributes function like SetUp and TearDown but only run their methods once per fixture rather than before and after every test.

    EDIT in response to comments:
    In order to have a method run after ALL tests have finished, consider the following (not the cleanest but I’m not sure of a better way to do it):

    internal static class ListOfIntegrationTests {
        // finds all integration tests
        public static readonly IList<Type> IntegrationTestTypes = typeof(MyBaseIntegrationTest).Assembly
            .GetTypes()
            .Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(MyBaseIntegrationTest)))
            .ToList()
            .AsReadOnly();
    
        // keeps all tests that haven't run yet
        public static readonly IList<Type> TestsThatHaventRunYet = IntegrationTestTypes.ToList();
    }
    
    // all relevant tests extend this class
    [TestFixture]
    public abstract class MyBaseIntegrationTest {
        [TestFixtureSetUp]
        public void TestFixtureSetUp() { }
    
        [TestFixtureTearDown]
        public void TestFixtureTearDown() {
            ListOfIntegrationTests.TestsThatHaventRunYet.Remove(this.GetType());
            if (ListOfIntegrationTests.TestsThatHaventRunYet.Count == 0) {
                // do your cleanup logic here
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write some integration-tests for my connect-middleware and test it with real-http-requests
I want to use hudson to build a maven-java project. Some of my integration
I have a dll-type project that contains MSTest integration tests. On my machine the
For some integration tests I want to connect to the database and run a
I have some integration tests that test the processing of USB data from a
I am writing a bunch of integration tests for a project. I want to
I have some integration tests that get kicked off by TeamCity on a successful
I want some code to be triggered every second. Usually, I'd create a Timer
The title pretty much says it all. I have a project that for political
I have some class libraries with NUnit tests, and I want to convert the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.