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 8199719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:13:45+00:00 2026-06-07T06:13:45+00:00

I have a basic Test setup using NUnit 2.6 and Visual NUnit in Visual

  • 0

I have a basic Test setup using NUnit 2.6 and Visual NUnit in Visual Studio 2010. My problem is that when I’m running all tests it seems like the FixtureSetup method (which has the TestFixtureSetUpAttribute) is running one time for each of the tests.

I’ve also tried to put the Init code to the constructor, but it gives the same results.

The tests themselves reports their run time to runtime like 0.003 and 0.032 and so on.

    [TestFixture]
    public class MODatabaseTests
    {
        [TestFixtureSetUp]
        public static void FixtureSetup()
        {
           // Perform heavy init (~1.5s)
        }

        [Test]
        public void TestA()
        {
            ...
        }

        [Test]
        public void TestB()
        {
            ...
        }

    }
  • 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-07T06:13:46+00:00Added an answer on June 7, 2026 at 6:13 am

    If you add this code, you can confirm your suspicion:

        private static bool initialized = false;
        [TestFixtureSetUp]
        public static void FixtureSetup()
        {
            if (initialized) Assert.Fail("fixture setup called multiple times");
            initialized = true;
            ...
        }
    

    The test runner may calling every test individually instead of treating a TestFixture as a suite of tests.

    As an aside, I would avoid static in unit tests because if you have any static variables, their state would be carried from each run (though the fixture kind of wants this) and you lose the “unit” part of unit testing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup a basic test app that displays a view containing a label,
I have 2 projects in my solution: Assembly (Basic Library) Test Assembly (NUnit) I
I have a basic question: When using JUnit, in your test suite (the class
Does anyone have experience using makefiles for Visual Studio C++ builds (under VS 2005)
I have some basic PHP code: $raceramps56[short] = My Test Product; $leftMenu = '<div
I have basic Spring MVC 3 setup for i18n where I can show labels
I have a basic nServicebus 3.2.0 setup with a web application endpoint and a
I have a basic web application written in Java, running on a tomcat on
I have a basic web service that returns the following object as JSON: public
I have an IE bug that I'm not sure how to fix. Using jQuery

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.