【问题标题】:Run all the tests but in the report only there are the methods that I want to run运行所有测试,但在报告中只有我想要运行的方法
【发布时间】:2017-06-01 10:44:09
【问题描述】:

我必须进行程序集,一个用于测试,另一个是具有我想要测试的方法的主程序集。

在我的测试程序集中我有很多类,每个类都测试主程序集类的方法。总的来说,在所有类中,我有大约 300 个测试方法,但在 MyClass01Test 中我只有 30 个测试方法。我只想运行这个类中的方法,而不是所有的测试。

我正在尝试使用此过滤器:

"-filter:+[*]*.MyMainClass -[*Tests]*"

问题在于它运行所有测试,而不仅仅是我的测试程序集中的 MyMainClassTest 类中的测试。但是,在我使用reportgenerator 获得的报告中,我只从MyClass01 中获得了正确的方法。

我使用的完整命令是这样的:

"D:\programas\OpenCover\OpenCover.Console.exe" -register:user "-filter:+[*]*.MyMainClass01 -[*Tests]*" -target:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe" -targetargs:"/testcontainer:\"F:\.MyAssmeblyTests.dll\"" -output:"F:\tests\resutlts.xml"

【问题讨论】:

    标签: mstest opencover reportgenerator


    【解决方案1】:

    您必须告诉 MSTest 它应该执行哪些测试。 这与 OpenCover 和 ReportGenerator 无关。他们只跟踪执行情况并创建报告。

    您可以在此处找到 MSTest 的相关参数: https://msdn.microsoft.com/en-US/library/ms182489.aspx

    【讨论】:

    • 您可能还想在 mstest 中使用/noisolation 开关。
    猜你喜欢
    • 1970-01-01
    • 2014-05-31
    • 2018-07-08
    • 2015-01-01
    • 1970-01-01
    • 2022-12-10
    • 1970-01-01
    • 1970-01-01
    • 2015-02-19
    相关资源
    最近更新 更多