Can't run NUnit tests for x86 projects - testing

I can't run NUnit tests, after I changed the 'Platform target:' to x86.
I'm using a .NET Core 2.2 project in VisualStudio 2019 and I'm running my tests with ReSharper. The NUnit Version is 3.11.0.
The following example works for x64, but does not for x86:
[TestFixture]
public class Tests
{
[Test]
public void Test1()
{
Assert.Pass();
}
}
'Test1 Ignored: VsTest test-case is missing. Rebuild the project and try again.'
So it seems like that the test is no longer identified as a NUnit Test and that the IDE tries to interpret it as a mstest?
Rebuilding does not help.

Related

How to successfully run/debug NUnit + SpecFlow tests using Visual Studio Mac

I have a cross platform automation solution based on SpecFlow and NUnit 3.
This solution succeeds to run Web (Selenium) and Android (Xamarin.UITest) automated tests on Windows, unfortunately, it does not works on OS X in Visual Studio Mac.
When I use the command line NUnit console runner OR Rider (JetBrains IDE), tests seems to be working, but when I use VS Mac, it does not.
All my issues seems to be related to VS Mac, the first I had was because assemblies dynamically loaded by SpecFlow were not found.
Someone gave me a workaround on GitHub (TestRunnerSupportAssembly key to add in .csproj so that test runner can find assemblies).
And now that the assemblies are loaded, it is the App.config file which seems to be loaded but whose keys do not appear in AppSettings object.
Here is a part of the log I get from the IDE during test run :
Mono: Config attempting to parse: '/Users/.../Automation/AutomationMobile/bin/Debug/AutomationMobile.dll.config'.
I really think the issue is because of the test runner used by VS Mac, but I can't find how to configure it appropriately.
PS : I cannot migrate to .NET core, because few assemblies does not support it (Xamarin.UITest for instance).

Run xUnit test with MSBuild

I've created ASP.NET we app project and then I've created a test class - this class is part of the .NET core.
I need to run the test by the console but I can't use .net core. because the app has to be compiled, etc. with MSBuild, so I have been doing some research about how to run xUnit test inside MSBuild task.
I found this https://xunit.github.io/docs/running-tests-in-msbuild#options.
So I installed xunit.runner.msbuild.net452.dll but I cannot run the test.
error : System.InvalidOperationException: Unknown test framework: could not find xunit.dll (v1) or xunit.execution.*.dll .....
Is .NET framework is compatible with xUnit?

How to integrate NUnit Tests (written in C#) in TFS builds?

I've written tests using Selenium in NUnit Framework using C# language. I want to associate these tests as part of builds in the TFS. So whenever new build is generated. These tests would be able to run as part of builds and generate/email reports as well.
Recommend you to use the new build system vNext build. vNext builds are JSON based, and you can plugin tasks built in msbuild, powershell and varied other scripting languages.
About how to integrate NUnit Tests in TFS builds, this blog describes clearly how to do this: Running NUnit Tests in a TFS 2015 Build vNext
Simply summarized as follows:
Add Nuget Package for NUnit Test Adapter
Specify path of custom Test Adapter inside build definition
Copying adapters inside Visual Studio TestWindows folder
Specify Path to Custom Test Adapter with nunit packages
Some other tutorial for you reference:
xUnit or NUnit with Visual Studio Online Build
Running nUnit and Jasmine.JS unit tests in TFS/VSO vNext build

How to run xUnit 2.1.0-beta-* for DNX projects with ReSharper

How to run xUnit 2.1.0-beta-* for DNX projects with ReSharper?
When the ReSharper do find the tests, it fails on running them with System.IO.FileNotFoundException that indicates the unit test assembly is not found.
Due to my understanding, DNX projects do NOT generate assemblies in \bin folder when they are compiled with VisualStudio 2015. Is there a way to force DNX projects generate assemblies like the tranditional class libraries projects?
Any ideas?
DNX tests aren't currently supported by ReSharper or the xunit plugin. It's a whole new execution model, and hasn't yet been implemented for ReSharper. I'd expect to see support as DNX and asp.net stabilise and near release.
xUnit now supports DNX. Not sure if this will let you run the tests from ReSharper though.
Here are the instructions, taken from https://github.com/xunit/dnx.xunit :
This runner supports xUnit.net tests for DNX 4.5.1+, and DNX Core 5+ (this includes ASP.NET 5+).
Usage
To install this package, ensure your project.json contains the following lines:
{
"dependencies": {
"xunit": "2.1.0-*",
"xunit.runner.dnx": "2.1.0-*"
},
"commands": {
"test": "xunit.runner.dnx"
}
}
To run tests from the command line, use the following.
# Restore NuGet packages
dnu restore
# Run tests in current directory
dnx test
# Run tests if tests are not in the current directory
dnx -p path/to/project test

Can you execute concordion.net tests using TestDriven.Net or directly from Visual Studio?

Is it possible to run tests written in Concordion.Net using some form of Visual Studio addin? I am looking to start using Concordion.Net. However, I was used to running tests from Visual Studio directly through the Resharper plugin. Since Concordion.Net is a different concept, and uses HTML files to 'specify' the tests, one cannot use the Resharper plugin.
You can run them using the nUnit GUI, but it is a bit of a pain to use it and slow.
You can use TestDriven.NET (http://testdriven.net/) to execute Concordion.NET tests within Visual Studio. To run a test please use the "Run Test(s)" command of TestDriven.NET on your Concordion.NET fixture class (http://testdriven.net/quickstart.aspx).
Please, make sure that you have specified the [assembly: RequiredAddin("ConcordionNUnitAddin")] attribute in the AssemblyInfo.cs of your specification project as described in the how to "Run Concordion.NET Tests with NUnit" (http://concordion.org/dotnet/RunningTests.html).
When you run Concordion.NET tests with TestDriven.NET in Visual Studio, you should see an output similar to:
“------ Test started: Assembly: Concordion.Spec.dll ------
Processed specifications : C:\Users\myuser\AppData\Local\Temp\Concordion\Spec\Concordion\Command\AssertEquals\NonString\Boolean.html
1 passed, 0 failed, 0 skipped, took 0,67 seconds (NUnit 2.6.2).”
To be able to run Concordion.NET tests with TestDriven.NET you have to install the Concordion.NUnit.dll into the installation directory of TestDriven.NET (C:\Program Files (x86)\TestDriven.NET\NUnit\2.6\addins\Concordion.NUnit.dll).
Concordion.NET tests can be run with the help of NUnit (http://concordion.org/dotnet/RunningTests.html) based on the Concordion NUnit addin. When NUnit discovers a class containing Concordion.NET fixture code annotated with [ConcordionTest], the Concordion.NUnit addin loads the related HTML specification document and creates a test instance that is executed with the help of NUnit.
Unfortunatelly, ReSharper uses a different mechanism to find tests than NUnit(http://confluence.jetbrains.com/display/NETCOM/4.09+Test+Framework+Support+%28R8%29). Thus, it would be necessary to write a ReSharper plugin to recognize classes annotated with [ConcordionTest] and use the ReSharper NUnit support to execute them. NUnit 3.0 will probably comply with interfaces consumed by ReSharper.
On the other Hand, the current version of the NUnit Adapter for Visual Studio (http://nunit.org/index.php?p=vsTestAdapter&r=2.6.2) is not able to load NUnit addins appropriately. An update of NUnit is necessary, which is planned for NUnit 3.0 (https://github.com/nunit/nunit-vs-adapter/issues/9).
To run Concordion.NET tests in Visual Studio you can use TestDriven.NET as described above.