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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:44:46+00:00 2026-06-13T18:44:46+00:00

When Visual Studio is running unit tests, it runs many tests simultaneously. What exactly

  • 0

When Visual Studio is running unit tests, it runs many tests simultaneously. What exactly is the scope of the test class while these are running. Are they all run in separate app domains or is data shared at all?

For instance if I have the following test class:

[TestClass]
public class FooTests
{
    Mock<ISomeInterface1> _complexMock1;
    Mock<ISomeInterface2> _complexMock2;

    public void CreateComplexMocks()
    {
        //set up _complexMock1 & _complexMock2
    }

    [TestMethod]
    public void Test1()
    {
        CreateComplexMocks();

        //use _complexMock1 & _complexMock2 in test
    }

    [TestMethod]
    public void Test2()
    {
        CreateComplexMocks();

        //use _complexMock1 & _complexMock2 in test
    }
}

The tests utilise the CreateComplexMocks() helper to construct some mocks. These are exposed as members rather than being passed back to the test (there would probably be many more in a real world example)

My question is, if both tests run at the same time, will they be sharing the state of _complexMock1 and _complexMock2?

What if the complexMocks were static?

  • 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-13T18:44:47+00:00Added an answer on June 13, 2026 at 6:44 pm

    Having found this blog, it would appear that a separate test class is instantiated for every test, on a different thread.

    So instance members will not be shared, but static members will.

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

Sidebar

Related Questions

Is there an API for running Visual Studio Unit Tests programmatically? Running MSTests.exe with
I am writing unit tests in visual studio 2010. For test some functionality, I
How can I create in Visual Studio 2008 unit tests running on .NET Full
I'm considering running unit tests for my Visual Studio 2010 projects on our build
After converting to Visual Studio 2010 with ReSharper5 some of my unit tests started
When running our unit tests in debug mode, at a certain point the Visual
I am writing some unit tests in Visual Studio 2010. I can run all
In Visual Studio 2010, I have a number of unit tests. When I run
We use Visual Studio 2010 Ultimate with tests written in MSTest. Both our unit
Using Visual Studio and TFS & preferably Specflow or standard unit test. I want

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.