OpenCover not finding solution modules - nunit

I'm trying to use OpenCover to produce some code coverage reports for my solution. I've got it running with assistance from this blog post http://www.allenconway.net/2015/06/using-opencover-and-reportgenerator-to.html, but it's currently not identifying and loading the modules which I want to report on.
Here is what I'm executing:
"%~dp0..\packages\OpenCover.4.7.922\tools\OpenCover.Console.exe" ^
-register:user ^
-target:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\mstest.exe" ^
-targetargs:"/testcontainer:\"%~dp0..\My.Project_Tests\bin\Debug\My.Project_Tests.dll\" /resultsfile:\"%~dp0My.Project.trx\"" ^
-filter:"+[My.Project*]* -[My.Project_Tests]*" ^
-mergebyhash ^
-skipautoprops ^
-output:"%~dp0\GeneratedReports\WebsiteReport.xml"
The output I get:
No tests to execute.
Committing...
No results, this could be for a number of reasons. The most common reasons are:
1) missing PDBs for the assemblies that match the filter please review the
output file and refer to the Usage guide (Usage.rtf) about filters.
2) the profiler may not be registered correctly, please refer to the Usage
guide and the -register switch.
I've tried changing the filter to include everything:
-filter:"+[*]*"
This finds and reports on code coverage within the test project, but doesn't manage to identify or report on coverage in any of the referenced projects which I actually want to test (My.Project).
The projects are all being built and .pdb files are present in the bin folder of the test project.
I would like code coverage reports from all projects referenced by my test project. Does anyone have any idea what's going wrong?

Turns out that I'm an idiot and was running MSTest when I should have been running NUnit console since our tests are all using NUnit.
Posting this just in case it helps someone else out.

Related

Need help on publishing xml report with the plugin parasoft findings in TeamCity

I added a build step for my project in teamcity which consists on using the plugin Parasoft Findings to publish an XML report of all the code violations. the problem is that teamcity is failing to parse XML report. It says there is an unexpected report format and to see log (which I couldn't find).
I already checked the report location pattern which is right. I don't use SOAtest but C++ test so I only put "Parasof analyzers 10.x" for the report type
I'm sorry but you did not provide any additional details regarding your question and it's hard to help you.
Please, provide:
error message
your configuration of build step and version of TeamCity and C++test
command line used to start C++test ( if you are using variables,
replace variables with real values used in your run)
By log I think, you should check your build step log, and provide us the right content.
You can find such logs on two different ways:
You can download it by clicking "Download full build log" on build
log page (Recommended).
Try to find the raw output from the build agent by looking in the
agents logs directory, for example in
c:\TeamCity_dir_agent\logs\teamcity-build.log
Following article from JetBrains' TeamCity manual might good point to start
Edit:
Parasoft updated the plugin which fixed the issue:
https://plugins.jetbrains.com/plugin/9949-parasoft-findings
I have the same issue. Error messages in build log:
Unexpected report format: <path-to>\report.xml. See log for details.
Failed to parse XML report
Failed to parse XML report
Step test results (Parasoft Findings) failed
teamcity-agent.log and teamcity-build.log are having no entries within this build step because there is no piece of code which would write that into during this error case.
Edit/Workaround:
In the report the node <ExecutedTestsDetails> must be below the node <Exec>. The node still has the right indendation but it is at the same level as <Exec>. The xsl of TeamCity Plugin works perfectly if you fix the report xml manually.
To make it work you can add the Build Feature "File Content Replacer" like that:
Regex: (?s)(<ExecutedTestsDetails.*?<\/ExecutedTestsDetails>).*?(<Exec.*?>)
Replace with: $2 $1

Play Framework code coverage in Intellij IDEA 14

I've created a simple Play 2.x application in Intellij IDEA 14.1.4 and decided to run tests with code coverage. Here's what I get to choose:
I've tried both options and when I actually run tests with code coverage, I get the following error:
With the first option:
With the second one:
The code of the test was generated by IDEA and I don't think it matters.
As I've found out, the problem might be with my user name, since it contains Russian symbols. The usual test run works perfectly and it only fails when I try to run with code coverage, which proves the username theory.
"C:\Program Files\Java\jdk1.8.0_45\bin\java" -ea "-javaagent:C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.4\plugins\coverage\lib\coverage-agent.jar=C:\Users\пс\AppData\Local\Temp\coverage0args"
C:\Users\пс\
However, I was unable to find the solution since I simply don't know what to look for.

NetBeans 8.0.2, PHPUnit skeleton genertor 2.0.1 - phpunit tests were not generated for the following files

I'm trying to get a PHPUnit test generated via the NetBeans IDE. WHen I initiate the creation of a test, the output window shows:
"C:\xampp\php\pear\PHPUnit\phpunit-skelgen.bat" "--ansi" "generate-test" "PrintuiInterface" "C:\xampp\htdocs\unified\components\com_printui\interface\printui_interface.php" "PrintuiInterfaceTest" "C:\unittests\components\com_printui\interface\printui_interfaceTest.php"
phpunit-skelgen 2.0.1 by Sebastian Bergmann.
Done.
It seems successful but I also get a popup that states "Tests were not generated for the following files: printui_interface.php Review the log in Output window"
I've tried moving the 'unittests' directory to several different places, thinking it may be a permissions issue. I seem to get the same results no matter where I put the 'unittests' directory.
There are no errors in the PHP error log.
Any thoughts on how I can determine what is wrong would be greatly appreciated.
Best regards.

Test projects not reading app.config in TeamCity -> NUnit phase

Well we are facing a strange problem with JetBrains TeamCity induced unit tests on our main project where tests from few library projects are failing regularly. Apparently, it's not reading the config file (coming from app.config and nicely stored in project -> bin -> debug -> projectName.dll.config).
Hints or tips on what could be the real issue would be highly appreciated.
I've got the same problem and wasted a couple of hours to figure out what the problem is.
In our case, the NUnit plugin was configured to run the tests from:
**\*Tests.dll
Though this sounds to be OK, it has turned out that this pattern will not only match to the MyTests.dll in the bin\Debug folder but also to the obj\Debug\MyTests.dll. The obj folder is used internally for the compilation and does not contain the config file.
Finally the solution was to change the plugin configuration to
**\bin\Debug\*Tests.dll
Actually we use a system variable for the build configuration so we did not have the "Debug" hard-coded. Using bin* might be also dangerous when the workspace is also used for Debug/Release builds and you don't have a full cleanup specified.
You might wonder why I did not realize the test count mismatch (actually it was doubled, because they were running once from bin and once from obj), but this is typical: while everything is green, you don't care about the count. When we have introduced the first test depending on the config, we had only one failure (because the one from bin was passing), so the duplication was not outstanding.
In addition to Gaspar Nagy's accepted answer, check to see if your project has multiple test dlls and one of them is referencing another.
This causes the referenced dll to be run twice, and the copy that was in the other dll's folder to not have the proper app.config entries. The proper fix is to remove any and all references from the other test project.
TeamCity (v6.5.4) has its own NUnit Test Runner and there seems to be an inconsistency between it and the NUnit GUI test runner (2.5.10). The NUnit GUI Test Runner follows the long standing convention of expecting the configuration file name to be of the format .config. You can see this in NUnit by looking at Project -> Edit...
TeamCity on the other hand is looking for an app.config.
Your options are to either:
Set the NUnit GUI to point to app.config and include the resultant
nunit project in your source control.
Have both an app.config and a .config - syncing both
manualy.
Add a step to your build process to copy .config to
app.config (or vice versa).
I had similar woes
This may help; additionally we had issues where this still would not work - we ended up copying the relevant config sections into the highest level config file. (i.e. if it was a web app copy it into the Web.Config) - fairly kludgy but we had wasted a few days on the issue
I learned recently that app.config files are not read for a class library... Maybe this link could help :)
app.config for a class library
If you need a config file for your "unit" tests then you are doing it wrong. Proper unit testing never needs configuration or access to the database, file system etc. You should change your testing strategy.
Good point to start is mark your tests that need configuration with the[Category("Integration")] annotation and set the Teamcity test runner to ignore this category. Then you should focus on refactoring these test.

Problem Publishing NUnit Testing Result Reports with Hudson

I am facing a problem with Hudson and NUnit testing. When trying to publish the Test Result Report for NUnit, the option in Hudson, i.e., "Publish NUnit Test Result Reports", is creating a problem. I am unable to provide the Path of the already-created XML file under the workspace folder of the Job. When I set the path of my file, i.e., "nunit-result.xml" and run the job, it throws an error:
"No test report files were found. Configuration error?"
Can anyone please help me out?
Thanks in advance.
Check the the beginning of the log where the clone is made. Sometimes when you have the "Enable concurrent builds" option it triggers another build in a different workspace called your-project-name#2/source and that's why it can't find the reports