Running F# xUnit Fact from TestDriven.NET reporting “It looks like you're trying to execute an xUnit.net unit test.”

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 01:29:44

问题


I am trying to run xUnit tests (from an F# module, if it makes any difference) using TestDriven.NET, but whatever I do I get this error:

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

I tried following the suggestions, i.e. I copied the files

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

to the folder with xunit.dll and I ran xunit.installer.exe. How can I get it to work?


回答1:


I just figured out that I forgot to make the test a function in F# (so it was just a value). The error message can't be more misleading though!




回答2:


You have two problems:

  1. your Fact is broken:-

    If you hover over the

    please work

    bit, you'll see something like: unit -> int

    For a Fact to be picked up by an xUnit runner, it needs to yield `unit (void).

    Hence, one key thing to get right first is to not return anything. In other words, replace your 123 with () (or an Assertion).

    You can guard against this by putting a :unit stipulation on the test:-

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

    This will force a compilation error.

  2. TestDriven.NET is reporting it cannot find the xunit.tdnet modules

    It's critical to get step 1 right first. Then retry and the problem should be gone

    If it remains...

    Either try the VS-based runner which should work as long as it's installed and xunit.dll is getting to your output dir or look at the docs for your version of TD.NET for detailed troubleshooting notes (exec summary is if the .tdnet file was in your out dir or you undo and redo the xunit.installer from the folder containing the packages it should just work, esp if you are on latest)



来源:https://stackoverflow.com/questions/11030404/running-f-xunit-fact-from-testdriven-net-reporting-it-looks-like-youre-trying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!