OrderedTest - Do not store values ​​from previous test. - visualstudio208 - Testing devices

I am trying to execute a Unit Test application using VSTS 2008 Unit Testing. My problem: I want to call two test cases ok. To do this, I use the order function for them to test VSTS 2008. The problem I am is that I am increasing the value of one variable (X) in TestA and based on this value I read something in TestB. But when the control enters TestB, I get the initial X value, but not what was incremented in TestA. I think for each vsts test, create a new instance of the test class in memory. Please suggest a solution for this, except using STATIC variables.

The code for it is below

   [TestMethod()]
   public void ff()
    {
        i = 11;
    }

    [TestMethod()]
    public void gg()
    {
        if (i == 4)
        {

            System.Diagnostics.Debug.WriteLine("it is 4");
        }

        else
        {
            System.Diagnostics.Debug.WriteLine("it is 7");
        }
    }

      

Thanks in Advance

0


source to share


2 answers


Can your tests be redesigned so that each can be run separately? This is the correct way to check 99% of the time. While this adds a little overhead and you can duplicate your setup a bit, it is much easier to maintain and each test can focus on a single feature without worrying about environmental changes.



+1


source


run your ordered tests using the TestView window under Test> Windows.



pushing all tests in a solution will cause your ordered tests to fail.

0


source







All Articles