SonarQube PHP
  1. SonarQube PHP
  2. SONARPHP-27

Cannot analyse project with multiple test files

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.4
    • Component/s: None
    • Labels:
      None
    • Environment:
      windows xp
    • Number of attachments :
      0

      Description

      I have a project with a test directory which have several test files, when I run mvn sonar:sonar with following options (in my pom.xml file):
      sonar.language=php
      sonar.dynamicAnalysis=true
      (sonar.phpPmd.shouldRun=false
      sonar.phpDepend.shouldRun=false
      sonar.phpcpd.shouldRun=false)
      sonar.phpUnit.coverage.shouldRun=true
      sonar.phpUnit.shouldRun=true

      I have the following error :

      Embedded error: Can not add twice the same measure:
      org.sonar.api.measures.Measure@10bed9c[
      id=<null>,
      metricKey=test_execution_time,
      metric=org.sonar.api.measures.Metric@1bb3e9a[
      key=test_execution_time,
      name=Unit tests duration,
      type=MILLISEC,enabled=true,
      qualitative=false,
      direction=-1,
      domain=Tests,
      worstValue=<null>,
      bestValue=<null>,
      optimizedBestValue=<null>,
      hidden=false],
      value=891.0,data=<null>,
      description=<null>,
      alertStatus=<null>,
      alertText=<null>,
      tendency=<null>,
      date=<null>,
      variation1=<null>,
      variation2=<null>,
      variation3=<null>,
      variation4=<null>,
      variation5=<null>,
      url=<null>,
      characteristic=<null>
      persistenceMode=FULL]

      The generated phpunit.xml file is formatted as following (phpunit command format)

      <testsuites>
      <testsuite ...>
      <testsuite ...>
      </testsuite>
      <testsuite ...>
      </testsuite>
      </testsuite>
      </testsuites>

        Activity

        Hide
        Fabien NAUD added a comment -

        If I edit the xml file (and run mvn sonar:sonar with sonar.dynamicAnalysis=false) as following (removing a testsuite)

        <testsuites>
        <testsuite ...>
        <testcase name="test1" class="MyTest" ...>
        <testcase name="test2" class="MyTest" ...>
        <testcase name="test3" class="MyTest" ...>
        <testsuite ...>
        </testsuite>
        </testsuite>
        </testsuites>

        Metrics are inserted into sonar database

        Show
        Fabien NAUD added a comment - If I edit the xml file (and run mvn sonar:sonar with sonar.dynamicAnalysis=false) as following (removing a testsuite) <testsuites> <testsuite ...> <testcase name="test1" class="MyTest" ...> <testcase name="test2" class="MyTest" ...> <testcase name="test3" class="MyTest" ...> <testsuite ...> </testsuite> </testsuite> </testsuites> Metrics are inserted into sonar database
        Hide
        Mathias kluba added a comment -

        This issue is linked with SONARPLUGINS-918

        Show
        Mathias kluba added a comment - This issue is linked with SONARPLUGINS-918
        Hide
        Akram Ben Aissi added a comment -

        This is also linked to SONARPLUGINS-748.
        But in this case, it seems that test cases have been analyzed twice and merged in an other file.
        Could you please test with 0.4 snapshot?

        Show
        Akram Ben Aissi added a comment - This is also linked to SONARPLUGINS-748 . But in this case, it seems that test cases have been analyzed twice and merged in an other file. Could you please test with 0.4 snapshot?
        Hide
        Cyril AKNINE added a comment -

        I have the same issue with 0.4 and sonar.dynamicAnalysis=false
        If my phpunit.xml log file has this kind of structure :
        <testsuites>
        <testsuite>
        <testsuite>
        <testcase />
        </testsuite>
        <testsuite>
        <testcase />
        </testsuite>
        </testsuite>
        </testsuites>

        Then, I have "Embedded error: Can not add twice the same measure on org.sonar.api.resources" error. But if I keep only 1 test file (commenting testcases in the other tests files, but keeping the files !), I have no error. Here is the kind of phpunit.xml log file generated that works :

        <testsuites>
        <testsuite>
        <testsuite /><!-- no testcase ! -->
        <testsuite>
        <testcase />
        </testsuite>
        </testsuite>
        </testsuites>

        Show
        Cyril AKNINE added a comment - I have the same issue with 0.4 and sonar.dynamicAnalysis=false If my phpunit.xml log file has this kind of structure : <testsuites> <testsuite> <testsuite> <testcase /> </testsuite> <testsuite> <testcase /> </testsuite> </testsuite> </testsuites> Then, I have " Embedded error: Can not add twice the same measure on org.sonar.api.resources " error. But if I keep only 1 test file (commenting testcases in the other tests files, but keeping the files !), I have no error. Here is the kind of phpunit.xml log file generated that works : <testsuites> <testsuite> <testsuite /><!-- no testcase ! --> <testsuite> <testcase /> </testsuite> </testsuite> </testsuites>

          People

          • Assignee:
            Akram Ben Aissi
            Reporter:
            Anonymous
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: