I am really frustrated with this issue. I have already tried changing the version numbers but no tests are showing in the test explorer.
In the test output window I can see this output
Starting Microsoft.Framework.TestHost [C:\Users\sul\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4\bin\dnx.exe --appbase "path to test project" Microsoft.Framework.ApplicationHost --port 63938 Microsoft.Framework.TestHost --port 63954 list ]
Unable to start Microsoft.Framework.TestHost
========== Discover test finished: 0 found (0:00:36.5471185) ==========
This is so fragile, sometimes tests are shown then they disappear for good. Restarting VS didn't help, reinstalling the xunit/xunit runner didn't help either.
In another test project I got a different output but still not tests are showing
Starting Microsoft.Framework.TestHost [C:\Users\sul\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4\bin\dnx.exe --appbase "path to project" Microsoft.Framework.ApplicationHost --port 63938 Microsoft.Framework.TestHost --port 64421 list ]
Connected to Microsoft.Framework.TestHost
Discovering tests in 'path to project\project.json'
========== Discover test finished: 0 found (0:00:35.9341416) ==========
This is part of my project.json
"commands": {
"test": "xunit.runner.dnx"
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Http.Core": "1.0.0-*",
"Microsoft.AspNet.TestHost": "1.0.0-*",
"Moq": "4.2.1502.911",
"xunit": "2.0.0",
"xunit.runners": "2.0.0"
To write a test you simply create a public method that returns nothing and then decorate it with the Fact attribute. Inside that method you can put whatever code you want but, typically, you'll create some object, do something with it and then check to see if you got the right result using a method on the Assert class.
It's an open source unit testing tool for . Net framework that's compatible with ReSharper, CodeRush, TestDriven.Net, and Xamarin. You can take advantage of xUnit.Net to assert an exception type easily.
When you have the ignore attribute above a testmethod the test will be skipped. Now when you run your tests you will see that this test has been skipped. Indicated by the yellow exclamation mark.
Sometimes, you want to write tests and ensure they run against several target application platforms. The xUnit.net test runner that we've been using supports . NET Core 1.0 or later, . NET 5.0 or later, and .
I've just had some issues with this when using TFS. Set it up and got it working on one machine, went onto another, Got latest code after checking in my changes, everything was showing correctly, but the test runner wasn't finding any tests at all. In the end a simple clean and rebuild on the Test project fixed it and it now finds tests.
This is my project.json
"dependencies": {
"Xunit": "2.1.0-beta2-*",
"Xunit.runner.dnx": "2.1.0-beta2-*"
},
"commands": {
"test": "xunit.runner.dnx"
},
Note the capital X in the Xunit listed in dependencies. The official documentation lists is as a lower case x, but this does not work. I've emailed the repo owner to make him aware of this.
EDIT: I've spoken to the author of XUnit who assures me the lower case x does work for him and others and that it's potentially a corrupted package cache.
I manage to get this to work by making sure that all the packages in all the solution projects reference the same version.
This happened to me because I was referencing the latest versions as you can see from project.json.
One other thing I did is never reference individual packages which fits the purpose only. For example in my business project I am creating a middleware and I was referencing Microsoft.AspNet.Http because I don't need the full MVC package. This caused issues in the test project so I added Microsoft.AspNet.MVC to any project that needs any sort of Http interaction i.e. httpcontext.
This may not be the ideal fix but it did work for me. I hope this helps someone else experiencing the same issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With