简体   繁体   English

net core 7,do.net 测试:一次测试失败后继续

[英]net core 7, dotnet test : continue after one test failed

I am using .net core 7.我正在使用 .net 核心 7。

From command line, do.net test (I am using nunit) stops when a test failed.从命令行,do.net 测试(我正在使用 nunit)在测试失败时停止。

Is there a way to NOT stop and continue with following tests?有没有办法不停止并继续进行以下测试?

Thx !谢谢 !

Could you please provide some code to better illustrate your issue?您能否提供一些代码以更好地说明您的问题?

Typically do.net test runs all tests and provides a report on which pass and which fail.通常do.net test运行所有测试并提供关于哪些通过和哪些失败的报告。

For example, on this minimal reproduction:例如,在这个最小复制中:

public class Tests
{
    [Test]
    public void FailingTest1()
    {
        Assert.Fail();
    }

    [Test]
    public void PassingTest()
    {
        Assert.Pass();
    }

    [Test]
    public void FailingTest2()
    {
        Assert.Fail();
    }
}

When I run do.net test , I see:当我运行do.net test时,我看到:

PS C:\Users\SeanK\Repositories\2023_01_NunitRepro> dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  Repro -> C:\Users\SeanK\Repositories\2023_01_NunitRepro\Repro\bin\Debug\net7.0\Repro.dll
Test run for C:\Users\SeanK\Repositories\2023_01_NunitRepro\Repro\bin\Debug\net7.0\Repro.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
  Failed FailingTest1 [27 ms]
  Stack Trace:
     at Repro.Tests.FailingTest1() in C:\Users\SeanK\Repositories\2023_01_NunitRepro\Repro\UnitTest1.cs:line 8

1)    at Repro.Tests.FailingTest1() in C:\Users\SeanK\Repositories\2023_01_NunitRepro\Repro\UnitTest1.cs:line 8


  Failed FailingTest2 [< 1 ms]
  Stack Trace:
     at Repro.Tests.FailingTest2() in C:\Users\SeanK\Repositories\2023_01_NunitRepro\Repro\UnitTest1.cs:line 20

1)    at Repro.Tests.FailingTest2() in C:\Users\SeanK\Repositories\2023_01_NunitRepro\Repro\UnitTest1.cs:line 20



Failed!  - Failed:     2, Passed:     1, Skipped:     0, Total:     3, Duration: 30 ms - Repro.dll (net7.0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM