I am currently trying to use TestDriven.Net with MSpec. I installed TestDriven.Net and then imported MSpec from Nuget into my class library. When I try to run my tests I get the following output.
The target type doesn't contain tests from a known test framework or a
'Main' method.
I have also copied the Machine.Specifications.dll.tdnet and Machine.Specifications.TDNetRunner.dll in the Debug folder of my solution where all the dlls are deployed but still I see no change.
Am I missing something?
Try running the TestDriven.Net batch file installer first. It's shipped with the Nuget package. You can find it under
\packages\Machine.Specifications.0.8.3\tools\InstallTDNetRunner.bat
Related
The setup is like this:
A Xamarin.Android application, which depends on Android class library
(at least that's what the template is called in VS)
Said class
library, the purpose of which (not entirely relevant, but FYI) is
interfacing with a REST service and has a dependance on the famous
Newtonsoft.Json NuGet package.
An NUnit test project for said
library.
IDE is Visual Studio 2017, latest version.
If you build and deploy the app on the phone, everything is fine.
However, if you try to run tests from the tests project, it says that it can't find the Newtonsoft library.
I've even managed to find a sort of reason: when the library gets built, it's dependancies aren't packed inside, and they are not copied to build directory.
When .apk is built for the phone, the dependancies ARE getting packed inside.
However, when NUnit project builds itself, it only takes the library, and the dependancies are nowhere to be found.
However, there's no interface to control the behaviour of NuGet "Package Reference" type dependencies (blue ones), the properties window is empty for them. And I found no way to add NuGet packages to this kind of project as a ".config" type of dependancy (grey one).
There is a workaround - you can add the Newtonsoft package to the NUnit test project, then it gets copied to the build directory and the Android library works with it, however it doesn't feel right to me. Tests don't need that reference and it has no business in that project.
How to control NuGet packages in Android Class Library?
Your workaround is the correct solution, you don't need to worry too much about it.
That is because the Newtonsoft package is not used directly in your NUnit test project, so Visual Studio / MSBuild doesn't know if your test project needs this Newtonsoft library. In order to avoid reference pollution in NUnit test project, Visual Studio / MSBuild tries to only bring references over into NUnit test project that it detects as being required by project Xamarin.Android application.
So, to resolve this issue, we often add Newtonsoft to the test project or give a copy task to copy it to the test project.
See This Thread for some more details.
Looking for an answer to another question I now found info that my described behaviour is a known problem, described by .NET developers here:
https://github.com/dotnet/standard/issues/481
I am using .NET framework 4.5 and C# for my project and i used mstest for Test project. All unit test cases ran fine on Visual Studio 2017 enterprise edition, but when I created Jenkins for the Unit test, some of tests are executed and in middle the build fails saying:
No test is available in
\PKGS\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.
Make sure that test discoverer & executors are registered and platform
& framework version settings are appropriate and try again
Additionally, path to test adapters can be specified using
/TestAdapterPath command. Example
/TestAdapterPath:. vstest.console.exe
F:\jnks\workspace\mPrint_Roam_Horizon_Inc\PKGS\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
/InIsolation /EnableCodeCoverage
The error says that the file Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll does not contain any tests (which is correct, because it is a frameworkfile). You probably have some errors in the path where you are looking for dll's with tests in them.
In my VS2017 solution I have several unit test projects.
In on of them my xUnit tests do not get discovered by mstest and therefore are not run.
I do get the warning:
Warning: [xUnit.net 00:00:00.7641189] Skipping: Testing.UnitTests (could not find dependent assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0')
But Microsoft.VisualStudio.QualityTools.UnitTestFramework is referenced in the project in exactly that version.
I have multiple unit testing projects. Many of them contain xUnit tests as well, but they get found and executed without any problems.
All projects containing xUnit tests have the same xUnit nuget packages assigned, especially xunit.runner.visualstudio
I am also using NCrunch and NCrunch has no problem discovering and execution the xUnit tests in question.
What could possibly be the reason to my problems?
Further Findings:
After upgrading Microsoft.VisualStudio.QualityTools.UnitTestingFramework to version 10.1.0.0, the xUnit tests were found but then I suddenly had 438 from 2447 failing. Those failing tests -mostly not xUnit - were previously working fine.
After shutting down an restarting visual studio the UnitTeestingFramework was automatically reset to version 10.0.0
opening the Reference Manager (Add References) all the project references are shown by selected checkboxes except of Microsoft.VisualStudio.QualityTools.UnitTestingFramework which only shows up if I previously add e.g. "Quality" to the search box, but then I see Microsoft.VisualStudio.QualityTools.UnitTestingFramework three times. One checked (version 10.0.0.0) an other one with same version, but different path and one with version 10.1.0.0
All together looks quite odd to me...
I had this issue but am not sure if this is exactly the same as yours. I saw an error in the output/tests window which stated it couldn't restore package xunit.runner.utility 2.2.0
After manually adding this in in package manager console like so:
install-package xunit.runner.utility -v 2.2.0
It started working again
I'm trying to use xbuild from mono to compile my C# web application. I keep running into this error:
Field 'System.Text.RegularExpressions.Regex.IsMatch' not found.
The only thing that I've been able to find about this error is to add 'System' as an assembly reference in the csproj file which I already had there. I also tried installing the 'System.Text.RegularExpressions' NuGet package and putting an assembly reference of 'System.Text.RegularExpressions' in the csproj file. Neither of those worked.
One thing I should note here. This error only gets thrown in my test library. I can build everything else fine without the tests but I need to be able to build the tests as I'm trying to set up CI that runs the tests. The tests are using NUnit.
Here's the data for what I'm using:
XBuild Engine Version 14.0
Mono, Version 4.8.0.0
C# 6
.NET Framework 4.5.2 (but have tried building with 4.5.0, 4.0.0, and 4.3.0)
I figured out what this problem was. We were using Selenium for UI tests and the drivers for that were preventing the build from completing for some reason. As far as what part in Selenium was causing this, I'm not sure.
I'm attempting to write tests with NUnit3 as part of some tech-debt migrations. I created a new project within an existing solution. Using nuget I added NUnit and NUnit.Console as per the instructions on github. (I also added the NUnit 3 Test Adapter extension to Visual Studio 2015, but I'm fairly sure that has no bearing on my current situation).
After adding the nuget packages I attempted to import the TestFixture attribute, however, visual studio isn't recognizing the NUnit.Framework namespace and I can't import anything.
The only thing I could thing to fix it was to add the reference manually. There too I was blocked by NUnit not being available.
I'm somewhat at a loss as to how to move forward. How do I proceed and fix the missing reference?
Update: The project I created was of type Unit Test Project, however I've gone ahead and create a Console Application and Class Library. I attempted to add NUnit via nuget to each of them and all of them have had the same result.
Update: Other nuget dependencies seem to install correctly with no discernable difference.
This is only a pseudo solution, as I don't know what the actual issue is. If anyone else comes across a better fix than my work-around I'll be glad to select it if it works for me down the line.
At the time of this writing, the latest version is 3.4.1. I forced nuget to downgrade to 3.4.0 for both the packages NUnit and NUnit.Console and violĂ the namespace is available as you'd expect any nuget package.