Generate dotcover coverage report with jenkins - unit-testing

I have ci server setup on jenkins which builds the .net core 2.2 application. and then generates Test Coverage report using dotcover.
I am executing following command from jenkins job to generate coverage report using dotcover in the directory where Test project's .csproj file exist.
dotnet restore
dotnet dotcover test --dcReportType=HTML --dcOutPut="%WORKSPACE%\TestReport\index.html"
It gives me following error.
[JetBrains dotCover] Failed to perform coverage analysis. Operation
was canceled by the user.
Failed to register x86 core COM object: RegSvr32 failed to register
the core. Exit code is 00000003. Probably you haven't rebooted after a
Windows update. Please reboot the computer and try again.
I have already updated and rebooted as suggested in error but it doesn't solves the issue.
If I run this command directly from Command Line it works fine and generates report properly with the same commands.
Don't know what I am missing in jenkins.

Related

"No test is available" when attempting to run VSTest for a GoogleTest exe

I have a C++ project that I am attempting to build and run using Azure Pipelines.
The build is working fine but I can't seem to get the unit tests to run in VSTest task using GoogleTest.
It was my understanding Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest is installed (as per https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md) so it can't be that.
Looking at the log I see:
No test is available in D:\a\1\s\Release\UnitTests.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
I also attempted a Command Line Script task but running the UnitTests.exe just yields:
'UnitTests.exe' is not recognized as an internal or external command,
operable program or batch file.
I solved this in the end by installing the Nuget package "GoogleTestAdapter" by Christian Soltenborn. All now seems to work fine but still very puzzled why this workaround is needed

"Failed to activate app" when trying to run UWP unit tests as part of a build pipeline or using vstest

We have a UWP app with unit tests that run fine from Visual Studio. However, we are running into issues when trying to run the tests on our build agent. To isolate the issue from our build pipeline, we have tried to run the tests using vstest.console.exe from the command line on our local build machine. The error below is the same regardless of whether we run from the build pipeline or from the command line. We would appreciate any guidance.
TestWindow>vstest.console.exe /Platform:x86 /Framework:FrameworkUap10
/InIsolation /logger:trx;LogFileName=%temp%\SampleUwpAppTest.trx
C:\vsts-agent_work\22\a\AppxPackages\SimpleUwpApp.Tests_1.0.0.0_x86_Test\SimpleUwpApp.Tests_1.0.0.0_x86.appx
Microsoft (R) Test Execution Command Line Tool Version 15.7.2
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait... Attempting to deploy to target
'Local Machine'. Deployment operation succeeded, package moniker:
'7d25c824-2568-4449-a622-ad28662417f9_1.0.0.0_x86__a178p9x51fw8a'.
Attempting to launch app with app user model Id
'7d25c824-2568-4449-a622-ad28662417f9_a178p9x51fw8a!vstest.executionengine.universal.App' and arguments '--port 1428 --endpoint 127.0.0.1:01428 --role client
--parentprocessid 5744 --telemetryoptedin false'. DEP7100: Failed to activate app
'7d25c824-2568-4449-a622-ad28662417f9_a178p9x51fw8a!vstest.executionengine.universal.App' with parameters '--port 1428 --endpoint 127.0.0.1:01428 --role client
--parentprocessid 5744 --telemetryoptedin false'. Access is denied.
Access is denied.
App activation failed.
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException:
Failed to initialize client proxy: could not connect to test process.
at
Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1
sources) at
Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria
testRunCriteria, ITestRunEventsHandler eventHandler) Closing app with
package full name
'7d25c824-2568-4449-a622-ad28662417f9_1.0.0.0_x86__a178p9x51fw8a'.
Test Run Aborted.
Build Information
Our sample solution has two projects: SimpleUwpApp and SimpleUwpApp.Tests. The former's project file has <AppxBundle>Always</AppxBundle> and the latter has <AppxBundle>Never</AppxBundle>. The build agent is a local Windows 10 machine which we have used for UWP builds for a while. Here is a screenshot of our build configuration in Azure DevOps:
You might see this error if developer mode is not enabled on the build agent.
You can enable developer mode in the Settings app, or set the AllowDevelopmentWithoutDevLicense registry key.
I ran across this issue today and eventually traced it to the way in which our Self-Hosted Azure DevOps agent was running - in order to run UWP Unit Tests you have to use Interactive mode for the Agent and not run it as a Windows Service. From the docs:
Visible UI testing using self-hosted Windows agents
Agents that are configured to run as service can run Selenium tests only with headless browsers. If you are not using a headless browser, or if you are running UI tests for desktop apps, Windows agents must be configured to run as an interactive process with auto-logon enabled.
After making this change I found the error went away.

How to get JaCoCo instrumentation code coverage while executing webApplication on server

I want to get a code coverage report (or tracking controller flow of an application) when I execute the some scenario on live application i.e. while application running in server, so I have refereed the official Jacoco documentation and did as fallows
As a first step, I tried to bind the jacoco agent to the application running port
export MAVEN_OPTS=-javaagent:/home/user/.m2/repository/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128-runtime.jar=includes=*,output=tcpserver,port=6300,address=*,dumponexit=true
then I have started the server and executed some test scenarios by that time I have also requested jacoco to get the dump by executing following command
mvn jacoco:dump
when I executed the above command first it showed like java.net.BindException: Address already in use then it printed as fallows
[INFO] Connecting to localhost/127.0.0.1:6300
When I stopped the server jacoco.exec has been generated to a known location there after I have requested to generate a jacoco report by executing the following command
mvn jacoco:report
Finally I got the report but when I open the index.html page it showed 0% coverage.
you can reproduce my difficulty with following sample Spring MVC project
please download Spring MVC project from https://github.com/mkyong/spring4-mvc-ajax-example from the Github
In my case I am using WildFly 8.x server to run the project and add the following dependencies to downloaded projects pom.xml
maven-surefire-plugin of 2.19.1 version
jacoco-maven-plugin of 0.7.4.201502262128 version
junit of 4.12 version
Then clean and build the project by using following commands.
mvn clean install
once it is done get the .war file from target folder of the project and keep inside the wildfly serverwildfly-9.0.0.CR2/standalone/deployments/ folder
Once the .war is deployed go to /wildfly-9.0.0.CR2/bin/ folder and execute/run the ./standalone.sh file or depending on platform you can run the.dat/.sh file
once project is deployed and server is started execute the following command
mvn jacoco:dump
it displayed like listening/connected to localhost/127.0.0.1:6300
Then execute some test scenarios and execute following maven command
mvn jaococ:report
Finally report will be generated with 0% coverage!.
Downloaded project can be found in MKyong website
Please help me to get the code coverage report and any help will be appreciated.
JaCoCo requires the exact same class files for report generation that were used at execution time, so
if report is completely empty, then classes were not provided
if report contains classes but their coverage is 0%, then they don't match classes that were used at runtime - this is described along with other related information in JaCoCo documentation on page http://www.jacoco.org/jacoco/trunk/doc/classids.html
and in either case check existence of warnings in log.
Update for updated question
Here is what I did:
downloaded and unpacked JaCoCo 0.7.9 into /tmp/jacoco/jacoco-0.7.9
downloaded and unpacked Wildfly 9.0.0.CR2 into /tmp/jacoco/wildfly-9.0.0.CR2
cloned https://github.com/mkyong/spring4-mvc-ajax-example into /tmp/jacoco/spring4-mvc-ajax-example and built as mvn verify
copied /tmp/jacoco/spring4-mvc-ajax-example/spring4-mvc-maven-ajax-example-1.0-SNAPSHOT.war into /tmp/jacoco/wildfly-9.0.0.CR2/standalone/deployments
Wildfly started as JAVA_OPTS=-javaagent:/tmp/jacoco/jacoco-0.7.9/lib/jacocoagent.jar=output=tcpserver ./standalone.sh and got enough time to deploy application
in directory /tmp/jacoco/spring4-mvc-ajax-example executed mvn org.jacoco:jacoco-maven-plugin:0.7.9:dump org.jacoco:jacoco-maven-plugin:0.7.9:report (note that version of used agent matches version of jacoco-maven-plugin) so that it created /tmp/jacoco/spring4-mvc-ajax-example/jacoco.exec and report /tmp/jacoco/spring4-mvc-ajax-example/site/jacoco:
opened http://localhost:8080/spring4-mvc-maven-ajax-example-1.0-SNAPSHOT/ and did some actions
executed mvn org.jacoco:jacoco-maven-plugin:0.7.9:dump org.jacoco:jacoco-maven-plugin:0.7.9:report again to get an updated report:

Error while running Nunit 3.0.1 in Bamboo CI

I am running NUnit 3.0.1 as a build task in Bamboo CI after the MSbuild task.
I am getting the following error
Invalid argument: -xml=TestResult.xml
Running a bat file as specified in How to run NUnit Runner in Atlassian Bamboo with NUnit 3 also didnt work as it gave me the error nunit3-console.exe is not a recognized command
Bamboo CI doesn't appear to fully support NUnit 3.X yet, see the issue here.
The error you are seeing is because NUnit 3 no longer supports the -xml option.
Looking at the notes on the Bamboo issue, it looks like the best appoach is to run NUnit3 as a script task (using the option --result=YOURPATH;format:nunit2 to format the results as NUnit2 would have), and then adding an NUnit Parser Task to merge the results back in.

Configure SpecRun in TeamCity

I have some specflow test and I have configured it to Run in Teamcity using NUnit Runner. But currently
I have a requiremenet to run all the test using SpecRun Runner in TeamCity.
I am quite clueless as how to configure to run test using specrunner in Teamcity as I didnt find a option
in the Runner dropdown in Teamcity to select SpecRun.
Can anyone please help me in giving some info on configuring specrun in Teamcity.
Thanks
I suspect that you will have to use a generic command line step in order to run SpecRun.exe to run the tests. As long as you use the command line switch /buildserver:teamcity then SpecRun should output the correct messages to allow integration with TeamCity so that it shows the tests as passed or failed.
Timothy, Teamcity Runner Dropdown does not provide a Specrun Option.
What can be done is write a .bat file to run runtests.cmd, i.e
"C:\Users\username\Documents\Visual Studio 2015\Projects\Blah_Blah_Project\Project_Name\runtests.cmd".
Now, save this .bat file in any C drive location. Select "Command Line" from TeamCity Dropdown, click on Advanced Option. Mention the Working Directory(path to .bat file) and Command Executable (name of the bat file).
I am assuming here, you have downloaded Specrun.Specflow plugin using nuget manager in Visual Studio and configured Default.srprofile file and successfully fired the specflow testcases from command line using runtests.cmd.