Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to order methods of execution using Visual Studio to do integration testing?

I have 2 questions in regard doing integration testing using VS 2010

First, I'm really in need of finding a way to execute these testing methods in the order I want them to. Note: I know in Unit Testing, methods should run standalone from anything else, but these are integration tests which I do depend on the order of which method runs first.

On the same note, is there a way to keep a local variable through running the tests? For example like the following code which right now fails.

[TestClass]
public class UnitTest1
{
    int i = 0;
    [TestMethod]
    public void TestMethod1()
    {
        i = 5;
    }

    [TestMethod]
    public void TestMethod2()
    {
        Assert.AreEqual(5, i);
    }
}

So is there a way to do any of these?

like image 721
Ray Avatar asked Jan 13 '11 19:01

Ray


People also ask

Which methodology is used in integration testing?

The methodology used is Black Box Testing. Either bottom-up or top-down integration can be used. Test cases are defined using the high-level software requirements only.

How do I run Mstest in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.


1 Answers

To execute tests in a specific order I followed the next steps:

In a test project with test1, test2 and test3

1 Right click on the project 'Add'->'new test..."
2 Select 'Ordered Test'
3 Double click in the file that appears "OrderedTest1.orderedtest"

alt text

4 Build the project if was not build previously
5 From the list of available test select the test you want and order them

alt text

From that point on there appears a new test in the test list editor

alt text

It is an extra test that runs the enclosed tests in the correct order, but if you run all the test in the project carelessly the tests included in the ordered list will be executed twice so you need to somehow manage lists or test categories to avoid that.
I tried disabling the individual tests but that also disables the ordered test, I don't know a better way to do so.

like image 88
Cristian T Avatar answered Oct 24 '22 09:10

Cristian T