I want to use a Xamarin.iOS Library Project:
And within this project I want to add unit tests (currently with nunit, but xunit would be fine, too).
I do not want to run them on the device/simulator (which is possible with the "Unit Test App" project template). I want those tests to be executed by the native test runner within XS.
Is there any hack known to get this to work?
(Actually those tests run just fine with nunit in Visual Studio, when the Xamarin.iOS reference is copied locally on every build, but on Mono/XS it doesn't seem to work.)
Related
locally tests and works. but it does not see the tfs te on the server and it does not work.
I can not see the xUnit test in Tfs and I can not work with it.
TFS version 2017
--- Solition----
For normal project, you could directly use Visual Studio Test task in the build pipeline.
You could try to explicitly specific the path to the xunit runner. Such as
$(System.DefaultWorkingDirectory)\packages\xunit.runner.visualstudio.2.2.0\build\_common)
And Szeki's comment is right, xUnit test runner can only be run in an assembly targeting .NET 4.5.2 or above, otherwise it cannot be loaded (and thus the tests will not be found). Take a look at this question: Running xunit.net tests in VSTS
If you are working with .net core project, you should use .net core command line to run the test instead of VStest. Details info please refer below blog:
Publish Core XUnit Test Results in VSTS
VSTS Configuration to run xUnit tests for x64 platform
I have a C# project in Xamarin for which I've written a few NUnit unit tests. To alert me to regressions as soon as possible I'd like to have Xamarin run my unit tests after every build. I'm not using CI or a build server, everything is local to my dev machine. Is there a way to modify the build task to run my tests after each compilation?
You can write a simple build script in which you invoke nunit-console.exe after your msbuild of your respective Xamarin projects.
Otherwise, I would personally recommend using Cake Build as it's fairly simple to get up and running and provides NUnit runners:
https://github.com/cake-build/cake (http://cakebuild.net/)
https://github.com/Redth/Cake.Xamarin (Xamarin Addin)
Both of these solutions should work fine locally.
Taking elements from #JonDouglas' suggestion I ended up finding the Custom Commands section and making an After Build with nunit-console ${TargetFile}. It's in the Options dialog here:
This problem is only when I right-click on exact test, and call Run Tests.
When I build projects, including project with tests, VS build only dependencies.
Is this normal?
I've setup my build as below using the build definition. I'm using XUnit and locally my tests are discovered and run. I've tested the glob **\*spec*.dll and it finds all my test dlls and the build log shows that those dlls are in fact built.
However in the build log I get
Run VS Test Runner
No test found. Make sure that installed test
discoverers & executors, platform & framework
version settings are appropriate and try again.
Which seems to suggest it is trying to use the MSTest test runner instead of the XUnit test runner. How do I tell the build for visual studio online to use the XUnit test runner and discoverer?
This might be out of date now, but this is how I have it setup and working - downvote and let me know if it's wrong and I'll delete this. I got it from a blog post/MSDN page, but I can't locate it any more.
First you need to create a TFVC Team Project (doesn't matter if you don't use it again).
Into $/MyTFVC/BuildProcessTemplate/CustomActivities/
Checking the following files from xunit.net:
Now in VS, click the BUILD, Manage Build Controllers... option. Select the "Hosted Build Controller (Hosted)" and click "Properties...".
Enter the path where you checked in the DLL's into the "Version control path to custom assemblies" field:
You should be good to go.
I have a set of Google Test-based unit tests for a native C++ DLL I'm developing. The DLL is in its own project, and the test project is dependent upon it. The test project has a Post-Build Event script that runs the tests.
My problem: Whenever the test project gets rebuilt, it runs the tests as expected. However, making a change to the dependent DLL does not always cause the test project to be rebuilt. Specifically, it seems that if none of the DLL's header files change, Visual Studio decides that the test project doesn't need to be rebuilt.
Is there any way to force Visual Studio to rebuild the test project, or to run the post-build event, whenever the DLL gets rebuilt?
I can force the tests to be re-run by right-clicking one of the files in the test project and choosing the Compile menu item, then doing a build. I'd prefer to eliminate that manual-and-often-forgotten step.
I suspect I could get the result I want if I were to include the DLL project's source files in my test project, but I'd really like to run the tests against the actual DLL.
Related but unhelpful question: How to setup Google C++ Testing Framework (gtest) on Visual Studio 2005