我试图在我的SonarQube实例中为Javascript项目显示传递和失败的Jasmine规范时遇到了一些问题 . 我使用Maven管理运行测试,通过非常好的maven-jasmine-plugin,它提供了一个非常简单的设置,用于与RequireJS集成并在我的 /target 目录中吐出JUnit样式的XML报告 . 我想在声纳中使用该报告 .

第一个问题是,如果测试是异步的,Jasmine会报告该测试的“未定义”时间,Sonar Runner无法解析,因为错误而死亡:

无法解析Surefire报告:引起:java.text.ParseException:Unparseable number:“undefined”引起:Unparseable number:“undefined”

如果我手动编辑TEST-jasmine.xml报告以简单地将undefined更改为0,则可以解析报告,但随后我收到以下警告:

WARN - 测试类“jasmine”不会保存测试结果,因为找不到使用文件名的SonarQube关联资源:“jasmine.js”

这是在带有2.5版JavaScript插件的SonarQube 5.1上 .

我已经看到一些较旧的邮件列表和StackOverflow关于Sonar中正确的Jasmine支持的问题 - 有什么办法可以做我想做的事情吗?

EDIT 以下是声纳 - 跑步者的调试日志(有一些文件和名称被编辑):

SonarQube Runner 2.4
Java 1.8.0_40 Oracle Corporation (64-bit)
Windows 8.1 6.3 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: c:\Users\Tom\sonar-runner-dist-2.4\conf\sonar-runner.properties
INFO: Project configuration file: c:\Users\Tom\Documents\<redacted>\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Work directory: c:\Users\Tom\Documents\<redacted>\.\.sonar
INFO: SonarQube Server 5.1
08:53:25.409 INFO  - Load global repositories
08:53:25.415 DEBUG - Download: http://192.168.10.157:9000/batch/global (no proxy)
08:53:25.536 INFO  - Load global repositories (done) | time=129ms
08:53:25.537 INFO  - Server id: 20150608164048
08:53:25.538 INFO  - User cache: C:\Users\Tom\.sonar\cache
08:53:25.545 INFO  - Install plugins
08:53:25.545 DEBUG - Download index of plugins
08:53:25.545 DEBUG - Download: http://192.168.10.157:9000/deploy/plugins/index.txt (no proxy)
08:53:25.600 DEBUG - Loaded 2133 properties from l10n bundles
08:53:25.600 INFO  - Install JDBC driver
08:53:25.600 DEBUG - Download index of jdbc-driver
08:53:25.600 DEBUG - Download: http://192.168.10.157:9000/deploy/jdbc-driver.txt (no proxy)
08:53:25.606 INFO  - Create JDBC datasource for jdbc:mysql://192.168.10.157:3306/sonar?useUnicode=true&amp;characterEncoding=utf8
08:53:25.825 DEBUG - Testing JDBC connection
08:53:26.389 DEBUG - Download: http://192.168.10.157:9000/api/server (no proxy)
08:53:26.420 INFO  - Initializing Hibernate
08:53:26.421 DEBUG - hibernate.generate_statistics: false
08:53:26.421 DEBUG - hibernate.dialect: org.sonar.core.persistence.dialect.MySql$MySqlWithDecimalDialect
08:53:26.421 DEBUG - hibernate.connection.provider_class: org.sonar.jpa.session.CustomHibernateConnectionProvider
08:53:27.391 INFO  - Load project repositories
08:53:27.392 DEBUG - Download: http://192.168.10.157:9000/batch/project?key=<redacted>&amp;preview=false (no proxy)
08:53:27.564 INFO  - Load project repositories (done) | time=173ms
08:53:27.564 INFO  - Load project settings
08:53:27.892 INFO  - Load technical debt model
08:53:27.906 DEBUG - Load technical debt model (done) | time=14ms
08:53:27.909 INFO  - To enable the analysis bootstraper for Visual Studio projects, set the property "sonar.visualstudio.enable" to "true"
08:53:27.909 INFO  - Apply project exclusions
08:53:28.200 DEBUG - Acquire semaphore on project : org.sonar.api.resources.Project@6e6b3dbf[id=<null>,key=<redacted>,qualifier=TRK], with key batch-<redacted>
08:53:28.227 WARN  - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.
08:53:28.228 INFO  - -------------  Scan <redacted>
08:53:28.231 INFO  - Load module settings
08:53:28.326 DEBUG - Available languages:
08:53:28.326 DEBUG -   * C# => "cs"
08:53:28.327 DEBUG -   * Java => "java"
08:53:28.327 DEBUG -   * JavaScript => "js"
08:53:28.340 INFO  - Load rules
08:53:28.552 DEBUG - Load rules (done) | time=212ms
08:53:28.576 DEBUG - Code colorizer, supported languages: cs
08:53:28.582 DEBUG - Initializers : 
08:53:28.582 INFO  - Base dir: c:\Users\Tom\Documents\<redacted>
08:53:28.582 INFO  - Working dir: c:\Users\Tom\Documents\<redacted>\.sonar
08:53:28.583 INFO  - Source paths: sites/all/libraries/custom
08:53:28.583 INFO  - Source encoding: windows-1252, default locale: en_US
08:53:28.584 INFO  - Index files
08:53:28.592 INFO  - Excluded sources: 
08:53:28.592 INFO  -   sites/all/libraries/custom/vendor/*
08:53:28.592 INFO  -   sites/all/libraries/custom/js/*
08:53:28.593 DEBUG - Declared extensions of language org.sonar.batch.repository.language.Language@6bbd44e7 were converted to sonar.lang.patterns.cs : **/*.cs
08:53:28.593 DEBUG - Declared extensions of language org.sonar.batch.repository.language.Language@16641839 were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
08:53:28.593 DEBUG - Declared extensions of language org.sonar.batch.repository.language.Language@62640933 were converted to sonar.lang.patterns.js : **/*.js
08:53:28.603 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.603 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.608 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.610 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.612 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.613 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.614 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.614 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.615 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.615 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.618 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.620 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.622 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.623 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.623 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.624 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.624 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.625 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.625 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.625 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.626 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.627 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.629 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.632 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.633 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.634 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.635 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.636 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.637 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.638 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.640 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.642 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.643 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.643 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.644 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.645 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.647 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.648 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.649 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.650 DEBUG - Language of file '<redacted>.js' is detected to be 'js'
08:53:28.651 INFO  - 40 files indexed
08:53:28.652 INFO  - 16 files ignored because of inclusion/exclusion patterns
08:53:29.226 INFO  - Quality profile for js: Sonar way
08:53:29.310 DEBUG - Sensors : Lines Sensor (wrapped) -> QProfileSensor -> InitialOpenIssuesSensor -> ProjectLinksSensor -> VersionEventsSensor -> JavaScriptSquidSensor -> JsTestDriverSensor -> SCM Sensor (wrapped) -> org.sonar.plugins.javascript.lcov.UTCoverageSensor@33d1d1ef -> org.sonar.plugins.javascript.lcov.ITCoverageSensor@6d21e89c -> CPD Sensor (wrapped)
08:53:29.310 INFO  - Sensor Lines Sensor (wrapped)
08:53:29.324 INFO  - Sensor Lines Sensor (wrapped) (done) | time=14ms
08:53:29.324 INFO  - Sensor QProfileSensor
08:53:29.327 INFO  - Sensor QProfileSensor (done) | time=3ms
08:53:29.328 INFO  - Sensor InitialOpenIssuesSensor
08:53:29.372 INFO  - Sensor InitialOpenIssuesSensor (done) | time=44ms
08:53:29.372 INFO  - Sensor ProjectLinksSensor
08:53:29.382 INFO  - Sensor ProjectLinksSensor (done) | time=10ms
08:53:29.382 INFO  - Sensor VersionEventsSensor
08:53:29.405 INFO  - Sensor VersionEventsSensor (done) | time=23ms
08:53:29.405 INFO  - Sensor JavaScriptSquidSensor
08:53:29.620 INFO  - 40 source files to be analyzed
08:53:30.235 INFO  - 40/40 source files analyzed
08:53:30.243 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.244 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.244 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.246 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.255 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.257 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.262 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.263 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.264 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.266 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.267 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.268 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.269 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.270 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.270 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.272 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.272 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.273 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.274 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.275 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.276 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.277 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.278 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.279 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.280 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.281 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.282 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.283 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.285 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.286 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.287 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.288 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.288 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.289 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.290 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.291 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.292 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.293 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.294 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.295 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
08:53:30.364 INFO  - Sensor JavaScriptSquidSensor (done) | time=959ms
08:53:30.364 INFO  - Sensor JsTestDriverSensor
08:53:30.364 INFO  - Parsing Unit Test run results in Surefire format from folder c:\Users\Tom\Documents\<redacted>\target\jasmine
08:53:30.408 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@6e6b3dbf[id=3532,key=<redacted>,qualifier=TRK], with key batch-<redacted>
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 5.474s
Final Memory: 23M/572M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.api.utils.SonarException: Fail to parse the Surefire report: c:\Users\Tom\Documents\<redacted>\target\jasmine\TEST-jasmine.xml
    at org.sonar.plugins.javascript.unittest.surefireparser.AbstractSurefireParser.parseFiles(AbstractSurefireParser.java:91)
    at org.sonar.plugins.javascript.unittest.surefireparser.AbstractSurefireParser.parseFiles(AbstractSurefireParser.java:79)
    at org.sonar.plugins.javascript.unittest.surefireparser.AbstractSurefireParser.collect(AbstractSurefireParser.java:47)
    at org.sonar.plugins.javascript.unittest.jstestdriver.JsTestDriverSensor.collect(JsTestDriverSensor.java:73)
    at org.sonar.plugins.javascript.unittest.jstestdriver.JsTestDriverSensor.analyse(JsTestDriverSensor.java:67)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51)
    at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    ... 9 more
Caused by: javax.xml.stream.XMLStreamException: java.text.ParseException: Unparseable number: "undefined"
    at org.sonar.plugins.javascript.unittest.surefireparser.SurefireStaxHandler.getTimeAttributeInMS(SurefireStaxHandler.java:121)
    at org.sonar.plugins.javascript.unittest.surefireparser.SurefireStaxHandler.parseTestResult(SurefireStaxHandler.java:88)
    at org.sonar.plugins.javascript.unittest.surefireparser.SurefireStaxHandler.parseTestCase(SurefireStaxHandler.java:73)
    at org.sonar.plugins.javascript.unittest.surefireparser.SurefireStaxHandler.stream(SurefireStaxHandler.java:60)
    at org.sonar.api.utils.StaxParser.parse(StaxParser.java:109)
    at org.sonar.api.utils.StaxParser.parse(StaxParser.java:89)
    at org.sonar.api.utils.StaxParser.parse(StaxParser.java:79)
    at org.sonar.plugins.javascript.unittest.surefireparser.AbstractSurefireParser.parseFiles(AbstractSurefireParser.java:89)
    ... 38 more
Caused by: java.text.ParseException: Unparseable number: "undefined"
    at java.text.NumberFormat.parse(Unknown Source)
    at org.sonar.api.utils.ParsingUtils.parseNumber(ParsingUtils.java:47)
    at org.sonar.plugins.javascript.unittest.surefireparser.SurefireStaxHandler.getTimeAttributeInMS(SurefireStaxHandler.java:118)
    ... 45 more