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

  • Home
  • SEARCH
  • 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 214797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:24:32+00:00 2026-05-11T18:24:32+00:00

I have been doing some research on test driven development and find it pretty

  • 0

I have been doing some research on test driven development and find it pretty cool.

One of the things I came across was that when you write your tests, there is an order of execution of your setup and test methods ([Setup] and [Test]).

Are there others that you can use while testing and if so what is the execution order of those, such as a dispose or something? I saw test fixture setup, but not too familiar with that one.

Example:

When I run the test, it does the [Setup] first and then runs the [Test] when it goes to the next test it runs the [Setup] again and then goes to the [Test].

I am using NUnit if that helps.

Here is a truncated example of what I have setup:

using NUnit.Framework;

    namespace TestingProject
    {
        [TestFixture]
        public class CustomerService_Tests
        {
            public string MyAccount = string.Empty;

            [SetUp]
            public void Setup()
            {
                MyAccount = "This Account";
            }

            [Test]
            public void Validate_That_Account_Is_Not_Empty()
            {
                Assert.That(!string.IsNullOrEmpty(MyAccount));
            }

            [Test]
            public void Validate_That_Account_Is_Empty()
            {
                Assert.That(string.IsNullOrEmpty(MyAccount));
            }
        }
    }

So, when I run the tests, it does the setup, and then the first test, then setup and then the 2nd test.

My question is what other types can I use while testing such as [Setup] and [Test] and what is the order of execution for these.

  • 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-05-11T18:24:32+00:00Added an answer on May 11, 2026 at 6:24 pm

    Using NUnit (not sure about others) you have the following order of executions:

    TestFixtureSetup

    Setup

    Test

    TearDown

    Setup

    Test

    TearDown

    TestFixtureTearDown

    Every time you run your tests it will always execute in that order.

    If you take a look at the following code, you can see an exact replica of what I am talking about. You can even copy and paste this code and it should work (using NUnit, not sure if it will work with others).

    If you run this in debug mode, and put a break point on each of the methods, you can see the order of execution while you debug.

    using NUnit.Framework;
    
    namespace Tester
    {
        [TestFixture]
        public class Tester
        {
            public string RandomVariable = string.Empty;
    
            [TestFixtureSetUp]
            public void TestFixtureSetup()
            {
                //This gets executed first before anything else
                RandomVariable = "This was set in TestFixtureSetup";
            }
    
            [SetUp]
            public void Setup()
            {
                //This gets called before every test
                RandomVariable = "This was set in Setup";
            }
    
            [Test]
            public void MyTest1()
            {
                //This is your test...
                RandomVariable = "This was set in Test 1";
            }
    
            [Test]
            public void MyTest2()
            {
                //This is your test...
                RandomVariable = "This was set in Test 2";
            }
    
            [TearDown]
            public void TestTearDown()
            {
                //This gets executed after your test gets executed. 
                //Used to dispose of objects and such if needed
                RandomVariable = "This was set in TearDown";
            }
    
            [TestFixtureTearDown]
            public void TestFixtureTearDown()
            {
                //Executes Last after all tests have run.
                RandomVariable = "This was set in TestFixtureTearDown";
    
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's another way to approach this. Replace your while-loop with… May 11, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer As mentioned, a wrapper around the Thread class could catch… May 11, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer Cleanup should be handled by destructors and child-parent relationship. Make… May 11, 2026 at 8:45 pm

Related Questions

I am looking for a utility that can be used against .NET assemblies to
I've been doing some research on how to globally handle errors in my ASP.NET
To quickly summarise my question: Is it feasible to programmatically change the name of
Okay, so far, I have been taking computer science courses in my high school
I've been doing a lot of research on how best to write correct network

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.