I am expecting vstest.console.exe will run all test methods in parallel with /Parallel
option specified. On a 4 core machine, I am expecting below test class will cost around 2~3 seconds for execution, by actually I got 8~9 seconds which means the tests are executed sequentially.
[TestClass]
public class UnitTest1
{
[TestMethod]
public async Task TestMethod1()
{
await Task.Delay(2000);
}
[TestMethod]
public async Task TestMethod2()
{
await Task.Delay(2000);
}
[TestMethod]
public async Task TestMethod3()
{
await Task.Delay(2000);
}
[TestMethod]
public async Task TestMethod4()
{
await Task.Delay(2000);
}
}
The test ouput:
Microsoft (R) Test Execution Command Line Tool Version 15.5.0 Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait... Passed TestMethod1 Passed
TestMethod2 Passed TestMethod3 Passed TestMethod4Total tests: 4. Passed: 4. Failed: 0. Skipped: 0. Test Run Successful.
Test execution time: 8.6960 Seconds
vstest.console.exe /Parallel MyUnitTest.dll
produces the above result. Noticed I got same execution time with/without /Parallel option, looks it does not have any effect. – Shuping