【问题标题】:Running tests marked as [Explicit] with dotnet test使用 dotnet test 运行标记为 [Explicit] 的测试
【发布时间】:2020-07-14 08:15:23
【问题描述】:

是否可以使用 dotnet test 执行标有 NUnit [Explicit] 属性的测试?

我有一些测试希望在 Bamboo 上作为单独的构建运行。它们需要一段时间才能运行,因此不希望它们包含在 VS 中的标准测试运行中,因此用 [Explicit] 属性标记它们。我还用[Category("Nightly")]标记了它们,所以我希望Bamboo有一个步骤:

dotnet test --filter "TestCategory=Nightly"

但正如预期的那样,由于 Explicit 属性,它们仍然会被忽略。

我尝试过明确命名,如下所示:

dotnet test --filter "ClassName=MyTests.Tests.TestClassName"

但仍然没有运气,我已经尝试了 dotnet test https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests?pivots=mstest 的所有可能参数来专门引用测试,但它们仍然被忽略。

有人处理过这个吗?

丰富

【问题讨论】:

    标签: c# testing nunit


    【解决方案1】:

    根据this Github issue,这实际上是 NUnit3TestAdapter 的一个已知错误,其中标记为[Explicit] 的测试不会执行,无论它们在dotnet test 的参数中如何引用。这已在 nuget 包的 latest pre-release version 中得到解决。

    【讨论】:

      猜你喜欢
      • 2016-10-11
      • 2017-07-22
      • 2019-05-26
      • 2020-11-05
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 2017-04-11
      • 2022-11-21
      相关资源
      最近更新 更多