gpt4 book ai didi

unit-testing - NUnit 没有运行我的测试用例

转载 作者:行者123 更新时间:2023-12-04 04:23:25 25 4
gpt4 key购买 nike

我有一个测试用例,看起来像:

namespace UnitTests

[<TestFixture>]
module ValidatorTests =

[<Test>]
let VerifyBasicFunctionality () =
Assert.That(bool)
Assert.That(bool)

当我尝试在 Visual Stuido 测试资源管理器中运行它时,没有任何 react (即使使用 NUnit 3 的测试适配器),只是说“成功构建”并且没有发现任何测试。然后,当我使用 nunit-console runner 从命令行运行(尝试使用 v.1、v.2、v.4)时,我得到了一些不同的东西:
$ nunit-console4 bin/Release/UnitTests.dll
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
OS Version: Unix 15.6.0.0
CLR Version: 4.0.30319.42000 ( 4.4.2 (Stable 4.4.2.11/f72fe45 Thu Aug 11 06:03:25 BST 2016) )

.N.N.N
Tests run: 0, Failures: 0, Not run: 3, Time: 0.011 seconds

当我使用 -xmlConsole 运行它时标志,我明白了:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="bin/Release/UnitTests.dll" total="0" failures="0" not-run="3" date="2016-09-08" time="10:26:00">
<environment nunit-version="2.4.8.0" clr-version="4.0.30319.42000" os-version="Unix 15.6.0.0" platform="Unix" cwd="/SOMEUSER/SOMEPATH/UnitTests" machine-name="gmaini-m.jet.local" user="SOMEUSER" user-domain="SOMELOCALBOX" />
<culture-info current-culture="en-US" current-uiculture="en-US" />
<test-suite name="bin/Release/UnitTests.dll" success="True" time="0.010" asserts="0">
<results>
<test-suite name="UnitTests" success="True" time="0.008" asserts="0">
<results>
<test-suite name="ValidatorTests" success="True" time="0.001" asserts="0">
<results>
<test-case name="UnitTests.ValidatorTests.VerifyBasicFunctionality" executed="False">
<reason>
<message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
</reason>
</test-case>
<test-case name="UnitTests.ValidatorTests.VerifyBasicOtherFunctionality" executed="False">
<reason>
<message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
</reason>
</test-case>
<test-case name="UnitTests.ValidatorTests.VerifyBasicSomeFunctionality" executed="False">
<reason>
<message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
</reason>
</test-case>
</results>
</test-suite>
</results>
</test-suite>
</results>


知道为什么它似乎发现了这些测试,我可以通过 -run="Namespace.Module.Function" 访问它们。并与 -fixture="Namespace" 谈论夹具但它不会运行它们?是 UnitTests.ValidatorTests.VerifyBasicFunctionality is an abstract class暗示存在一些 C# 互操作问题?

谢谢你的时间 :)

最佳答案

这个修复是:

namespace UnitTests

[<TestFixtureAttribute>]
type ValidatorTests () =

[<Test>]
member __.VerifyBasicFunctionality() =
Assert.That(bool)
Assert.That(bool)

基本上,使这个面向对象。所以我的假设是正确的。

关于unit-testing - NUnit 没有运行我的测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39394442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com