Sonar-Runner 2.4 can't find code coverage reports - visual-studio-2012

I'm running SonarQube 5.2 with SonarRunner v2.4 (MSBuild) and am having issues getting SonarRunner to pick up the code coverage reports. I have VS Test which drops the TestResults folder within the source directory. The TRX file is within the TestResults folder. Is there a default directory that Sonar-Runner scans to search for the TRX/code coverage reports? The build succeeds but there are no unit test coverage results in SonarQube for the app.
TRX: F:\Builds\50\IT\ABCDemo.Nightly\src\TestResults\ *.TRX
Source:
F:\Builds\50\IT\ABCDemo.Nightly\src
Process:
SonarRunner begin //with key,name,version filled in
MSBuild executes
VS Test executes and drops TestResults folder within src directory.
SonarRunner end
Issue:
MSBuild SonarQube Runner Post-processor 1.0.2.0
09:22:57.327 Fetching code coverage report information from TFS...
09:23:17.723 No code coverage reports were found for the current build.
EDIT: I've included the .TRX and .coveragexml files using /d: but I still get the issue saying no code coverage reports were found.
I can see in the logs that it does:
09:51:59.875 INFO - Parsing the Visual Studio coverage XML report f:\Builds\50\IT\ABCDemo.Nightly\src\VisualStudio.coveragexml
09:53:07.737 INFO - Parsing the Visual Studio Test Results file f:\Builds\50\IT\ABCDemo.Nightly\src\TestResults\tfsbuildagent_QL1CIBUILD3 2015-12-03 09_51_33.trx
These occur near the end of sonar analysis.

Resolved by:
Included the paths to the files for trx and coveragexmls within the arguments for sonar-runner.
MSBuild.SonarQube.Runner.exe begin
/k:projectkey /n:projectname /v:projectversion
/d:sonar.cs.vstest.reportsPaths="path\to\ *.trx"
/d:sonar.cs.vscoveragexml.reportsPaths="path\to\VisualStudio.coveragexml"
Moved the /'s around for better visual.

Related

Rerunning failed scenarios with Selenide/Cucumber - no rerun.txt file

I writing automation tests with Cucumber/Selenide and I want to rerun failed scenarios.
This is part of my project with only two small tests (one is failing) to demonstrate behavior: https://github.com/mtpx/cucumberRerun
I read how to do it on How to rerun the failed scenarios using Cucumber? and https://medium.com/#belek.bagishbekov/how-to-rerun-failed-test-cases-in-cucumber-b7fe9b1dcf9c
In my application.feature test runner(ApplicationTest) in #CucumberOptions's plugins section I have line: "rerun:rerun/failed_scenarios.txt", according to previous urls it should generate text file with failed scenario, but after test execution with 'mvn clean test' (with failed scenarios) - there's no any rerun.txt file.
Do You know what is wrong here? Why after build i dont have rerun.txt file?
I using Selenide instead of Selenium, maybe problem is here?
Create another scenario file as shown below. Let's say this as FailedScenarios.java. Whenever you notice any failed scenario run this file. This file will use target/rerun.txt as an input for running the scenarios.
This line is require:
features = "#target/rerun.txt",
Full CucumberOptions
#CucumberOptions(
monochrome = true,
features = "#target/rerun.txt", //Cucumber picks the failed scenarios from this file
format = {"pretty", "html:target/site/cucumber-pretty",
"json:target/cucumber.json"}
)
public class FailedScenarios {
}
You can use rerun file path other than target if you need to run failed Scenario also trigger from maven , In that case change the path in both file you main runner and failed test runner
problem solved :)
In pom i had line:
-Dcucumber.options="--plugin io.qameta.allure.cucumberjvm.AllureCucumberJvm"
This line overrides all plugins information in TestRunner

xUnit tests fails when executed by Azure DevOps

I'm creating a very simple test project to experiment with various Azure DevOps CI/DI features. This project contains a solution with an ASP.NET Core website project, and an xUnit unit tests project. The unit tests runs correctly on my local machine (tested with the visual studio runner and with dotnet test, but I cannot make it work with an Azure build.
The output of the unit tests step in Azure is the following :
##[section]Starting: Test Assemblies
==============================================================================
Task : Visual Studio Test
Description : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
Version : 2.147.0
Author : Microsoft Corporation
Help : [More information](https://go.microsoft.com/fwlink/?LinkId=835764)
==============================================================================
SystemVssConnection exists true
SystemVssConnection exists true
SystemVssConnection exists true
Running tests using vstest.console.exe runner.
======================================================
Test selector : Test assemblies
Test filter criteria : null
Search folder : D:\a\1\s
VisualStudio version selected for test execution : latest
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Diagnostics enabled : true
SystemVssConnection exists true
Run the tests locally using vstest.console.exe
========================================================
Test selector : Test assemblies
Test assemblies : **\release\netcoreapp2.2\*test*.dll,!**\obj\**
Test filter criteria : null
Search folder : D:\a\1\s
Run settings file : D:\a\1\s
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Diagnostics enabled : false
Rerun failed tests: false
VisualStudio version selected for test execution : latest
========================================================
======================================================
[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" #D:\a\_temp\e481a311-390d-11e9-aa01-4f08eeab4c37.txt
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation. All rights reserved.
vstest.console.exe
"D:\a\1\s\tests\ContosoUniversity.Tests\bin\Release\netcoreapp2.2\ContosoUniversity.Tests.dll"
"D:\a\1\s\tests\ContosoUniversity.Tests\bin\Release\netcoreapp2.2\xunit.runner.visualstudio.dotnetcore.testadapter.dll"
/logger:"trx"
/TestAdapterPath:"D:\a\1\s"
Starting test execution, please wait...
Test run will use DLL(s) built for framework .NETCoreApp,Version=v2.2 and platform X86. Following DLL(s) do not match framework/platform settings.
xunit.runner.visualstudio.dotnetcore.testadapter.dll is built for Framework 1.0 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (64-bit .NET Core 4.6.27207.03)
[xUnit.net 00:00:04.36] Discovering: ContosoUniversity.Tests
[xUnit.net 00:00:04.43] Discovered: ContosoUniversity.Tests
[xUnit.net 00:00:04.44] Starting: ContosoUniversity.Tests
[xUnit.net 00:00:04.93] Finished: ContosoUniversity.Tests
Passed ContosoUniversity.Controllers.HomeControllerTest.Index_Renvoie_Le_Bon_Modele
Unable to find D:\a\1\s\tests\ContosoUniversity.Tests\bin\Release\netcoreapp2.2\xunit.runner.visualstudio.dotnetcore.testadapter.deps.json. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk".
Results File: D:\a\1\s\TestResults\VssAdministrator_fv-az561_2019-02-25_14_59_22.trx
Total tests: Unknown. Passed: 1. Failed: 0. Skipped: 0.
Test Run Aborted.
Test execution time: 8.5546 Seconds
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1
##[error]VsTest task failed.
##[section]Async Command Start: Publish test results
Publishing test results to test run '1000118'
Test results remaining: 1. Test run id: 1000118
Published Test Run : https://orkeis-proj1.visualstudio.com/MyFirstProject_Test/_TestManagement/Runs#runId=1000118&_a=runCharts
##[section]Async Command End: Publish test results
##[section]Finishing: Test Assemblies
I'm failing to understand how I'm supposed to have that missing json file. The error suggests to install Microsoft.NET.Test.Sdk, but I do have it referenced in my project file :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>ContosoUniversity</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\ContosoUniversity.csproj" />
</ItemGroup>
</Project>
So any tip about what I'm missing would be appreciated.
The problem was that the default file pattern to look for test assemblies (*test*.dll) also did include xUnit's core assemblies (named xunit.runner.visualstudio.dotnetcore.testadapter.dll), which confused the test system.
All I had to do to fix the issue is use a more specific pattern (like *tests.dll), or exclude all test adapter assemblies (!**/*testadapter.dll).
Update : The official xUnit documentation has been updated to help avoid this problem (https://xunit.net/docs/getting-test-results-in-azure-devops)
Thanks to #Shtong I was able to fix my xunit pipeline build.
This is my YAML file for future reference:
- task: VSTest#2
inputs:
testAssemblyVer2: |
**\bin\$(BuildConfiguration)\**\*tests*.dll
!**\obj\**
!**\xunit.runner.visualstudio.testadapter.dll
!**\xunit.runner.visualstudio.dotnetcore.testadapter.dll
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
otherConsoleOptions: '/platform:x64 /Framework:.NETCoreApp,Version=v3.1 /logger:console;verbosity="normal" '
I had a similar problem, that could be solved by the solution given by Shtong.
But in my case the cause was quite different, this is why I want to share it here.
In my scenario A.Tests project references B.Tests project because some test classes inherit from B.Tests classes. This caused B.Tests.dll to be copied to A.Tests.dll location causing the same hickup in vstest.
To get rid of the error I excluded B.Tests.dll from the A.Tests.dll folder by
!**\A.Tests\**\B.Tests.dll

VSTest - DeploymentItem defined in testsettings file is not being deployed to TestResults folder

I have a testsettings file with deployment items defined in it that deploys my files as I expect when I use it with MSTest. However, when I use the same testsettings file with vstest.console.exe the items do not get deployed to the TestResults folder. Do I need to do something differently to deploy specific files with vstest?
Here's the deployment section in the testsettings file:
<Deployment>
<DeploymentItem filename="C:\MyTests\testfile.txt" />
</Deployment>
Here's how I'm using it with MSTest that works:
MSTest.exe /testcontainer:"C:\Tests\MyTests.dll" /testsettings:"C:\Tests\ts.testsettings"
And here's how I'm using it with VSTest that is not working:
vstest.console.exe C:\Tests\MyTests.dll /Settings:"C:\Tests\ts.testsettings"
Please make sure DeploymentEnabled flag is true in runsettings file. By default this is true. Changing it to false doesn't copy Deployment Items to the out directory of the TestResults folder.
Example:
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeploymentEnabled>True</DeploymentEnabled>
</MSTest>
Reference https://msdn.microsoft.com/en-us/library/jj635153.aspx

Veracode through an error - ASPCONFIG: Could not autodiscover 'components.config'

I have a Veracode plugin in my VS 2013 Professional.
I have ucommerce.dll, Sitecore.Kernel and Sitecore.Analytics.dll
I set copy local true for all above dll files.
When i tried to pre-compile all the web project I'm getting a below error message
1>------ Pre-compile started: Project: XXXXX.Web.PQRPorta\ ------
1>Pre-compiling with command similar to the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -p
"C:/XXXXX.Web.PQRPortal" -v "XXXXX.Web.PQRPortal/" -fixednames -f -c
-d "C:/SVN/trunk/Releases/SourceCode/Source/PrecompiledWeb/XXXXX.Web.PQRPortal"
1>error ASPCONFIG: Could not autodiscover 'components.config'. Make
sure it's present in the application folder
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\' or in a
sub folder. Paths ignored
''C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\bin',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\App_Data',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\obj''
1>XXXXX.Web.PQRPortal\ - 1 error, 0 warnings
Is there any configuration missing?
Update
I found the components.config file inside
C:\inetpub\wwwroot\XXXX\Website\sitecore modules\Shell\uCommerce\Configuration
and I added the file inside the web project root directory and tried to precompile web project, now I’m getting different error error
ASPRUNTIME: Type is not resolved for member 'Castle.Windsor.Configuration.Interpreters.ConfigurationProcessingException,Cast‌​le.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
any solution for it?
The components.config is a file uCommerce need.
The configuration file should be placed somewhere below the uCommerce folder. (not sure where depend on the version) It will automatically be picked up when the application starts up.

SonarQube Analysis not showing code coverage

I have a Jenkins project to do SonarQube analysis of my NodeJS project. I added istanbul as a dependency to my project's package.json. In the Jenkins build configuration, first I run a shell script:
cd ./project-name
npm install
node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha path-to-unit-tests
node_modules/.bin/istanbul report cobertura
cd ..
This installs the dependencies, runs the tests and generates a code coverage report and generates a cobertura-coverage.xml file.
After the shell script, I run a Invoke Standalone SonarQube Analysis with the following properties for code coverage:
sonar.java.coveragePlugin=cobertura
sonar.dynamicAnalysis=reuseReports
sonar.cobertura.reportPath=./project-name/coverage/cobertura-coverage.xml
The Jenkins job runs successfully with a SonarQube dashboard describing various things such as the lines of code, technical debt, issues and so on for the project. But the code coverage for the unit tests doesn't show up on the SonarQube dashboard. I made sure that the dashboard has the Unit Tests widget.
Version of SonarQube server: 5.2
Version of JavaScript plguin used on SonarQube: 2.9
Version of Cobertura plugin used on SonarQube: 1.6.3
Version of Cobertura plugin used on Jenkins: 1.9.7
Version of NodeJS plugin used on Jenkins: 0.2.1
I verified that the workspace does have the cobertura-coverage.xml file. Also checked the build console logs and found no bugs. I have also tried pushing the code coverage using LCOV format before:
sonar.dynamicAnalysis=reuseReports
sonar.javascript.lcov.reportPath=./project-name/coverage/lcov.info
The report doesn't get published to SonarQube even though the coverage report does get generated in Jenkins workspace. I looked at the workspace contents and verified. The console logs show the coverage report getting generated. Also tried
sonar.dynamicAnalysis=reuseReports
sonar.javascript.lcov.reportPath=project-name/coverage/lcov.info
and
sonar.dynamicAnalysis=reuseReports
sonar.cobertura.reportPath=project-name/coverage/cobertura-coverage.xml
to no avail. I also restarted the Jenkins and SonarQube servers 2 times each. Looked at many similar questions on StackOverflow and elsewhere but didn't find anything that works.
If I add a post-build action Publish Cobetura Coverage Report and specify the path to the cobetura-coverage.xml file in the Cobertura xml report pattern field, the code coverage report does get published in Jenkins.
Looked at the background task logs in SonarQube and saw an exception.
java.lang.IllegalStateException: Cannot persist sources of project-key:project-name/node_modules/jscs/jscs-browser.js
at org.sonar.server.computation.step.PersistFileSourcesStep$FileSourceVisitor.visitFile(PersistFileSourcesStep.java:132) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitNode(DepthTraversalTypeAwareCrawler.java:72) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:44) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:91) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:47) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:91) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:47) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.PersistFileSourcesStep.execute(PersistFileSourcesStep.java:89) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:39) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.taskprocessor.report.ReportTaskProcessor.process(ReportTaskProcessor.java:53) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.taskprocessor.CeWorkerRunnableImpl.executeTask(CeWorkerRunnableImpl.java:78) [sonar-server-5.2.jar:na]
at org.sonar.server.computation.taskprocessor.CeWorkerRunnableImpl.run(CeWorkerRunnableImpl.java:55) [sonar-server-5.2.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45-internal]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_45-internal]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_45-internal]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_45-internal]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45-internal]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45-internal]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45-internal]
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (7989143 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
### The error may involve org.sonar.db.source.FileSourceMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO file_sources (project_uuid, file_uuid, created_at, updated_at, binary_data, line_hashes, data_hash, src_hash, data_type, revision) VALUES (?, ?, ?, ?, ?, ?, ?, ?,?, ?)
### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (7989143 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:154) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) ~[mybatis-3.2.7.jar:3.2.7]
at com.sun.proxy.$Proxy84.insert(Unknown Source) ~[na:na]
at org.sonar.db.source.FileSourceDao.insert(FileSourceDao.java:117) ~[sonar-db-5.2.jar:na]
at org.sonar.server.computation.step.PersistFileSourcesStep$FileSourceVisitor.persistSource(PersistFileSourcesStep.java:160) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.PersistFileSourcesStep$FileSourceVisitor.visitFile(PersistFileSourcesStep.java:130) ~[sonar-server-5.2.jar:na]
... 18 common frames omitted
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (7989143 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3540) ~[mysql-connector-java-5.1.35.jar:5.1.35]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2417) ~[mysql-connector-java-5.1.35.jar:5.1.35]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) ~[mysql-connector-java-5.1.35.jar:5.1.35]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2535) ~[mysql-connector-java-5.1.35.jar:5.1.35]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1911) ~[mysql-connector-java-5.1.35.jar:5.1.35]
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1203) ~[mysql-connector-java-5.1.35.jar:5.1.35]
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) ~[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) ~[commons-dbcp-1.4.jar:1.4]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:50) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152) ~[mybatis-3.2.7.jar:3.2.7]
... 25 common frames omitted
So now I've updated the shell script code coverage generation line to
node_modules/.bin/istanbul cover -x node_modules ./node_modules/.bin/_mocha path-to-unit-tests
Still getting the exception. Based on max_allowed_packet, I don't have MySQL, I need to bump up the value of MAX_ALLOWED_PACKET in the database settings. Just done that and retriggered the Jenkins job for SonarQube analysis. The exception disappeared. The background task in SonarQube was successful. But I still don't see Unit test code coverage in the dashboard. There are no other exceptions. When I click on 'Configure Widgets' button, the Unit test widget has 'No data' label on it. When I go back to the dashboard, the Unit test widget disappears.
Any idea what I am missing?
The first time (~a year back) when I started exploring "Sonarqube" and while doing set up everything worked fine. I was able to see all the metrics along with "code coverage".
For that used version was:
sonarqube-6.7.5, sonar-scanner:
sonar-scanner-3.2.0.1227-macosx
After that, when I tried today for some other project but I struggled almost ~3 hours to identify why code coverage is not being displayed in the sonarqube report though everything is configured properly.
After spending some time I have found below two blog topics which helps me to understand why I was not getting the coverage report.
If I read it correctly then it seems that there was a bug where after "lcov" report path was not recognized though it was configured accurately.
Reference links:
unable-to-get-code-coverage-for-javascript
Fix: js-coverage-doesnt-work-anymore
Used version: Docker image of sonarqube:8.3.0 & newtmitch/sonar-scanner as a sonar-scanner.
For reference, Dockerfile from my local setup which is used to run the sonar-scanner:
FROM newtmitch/sonar-scanner AS sonarqube_scan
COPY . /usr/src
RUN ls -list
RUN sonar-scanner \
-Dsonar.host.url="http://localhost:9000" \
-Dsonar.projectKey="test-node-app" \
-Dsonar.projectVersion="1.0" \
-Dsonar.sources="/usr/src" \
-Dsonar.language="javascript" \
-Dsonar.sourceEncoding="UTF-8" \
-Dsonar.dynamicAnalysis="reuseReports" \
-Dsonar.javascript.lcov.reportPaths="/usr/src/app/coverage/lcov.info"
I hope someone this helpful!
Happy learning!
The lcov report publishing worked after I had fixed the exception mentioned in the question. But sometimes, I randomly see another exception. Moreover, the Unit test widget on the SonarQube dashboard shows only the Conditionals coverage. Need to fine tune the solution more.
sonar.dynamicAnalysis=reuseReports
sonar.javascript.lcov.reportPath=project-name/coverage/lcov.info

Resources