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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:59:40+00:00 2026-05-16T02:59:40+00:00

So, I was not totally sure this was true: [TestClass] public class UnitTest1 {

  • 0

So, I was not totally sure this was true:

[TestClass]
public class UnitTest1
{
    private int i = 0;

    [TestMethod]
    public void TestMethod1()
    {
        Thread.Sleep(5000);
        Assert.IsTrue(i == 10);
    }

    [TestMethod]
    public void TestMethod2() {
        i = 10;
    }
}

By the results of the test, it looks like it isn’t, but I’d like to know for sure that if I define a global variable on a Test Method, it can’t be read by other Test Methods.

Also, do I have to define

    [TestCleanup]
    public void Test_Cleanup() {
        engine = null;
    }

becase of this

    [TestInitialize]
    public void Test_Initialize()
    {
        var pieceGeneratorMock = new Mock<IPieceGenerator>();
        pieceGeneratorMock.Setup(pg => pg.Generate())
            .Returns(new Piece(Color.Red));
        IPieceGenerator pieceGenerator = pieceGeneratorMock.Object;

        Size size = new Size(4, 4);
        BackgroundBoard backgroundBoard = new BackgroundBoard(size);
        PieceBoard pieceBoard = new PieceBoard(size);
        engine = new Engine(pieceGenerator, backgroundBoard, pieceBoard);
    }

?

  • 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-16T02:59:41+00:00Added an answer on May 16, 2026 at 2:59 am

    In JUnit, at least, each test method is invoked on a separate instance of your TestCase. You could verify this for yourself by outputting/logging the indentity hash of this in each test* method.

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

Sidebar

Related Questions

I'm not totally sure but this looks wrong: I have a header file named
Not totally sure how to approach this. I've researched a bit but I've come
I'm still not sure I totally get how this particular case should work out.
Okay, I feel totally stupid posting this. I am not sure if it is
This may be an obvious search, but I'm not totally sure on the proper
OK, I'm guessing that this might be a bug but I'm not totally sure.
I am not sure whether this is a bug or if I have totally
Not sure if this counts as programming related, it's a tool that I use.
Not entirely sure of a good title for this, feel free to edit it
Hi folks this is prob quiet simple but not sure how to do it.

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.