从TestDriven.NET运行F#xUnit事实报告“看起来你正在尝试执行xUnit.net单元测试。”

时间:2012-06-14 09:38:07

标签: f# testdriven.net xunit.net

我正在尝试使用TestDriven.NET运行xUnit测试(来自F#模块,如果它有任何区别),但无论我做什么,我都会收到此错误:

It looks like you're trying to execute an xUnit.net unit test.

For xUnit 1.5 or above (recommended):
Please ensure that the directory containing your 'xunit.dll' reference also contains xUnit's
test runner files ('xunit.dll.tdnet', 'xunit.runner.tdnet.dll' etc.)

For earlier versions:
You need to install support for TestDriven.Net using xUnit's 'xunit.installer.exe' application.

You can find xUnit.net downloads and support here:
http://www.codeplex.com/xunit

我尝试了这些建议,即我复制了文件

xunit.dll.tdnet
xunit.extensions.dll
xunit.gui.clr4.exe
xunit.runner.tdnet.dll
xunit.runner.utility.dll
xunit.runner.utility.xml
xunit.xml

到xunit.dll的文件夹,然后我运行了xunit.installer.exe。我怎样才能让它发挥作用?

2 个答案:

答案 0 :(得分:3)

我只是想通了我忘了让测试成为F#中的一个函数(所以它只是一个值)。错误信息不能更具误导性!

答案 1 :(得分:1)

你有两个问题:

  1. 您的事实已经破裂: -

    如果将鼠标悬停在

    please work

    位,您会看到类似:unit -> int

    的内容

    对于xUnit运行器选择的Fact,它需要产生`unit(void)。

    因此,首先要做的一件事就是不要退货。换句话说,请将123替换为()(或断言)。

    您可以通过在测试中加上:unit规定来防范这种情况: -

    [<Fact>]
    let ``please work`` () : unit = 123
    

    这将强制编译错误。

  2. TestDriven.NET 报告找不到xunit.tdnet模块

    首先获得第1步是至关重要的。然后重试并且问题应该消失

    如果它仍然存在......

    尝试基于VS的运行程序,只要它已安装并且xunit.dll到达您的输出目录,或者查看您的TD.NET版本的文档以获取详细的故障排除说明(exec摘要,如果.tdnet文件在你的目录中,或者从包含它应该正常工作的包的文件夹中撤消并重做xunit.installer,尤其是如果你最近的话)