Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSTest v2 Ordered Tests

I am using Visual Studio 2017 Enterprise and MSTest V2. My solution has multiple Unit Test projects. In one project, I have unit tests that are testing the loading of resources from the installation directory. Most test that the resources are loaded correctly, but some delete the resource to confirm that this is handled correctly as well.

enter image description here

The issue that I am having is that the tests run in parallel. Therefore, the tests that remove the resources do this at the same time the tests that are loading the resources are running, and I get failed tests.

I realize I can resolve this by updating my code to send the directory to search, or by running one set of tests and then the next, but I would prefer being able to run all tests at once. It sounds like MSTest v2 is supposed to run sequentially unless otherwise directed to run in parallel, but on my system, this is demonstrably false. It also appears that Ordered Test does not work with v2. Is there a way to get MSTest V2 to run sequentially?

like image 766
Tim Avatar asked Mar 28 '19 17:03

Tim


1 Answers

  1. MStest v2 will not support orderedtests issue
  2. you may have set the parallelization scope in testsettings file or Assembly file https://www.meziantou.net/mstest-v2-execute-tests-in-parallel.htm If you remove that it will run sequentially

I would say that you can create a flag and update that from dependent test, check for the flag status before cleaning up resource. may be a dictionary of testname and status, once its done, execute this test or wait for that test to complete. you can implement a custom logic for that.

like image 183
SSP Avatar answered Sep 19 '22 11:09

SSP