SonarQube PHP
  1. SonarQube PHP
  2. SONARPHP-213

Improve the way PHPUnit is executed from Sonar

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.4
    • Fix Version/s: 0.6
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      At the moment by default we still support executing phpunit tests via AllTests.php file. The default behaviour should be using phpunit xml configuration file.

        Activity

        Hide
        Sebastian Marek added a comment -

        There are several way of executing phpunit. All of them explained in PHPUnit manual - see http://www.phpunit.de/manual/current/en/textui.html and http://www.phpunit.de/manual/current/en/organizing-tests.html

        In short, at the moment the way you can execute PHPUnit within Sonar is:

        • by using sonar.phpUnit.analyze.test.directory - if set to true (default value) it will pass test directory path to PHPUnit. If set to false it will use sonar.phpUnit.mainTestClass option
        • by using sonar.phpUnit.mainTestClass - to point at suite file, commonly known as AllTests.php. That's the old way of executing PHPUnit, I believe it's not supported anymore. (will double check though)
        • if file specified in sonar.phpUnit.mainTestClass doesn't exist and is set to false Sonar will execute PHPUnit using PHPUnit xml file.
        Show
        Sebastian Marek added a comment - There are several way of executing phpunit. All of them explained in PHPUnit manual - see http://www.phpunit.de/manual/current/en/textui.html and http://www.phpunit.de/manual/current/en/organizing-tests.html In short, at the moment the way you can execute PHPUnit within Sonar is: by using sonar.phpUnit.analyze.test.directory - if set to true (default value) it will pass test directory path to PHPUnit. If set to false it will use sonar.phpUnit.mainTestClass option by using sonar.phpUnit.mainTestClass - to point at suite file, commonly known as AllTests.php. That's the old way of executing PHPUnit, I believe it's not supported anymore. (will double check though) if file specified in sonar.phpUnit.mainTestClass doesn't exist and is set to false Sonar will execute PHPUnit using PHPUnit xml file.
        Hide
        Sebastian Marek added a comment -

        Now:

        • by default run PHPUnit using xml config file
        • running tests from a given test folder is not default behaviour anymore
        • don't add test dirs to phpunit cmd line when a custom phpunit xml file is provided
        • sonar.phpUnit.mainTestClass - deprecated

        Reasoning behind all of this - only using phpunit xml file we can create an accurate coverage report.

        Show
        Sebastian Marek added a comment - Now: by default run PHPUnit using xml config file running tests from a given test folder is not default behaviour anymore don't add test dirs to phpunit cmd line when a custom phpunit xml file is provided sonar.phpUnit.mainTestClass - deprecated Reasoning behind all of this - only using phpunit xml file we can create an accurate coverage report.

          People

          • Assignee:
            Sebastian Marek
            Reporter:
            Sebastian Marek
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: