I am trying to use xUnit.net to test a project I wrote in Mono on OSX. I wannt good way to run the tests in MonoDevelop or at least a way to create a test suite and run these tests from a main method of the project. Has anyone tried doing this? I remember in NUnit I would be able to create test suites and run them myself but I am not able to figure out how to do the equivalent in xUnit.net.
Let me know if anyone has found a good way to run tests without using a runner in xUnit.net or a better way to run tests in OSX MonoDevelop.
You can run your tests using xunit gui (use mono xunit.gui.flavor from terminal) - I'm not aware of an xunit addin for MonoDevelop that could integrate an xunit test runner into the MonoDevelop IDE (another reference: http://xunit.codeplex.com/discussions/439410).
To debug your unit tests, you can attach the debugger to the xunit gui. To make this simpler, you can customize the projects run configuration: http://www.grumpydev.com/2011/06/30/debugging-xunit-tests-using-monodevelop/
It's a decision you have to make whether you want to jump through a few hoops to use xunit or just use NUnit that's integrated well with the platform.
Related
I'm trying to run unit tests from the command line.
For this, I need the test dlls, as per this:
https://msdn.microsoft.com/en-us/library/ms182490.aspx
In the Prerequisites section on that page, it says I need to "Run a Unit Test and Fix Your Code"
Question 1: Do I need to run tests from VS to be able to run them from command line? Surely not?
Now to the more important bit. When I build my solution, regardless of whether it's via VS or command line using MSBuild, I do not get any dlls generated for my tests.
I know this is for C++ but thought might still be relevant https://social.msdn.microsoft.com/Forums/vstudio/en-US/a89c2173-90e6-47b2-af8e-48865969cbca/msbuild15-does-not-create-a-dll-file-after-building-the-c-native-unit-test-project?forum=msbuild. (not that it helped of course).
Question 2: Why don't my unit test dlls get generated when building?
UWP is a bit different from other projects when it comes to Unit Testing. Universal Windows Apps run in a sandbox to make sure they don't do things they don't have permissions for. For this reason, the unit test project is not a simple DLL only, but in fact a full-fledged UWP app (and the generated executable has appx extension), that is launched and performs the tests.
That said, you can still launch the unit test project from the console using a special command as you can see in this SO answer.
vstest.console.exe /Platform:x64 AppPackages\UnitTestProject1_1.0.0.0_x64_Debug_Test\UnitTestProject1_1.0.0.0_x64_Debug.appx
I have a UWP project which fails to run unit tests via R#.
I know this was very cumbersome in the beginning of UWP, but I was able to get the unit tests going if I restarted Visual Studio a couple of times. A year later, and a major release further in VS2017 and R# I am still not able to run unit tests...
I'm using:
VS2017 Pro (15.4.3)
R# 2017.2.2 ultimate
UWP solution with target project Creators update (15063)
MS test project (15063)
When I open my solution, it doesn't matter which unit test I run, every test will be inconclusive.
Does anybody recognize these kind of issues and have a workaround for this? Any way to at least allow some kind of TDD way of working?
PS: Of course there isn't an actual stack-trace or inner exception in an output window which I can use for troubleshooting. It's just this pointless message without any useful suggestion how to move further
I have written UI test for xamarin mobile app in C# using the tool visual studio 2015, I just wanted to know whether I can run all the UI test methods in a single class. I have written all the test in different methods in different classes
In NUnit.Runners.2.6.x you can use -run=XXXX to specify which tests/fixtures/namespaces to run:
-run=STR Name of the test case(s), fixture(s) or namespace(s) to run
i.e.
packages/NUnit.Runners.2.6.4/tools/nunit-console.exe -run=Tests iOS_UITest.UITests/bin/Debug/Xamarin.UITest.dll
⚠️
Mono current ships with and older version of NUnit that does not support all of the NUnit features that UITests may rely on. You are strongly recommend to use the test runner from Nunit 2.6.3 or higher when running UITests at the command line. Note that Xamarin.UITest is not compatible with NUnit 3.0.
re: Running_UITests_Using_the_Command_Line
I need to organise the launch Unit-Tests in MS Test Manager. Can It be done? I create controller but I can't specify path for my solution or tests dll.
I'm not sure that launch Unit-Tests in Microsoft test manager are possible, but my boss requires it.
What you should probably do is setup your build server to run the tests. Then use test manager to trigger a build, which will in turn run the tests.
There's not much value in running the tests again on previously built code as it won't have changed. The tests should run on the code as it builds and then again when the code changes and is consequently rebuilt.
Is there a tool for automated test discovery for .NET. I am using the Visual Studio unit testing stuff and wanted functionality similar to Python Nose. I need to have a tool automatically discover all the unit test available and run for example the ones "marked" as unit and in different scenarios run the tests "marked" as Integration and so on. I have found an individual that has created his own implementation of the MSBuild test task and an considering creating my own with annotation attributes to do what Nose does but wanted to see if anyone was aware of an existing tool that could work.
Thanks
Visual Studio integrated test framework does exactly that when running from the IDE.
If you need a command line tool that does exactly the same functionality (finds all the tests in a specific directory/solution) I guess you have to write something.
Because MSTest command line needs at least the assembly to be specified. I suggest you write a short script that iterates all the assemblies and find if they have tests in them and then run each assembly using MSTest.exe
Update:
I've just published a new CodePlex project called #Nose that does exactly what you need. Currently it only supports NUnit but I plan on adding VSTest as well.
Try ReSharper from JetBrains. It does what you want with unit tests plus a whole lot more.