title: Import Jasmine test results into SonarQube
body: <p>I've encountered a couple issues when trying to display the passing and failing Jasmine specs in my SonarQube instance for a Javascript project. I use Maven to manage running the tests, via the very nice maven-jasmine-plugin, which provides a very simple setup for integrating with RequireJS and spitting out a JUnit-style XML report in my <code>/target</code> directory. I'd like to use that report in Sonar.</p>
  
  <p>The first issue is that, if the tests are asynchronous, Jasmine reports a time of "undefined" for that test, which the Sonar Runner cannot parse, dying with an error:</p>
  
  <blockquote>
    <p>Fail to parse the Surefire report: 
    Caused by: java.text.ParseException: Unparseable number: "undefined"
    Caused by: Unparseable number: "undefined"</p>
  </blockquote>
  
  <p>If I manually edit the TEST-jasmine.xml report to simply change undefined to 0, the report can be parsed, but then I get the following warning:</p>
  
  <blockquote>
    <p>WARN - Test result will not be saved for test class "jasmine", because SonarQube associated resource has not been found using file name: "jasmine.js"</p>
  </blockquote>
  
  <p>This is on SonarQube 5.1 with the 2.5 version of the JavaScript plugin.</p>
  
  <p>I've seen some older mailing list and StackOverflow questions around proper Jasmine support in Sonar - is there any way to do what I want to do?</p>
  
  <p><strong>EDIT</strong> Below is the debug log of the sonar-runner (with some files and names redacted):</p>
  
  <pre><code>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\&lt;redacted&gt;\sonar-project.properties
  INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
  INFO: Work directory: c:\Users\Tom\Documents\&lt;redacted&gt;\.\.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;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=&lt;redacted&gt;&amp;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=&lt;null&gt;,key=&lt;redacted&gt;,qualifier=TRK], with key batch-&lt;redacted&gt;
  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 &lt;redacted&gt;
  08:53:28.231 INFO  - Load module settings
  08:53:28.326 DEBUG - Available languages:
  08:53:28.326 DEBUG -   * C# =&gt; "cs"
  08:53:28.327 DEBUG -   * Java =&gt; "java"
  08:53:28.327 DEBUG -   * JavaScript =&gt; "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\&lt;redacted&gt;
  08:53:28.582 INFO  - Working dir: c:\Users\Tom\Documents\&lt;redacted&gt;\.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 '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.603 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.608 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.610 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.612 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.613 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.614 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.614 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.615 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.615 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.618 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.620 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.622 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.623 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.623 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.624 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.624 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.625 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.625 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.625 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.626 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.627 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.629 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.632 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.633 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.634 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.635 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.636 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.637 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.638 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.640 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.642 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.643 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.643 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.644 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.645 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.647 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.648 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.649 DEBUG - Language of file '&lt;redacted&gt;.js' is detected to be 'js'
  08:53:28.650 DEBUG - Language of file '&lt;redacted&gt;.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) -&gt; QProfileSensor -&gt; InitialOpenIssuesSensor -&gt; ProjectLinksSensor -&gt; VersionEventsSensor -&gt; JavaScriptSquidSensor -&gt; JsTestDriverSensor -&gt; SCM Sensor (wrapped) -&gt; org.sonar.plugins.javascript.lcov.UTCoverageSensor@33d1d1ef -&gt; org.sonar.plugins.javascript.lcov.ITCoverageSensor@6d21e89c -&gt; 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\&lt;redacted&gt;\target\jasmine
  08:53:30.408 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@6e6b3dbf[id=3532,key=&lt;redacted&gt;,qualifier=TRK], with key batch-&lt;redacted&gt;
  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\&lt;redacted&gt;\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
  </code></pre>