I'm attempting to run dotCover on an xunit unit test. No matter which test I attempt to cover, they all give me the same result:
Inconclusive: Test wasn't run
So no matter what, dotCover doesn't find the coverage for any of my tests.
I am using ReSharper's unit test runner, and I am able to run the unit tests within VS inside the Unit Test Sessions window, so all of my unit tests run successfully.
When I attempt to cover a unit test (I've tried using the icon to the left of the test, the test all button in the Unit Test Sessions window, and right-clicking a unit test and saying Cover Unit Tests from within the same window), I always get the same message: Inconclusive: Test wasn't run.
My setup:
Visual Studio 2010
ReSharper 7.1
dotCover 2.2
xunit 1.9.1.1600
I've also set up both (http://xunitcontrib.codeplex.com/)
xunitcontrib-resharper 0.7 (RS 7.1, 6.1.1)
xunitcontrib-dotcover 0.7 (dotCover 2.0 - 2.2)
so that I should be able to use the xunit test runner from within VS.
Any help in getting the code coverage to work would be greatly appreciated.
"Inconclusive Test" means that test execution was scheduled in task runner, but didn't get any response from it.
It can be a problem with xUnitContrib itself. Can I ask you for dotCover logs to check if dotCover was actually called from the UTR with xUnit plugin?
Related
I followed sonarqube doc on how to import a xunit test execution report. I don't have any errors and the script runs fine. However, I don't see any unit tests within sonarQube.
You're likely facing a regression. The workaround is
simply adding /d:sonar.cs.vscoveragexml.reportsPaths="**\*.coveragexml" into the Additional Settings of the SonarQube Scanner for MSBuild - Begin Analysis (new) task.
I recently installed Visual Studio 2013 and CodeLens is amazing! The problem that I find is that whenever I open a class file that has methods in it, it doesn't seem to find the Unit Tests associated to the method if it is not written in MSTest. Is there anything that I have to do so that it can find other Unit tests like MSpec?
Is it because Machine Specifications has a different approach when creating unit tests vs MSTest or other testing framework out there?
The tested by and test status indicators are powered by the test explorer.
So if your MSpec tests show up in the test explorer and are written in C# or VB, they should also show up in CodeLens.
(same answer as Visual Studio 2013 feature Code Lens with NUnit)
I just did it with NUnit on a clean machine by installing Nunit and the Nunit extension in extension manager. Here Main shows one reference and one passing test, and the test itself shows the checkmark after successfully running.
I did the same thing that John Gardner showed in his answer, except I split it into 2 projects (to mimic the set up that I was working with in my real solution). At first it didn't work even though I could see the tests in Test Explorer. After a bit of searching, I stumbled onto the right answer for my situation.
It turns out that you need to:
(1) Create a new Unit Test Project (not a class library)
(2) Add NUnit reference to the Unit Test project (I used NuGet) and have the NUnit Test Adapter installed in VS2013
(3) Move your tests to this new project
(4) Once you save and build, now you can go back to your production code and see the "x/y passing" message and see the unit tests in the Test Explorer window.
Most of us that have been using NUnit for a long time are used to creating class libraries for our code instead of Unit Test Projects. It would be nice if the CodeLens documentation actually directly covered this (the documentation states "Test status indicators appear automatically in test projects" which was my clue).
I'm trying to run MSpec tests in Visual Studio's test system using Gallio, but it appears to be ignoring the MSpec plugin from the IDE. What I did:
Installed Gallio
Added the MSpec NuGet package to my test project
Added the Gallio NuGet package to my test project
Copied the three files required for the MSpec Gallio integration to an "MSpec" folder in Gallio's installation directory
Wrote an MSpec test
Ran "All Tests in Solution" in the IDE
This yielded the following error
"No tests were run because no tests are loaded or the selected tests are disabled"
To check Gallio itself, I added a reference to MbUnit and created a simple MbUnit test. I also ran Gallio's other tools to check if the plugin was being picked up at all. I even restarted VS for good measure.
Results
Running the tests using Gallio.Echo or Gallio.Icarus successfully executes both MbUnit and MSpec tests, so the plugin is being picked up. Running the tests from Visual Studio runs the MbUnit test but not the MSpec test, so Gallio integration appears to be working (just not the MSpec plugin). Any thoughts?
Before anyone mentions it: yes, I'd rather be using ReSharper but licenses are not an option for my situation at the moment.
Update: The is now a project to integrate MSpec into VS2012's test system. It's available on the Visual Studio Gallery and the source is on GitHub.
After starting to debug the problem with both project's sources, it appears there are two underlying issues causing the incompatibility between MSpec and Gallio's VS runner. However, both issues stem from the fact that the VS runner uses Cecil to load type information from assemblies (presumably to avoid loading the test assembly into the main VS AppDomain).
I'll update this answer as I uncover more (hopefully resulting in one or more patch to fix the issues).
Issue 1: Nested types are ignored
I had been using nested types for my tests (SubjectSpec+when_something), which are ignored by the Cecil-based reflection used by Gallio's VS runner to avoid loading the test assembly into the app domain.
This ended up being a relatively simple fix, which I've submitted as a patch to the Gallio developers. I'll update this answer if/when I get confirmation of which release it will be part of.
Issue 2: MSpec causes "An exception occurred while invoking a test driver"
If the container type is removed to avoid issue 1, MSpec throws this error. The reason for this is that MSpec is trying to create an instance of the test object, but Gallio is only supplying it a wrapper Type object that can't actually be created.
I'm trying to find a way to migrate from mstest to xunit and still benefit from the IDE integration which made me choose mstest in the first place. Gallio seems to accomplish this noble goal, plus it's free (don't want Reshaper or TestDriven.net). But I can't get code coverage to work.
My solution contains of two projects: project SUT (the assembly I need to test) and project SUT.Tests which is a VS test project (this allows Gallio to display xunit tests in VS's Test View). I have code coverage enabled in Local.testSettings for SUT.dll and instrumentation is in place. After the test run completes there is no code coverage. Code Coverage Results window reports: Empty results generated: none of the instrumented binary was used. Look at test run details for any instrumentation problems. Unfortunately the test run details do not contain any "instrumentation problems". I tried unchecking the instrument assemblies in place checkbox and re-running the unit test; same result.
Any idea what's wrong?
My setup:
- Windows 7 x64
- VS 2010 Premium (SP1)
- xUnit 1.8
- Gallio 3.3.1 x64 (installer, not zip)
Apologies for answering my own question:
Turns out Gallio loads SUT.dll from SUT.Tests\Bin\Debug rather than SUT\Bin\Debug. I added this path to code coverage details, selected it instead of the default SUT.dll path and now it works! This is better described at here, towards the end of the post.
When I run my nunit tests using the test runner in resharper, I get an OutOfMemory exception.
It appears to me that as a test suite runs, it consumes memory over the duration of the suite, and only releases memory back when the entire set of tests is complete. So even if I run a collection of tests from across multiple assemblies, their collective memory footprint gets consumed, and only released at the end.
Is there a way to cause the test runner to release memory more frequently? We're talking about 755 tests which doesn't seem excessive. I think the problem is related to using Rhino.mocks and all of the mock repository allocations that are created in this collection of tests.
Note: Using Resharper 5.1, Rhino.Mocks, VS2010, and NUnit 2.4.8
Thanks,
John Schank
Not sure if you are using the NUnit test runner or the Resharper test runner, but if you are using the NUnit test runner see the below link and upgrade to 2.5 or use Resharper test runner.
http://sourceforge.net/tracker/index.php?func=detail&aid=1965952&group_id=10749&atid=110749