3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MSTest v2でテストを並列に実行する

Posted at

MSTest v2ではデフォルトで直列にテストが実行されるようです。

テストを並列に実行したい場合は、Properties\AssemblyInfo.csに、以下の通り修正します。

AssemblyInfo.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ExecutionScope = Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope;

[assembly: Parallelize(Workers = 4, Scope = ExecutionScope.ClassLevel)]

上記のWrokersは並列するテストの個数を指定し、Scopeは並列化する単位(クラス毎かメソッド毎か)を指定します。
また、この単位だけは直列にしたいという場合は、クラスもしくはメソッドに以下の通りDoNotParallelize属性を付加します。

    [TestClass]
    [DoNotParallelize()]
    public class TestClass
    {
    }
    [TestMethod()]
    [DoNotParallelize()]
    public void TestMethod()
    {
    }
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?