How Does MSTEST/Visual Studio 2008 Team Test Decide Test Method Execution Order?

前端 未结 7 1291
一个人的身影
一个人的身影 2020-12-03 21:47

I was under the impression that the test methods in a unit test class would be executed in the order that they appear in the class file. Apparently this is not true. It also

相关标签:
7条回答
  • 2020-12-03 22:08

    It's very simple. I am using this

    C:>mstest /testcontainer:C:\MyTest.dll /resultsfile:C:\MyTestresults.xml

    The logic is here that by default mstest gives you a .trx file. So in the command against [/resultfile:] option write the name of file by giveing .xml extension. So I used /resultsfile:C:\MyTestresults.xml instead of /resultsfile:C:\MyTestresults.trx

    This works fine for me. Let me know if it works for you.

    0 讨论(0)
  • 2020-12-03 22:10

    In my experiences (I was little hard) I tried a lot of thinks about the change order of the method execution orders in the MStest project. I'm going to try describe the steps.

    1. You should ensure delete the default .testrunconfig and .vsmdi files. These files createdby Visual Studio when the creating test project.

    2. Close the Visual Studio instance and reopen it.

    3. When the Visual Studio opened you should open the Test List Edior then Create your own list under the Lists of tests section. After you create a new test list it should be empty.

    4. Go to All Loaded tests section then drag any test onto newly created test section with your choised order.

    Then ensure your last created test section checked and you can press the run test and voala it's running with your defined order.

    I don't know this might bug or some thing like that, but it magically working. We tested this method a couple of time with my colleague.

    Good lock

    0 讨论(0)
  • 2020-12-03 22:12

    There are many ways to order the tests in VS. Use the test view and the add extra columns and order. I use VSMDI files and this runs them in order specified therein.

    0 讨论(0)
  • 2020-12-03 22:15

    Problem: What I want to do is to run only the web tests that are included into my ordered test. I'm using an ordered test just for that purpose, so I can run my web tests in the specific order I need them to run in. I have lots of web tests, but my ordered test contains a sub-set of those web tests, which I would like to run. Solution: An ordered test is used to run a set of tests in a certain order. Create an Orderer test list in Visual Studio/test project. From test view window (Test | Windows | Test View), select the OrderedTest and run it from there (you can right-click it and select "Run Selection"). The orderedtest will automatically run all your webtests that are included in it.

    You will the the results in the test results window (Test | Windows | Test Results); double click the OrderedTest, and you will see detailed results for everyone of your webtests there. You can double click each webtest, and you will be able to see detailed results for each of them.

    0 讨论(0)
  • 2020-12-03 22:18

    It shouldn't matter what order they run in ... if your tests depend on another test running first, your tests are flawed :-)

    0 讨论(0)
  • 2020-12-03 22:21

    I was able to track down the answer.

    According to Microsoft employee Guillermo Serrato:

    MSTest executes all tests synchronously, the order is nondeterministic

    0 讨论(0)
提交回复
热议问题