SandroLuck / SonarDelphi

This repository contains the source code to the Sonar-Delphi plugin. Can be used to analyse Delphi projects with SonarQube.
27 stars 40 forks source link

CodeCoverageSensor is missing #1

Open t-huebner opened 7 years ago

t-huebner commented 7 years ago

Thank you for upgrading to Sonar 5.6.1! Basic feature are working fine.

I don't get unit test reporting and code coverage reporting to work. My CodeCoverage_Summary.xml is ignored and unit test report processing fails with exception:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project win32client: org.sonar.plugins.surefire.data.SurefireStaxHandler cannot be ast to org.sonar.api.utils.StaxParser$XmlStreamHandler at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.MojoExecutionException: org.sonar.plugins.surefire.data.SurefireStaxHandler cannot be cast to org.sonar.api.utils.StaxParser$XmlStreamHandler at org.sonarsource.scanner.maven.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:36) at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:81) at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:112) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: java.lang.ClassCastException: org.sonar.plugins.surefire.data.SurefireStaxHandler cannot be cast to org.sonar.api.utils.StaxParser$XmlStreamHandler at org.sonar.plugins.delphi.surefire.DelphiSureFireParser.parseFiles(DelphiSureFireParser.java:124) at org.sonar.plugins.delphi.surefire.DelphiSureFireParser.parseFiles(DelphiSureFireParser.java:117) at org.sonar.plugins.delphi.surefire.DelphiSureFireParser.collect(DelphiSureFireParser.java:87) at org.sonar.plugins.delphi.surefire.SurefireSensor.collect(SurefireSensor.java:93) at org.sonar.plugins.delphi.surefire.SurefireSensor.analyse(SurefireSensor.java:86) at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) at com.sun.proxy.$Proxy16.execute(Unknown Source) at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240) at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:78) ... 22 more

My pom.xml: `

delph test-report delphi code coverage target\CodeCoverage_Summary.xml target\CodeCoverage_Summary.xml true ` I'm using Sonar 5.6.1 LTS and Java 8. Delphi 10.1 and CodeCoverageTool 1.0 RC. Do you have any ideas?
SandroLuck commented 7 years ago

I see... The main problem is I used an alternative approach to get CodeCoverage. I have to investigate this feature. Are you using AQtime? (I do have a solution for this one using it's COM). I'll take a look at the sonar.delphi.codecoverage.report later this week.

EDIT: Just saw there is alot of "deprecated" documentation and analysing ways which won't work with SonarQube today.(I'll delete it soon)

t-huebner commented 7 years ago

Thank you for answering Sandro!

I'm using https://github.com/magicmonty/delphi-code-coverage to get an "emma" compatible CodeCoverage_Summary.xml - works very well together with newest Delphi 10.1!

My goal is, to get these results into Sonar together with my dunit xml report file.

asettico commented 7 years ago

Hi, I'm trying to reach the same goal, were you able to obtain code coverage analysis in sonar using codecoverage with emma report ? Can you share your experience?

SandroLuck commented 7 years ago

Using the generic code coverage Tool and aqtime i was able to Produce codecoverage. This ist the only Tested way but using the generic Code coverage tool(for sonarqube) it should be doable

SandroLuck commented 7 years ago

Sry for the German autocorrectur of my phone

asettico commented 7 years ago

ok, I've tried the generic code coverage tool of Sonar, it works fine. Now the problem is to generate the coverage file (in my test I've used a dummy file created manually). which version of AQTime have you used ?

asettico commented 7 years ago

I've modified the delphicodecoverage in order to produce a XML file in the Sonar Generic Code Coverage format, I'm testing it on my Hudson server. As soon as I have a stable / tested version I've pull it in github.

mendrix commented 4 years ago

@asettico have you already pulled your code in GitHub? I have the same issue I want to solve...