What happens if I specify a timeout value in nunit-console, but a smaller MaxTime in a specific test?

huangapple go评论39阅读模式
英文:

What happens if I specify a timeout value in nunit-console, but a smaller MaxTime in a specific test?

问题

如果在nunit控制台命令行中指定了--timeout,并且在特定测试中指定了较小的MaxTime,会发生什么情况?

例如,在nunit控制台中,我的超时值为600000毫秒(即:600秒),但在一个测试用例中,我的MaxTime为20000(即:20秒),会发生什么?

我猜想:

  1. 如果测试执行时间少于20秒,则测试通过。
  2. 如果测试执行时间介于20秒和600秒之间,则测试可以完成(即:不会中止),但会标记为失败。
  3. 如果测试执行时间超过600秒,则测试将被中止,并标记为失败。

我的理解是否正确?

英文:

What happens if I specify --timeout in nunit console command line, and at a specific test, I specify a smaller MaxTime?

For example, in nunit console my timeout value is 600000 ms ( ie: 600 seconds), but in a test case, my MaxTime is 20000 ( ie: 20 seconds), what will happen?

My guess is that

  1. If the test is taking less than 20 seconds to run, then it passes
  2. If the test takes between 20 and 600 seconds to run, then the test can complete ( ie: no aborting), but will be marked with a failure.
  3. If the test takes more than 600 seconds to run, then the test will be aborted, and it will be marked with a failure.

Is my understanding correct?

答案1

得分: 1

我认为您混淆了两个不同的 NUnit 属性:

如果一个测试有 TimeoutAttribute,当超过该超时时间时,它将被取消。在 NUnit 中,取消被视为一个错误,而不是一个失败,也就是说,测试出了问题,而不是被测试系统出了问题。然而,大多数人倾向于将错误和失败视为相同的情况... 即测试没有通过。

超时值,可以作为控制台运行程序的参数指定,可能应该被称为 "defaultTimeout",因为这就是它的含义。当您指定该参数时,所有没有自己的 TimeoutAttribute 的测试都被视为具有该默认值的属性。无论值是较大还是较小,都没有这两个值之间的时间处理特殊情况。

NUnit 还有一个 MaxTimeAttribute,它根本不会取消测试。相反,它只是跟踪运行测试所使用的时间长度。如果测试本来应该通过,但超过了指定的最大时间,那么它会被标记为失败。

英文:

I think you are mixing two different NUnit attribtues:

If a test has a TimeoutAttribute, it will be cancelled when that timeout is exceeded. Cancellation is treated by NUnit as an error, rather than a failure, that is, there is something wrong with the test rather than the system under test. Most folks, however, tend to look at errors and failures as being the same... i.e. the test didn't pass.

The timeout value, which may be specified as an argument to the console runner, should probably have been called "defaultTimeout", since that's what it is. When you specify that argument, all tests without their own TimeoutAttribute are treated as if they had an attribute with that default value. It doesn't matter whether the value is larger or smaller and there is no special treatment of timings between the two values.

NUnit also has a MaxTimeAttribute, which doesn't cancel tests at all. Rather, it simply tracks the length of time used to run the test. If the test would otherwise have passed but exceeded the max time specified, it is marked as a failure.

huangapple
  • 本文由 发表于 2023年6月1日 15:26:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76379571.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定