English 中文(简体)
测试:同一试验室内的测试执行令
原标题:MSTest: execution order of tests within the same TestClass

在进行MS 试验时,我需要执行<条码>。

<代码> 试验编码 和每一类别内的测试可以是随机的,但管理试验不应从另一个<代码> 试验 进行测试,直至其执行<编码> /ClassInitialize、所有类别测试和。 类别Cleanup

I have global AssemblyInitialize and AssemblyCleanup, therefore the following does not work, because it initializes the assembly for each test:


MSTest.exe /testcontainer:MyUnitTests.dll /resultsfile:report.trx /test:TestClass1 /test:TestClass2
最佳回答

我询问了一个类似的问题:here,尽管这不是关于测试级执行令。 如果命令的理由使某种国家得以建立/维持,则命令试验可能会使其陷入困境。 如果你们的测试是这样的话,我建议以令状的方式撰写这些试验。

As regards your problem with the assembly-level code, a work around for the AssemblyInitialize and AssemblyCleanup can be as follows:

private int InitCount;

[AssemblyInitialize]
public static void Setup(TestContext context)
{
     if (InitCount++ == 0) {
         //Do Something
     }
}

[AssemblyCleanup]
public static void Teardown()
{
      if (--InitCount == 0) {
          //Do something
      }
}

基本上,你只能强迫大会一级的方法发生一次火灾。

问题回答

暂无回答




相关问题
Invoke callback in Moq

I have a method that performs an asynchronous service call. I call this class by passing in the callback. public void GetRights(EventHandler<GetRightsCompletedEventArgs> callback) { ...

Fluent NHibernate PersistenceSpecification CheckList

I am currently working on a college project in which we are using Fluent NHibernate. I am working on figuring how to create testing for our entities and Fluent mappings. I have, however, hit a dead ...

Why does Assert.AreEqual(1.0, double.NaN, 1.0) pass?

Short question, why does Assert.AreEqual(1.0, double.NaN, 1.0) pass? Whereas Assert.AreEqual(1.0, double.NaN) fails. Is it a bug in MSTest (Microsoft.VisualStudio.QualityTools.UnitTestFramework) or ...

Migrate from MSTest to XUnit

We are thinking about moving our tests from MSTest to XUnit. Is there any migration application that takes a MSTest and migrates it to XUnit? Also, if not, what should I look out for when doing this?...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

Repeat mstest test run multiple times

Some of my mstest unit tests help detect multi-threading race conditions, and as such they are most useful when run many times in a row, but I only want to do this for specific test runs -- not all ...

热门标签