Skip to main content

Importing utPLSQL reports

The ZPA plugin imports the test results and code coverage of utPLSQL into SonarQube. It requires utPLSQL v3 and the reports generated by utPLSQL-cli.

Recommendations​

  • Keep main and test sources in separate folders, for example src and test, rather than src and src/test.
  • Compile with PLSQL_OPTIMIZE_LEVEL set to 0 or 1. Higher optimization levels can move code around, and the coverage lines stop matching the source files.

1. Analyze the test packages​

Point sonar.tests to the folder with the utPLSQL test packages, so SonarQube knows which files are tests and the utPLSQL rules can check them:

sonar.sources=src
sonar.tests=test

2. Generate the reports​

Run the tests with the two SonarQube reporters of utPLSQL:

utplsql run scott/tiger@localhost:1521/orcl \
-f=ut_sonar_test_reporter -o=utplsql-test.xml \
-f=ut_coverage_sonar_reporter -o=utplsql-coverage.xml

ZPA maps the database objects in the reports to the source files by itself, so the object-to-file mapping options of utPLSQL-cli (-source_path, -test_path, -regex_expression…) are not needed.

3. Import the reports​

With the file names above, which are the defaults, SonarScanner imports the reports without further configuration. For other names or locations, set:

sonar.zpa.tests.reportPaths=reports/tests.xml
sonar.zpa.coverage.reportPaths=reports/coverage.xml

Example: the utPLSQL project​

The utPLSQL project itself is analyzed on SonarQube Cloud and on a SonarQube instance with ZPA. On SonarQube Cloud, the coverage report needs a long list of mapping options:

utPLSQL-cli/bin/utplsql run <connection_string> \
-p='ut3_tester,ut3_user' \
-source_path=source \
-owner=ut3_develop \
-test_path=test \
-regex_expression="test/(\w+)(/(\w+))*/(\w+)\.(.{3})$" \
-owner_subexpression=1 \
-type_subexpression=5 \
-name_subexpression=4 \
-f=ut_coverage_sonar_reporter -o=coverage.xml \
-f=ut_sonar_test_reporter -o=test_results.xml

With ZPA, the same reports need only the schema to cover:

utPLSQL-cli/bin/utplsql run <connection_string> \
-p='ut3_tester,ut3_user' \
--coverage-schemes=ut3_develop \
-f=ut_coverage_sonar_reporter -o=coverage.xml \
-f=ut_sonar_test_reporter -o=test_results.xml

Compare the SonarQube Cloud dashboard with the SonarQube + ZPA dashboard.

More projects analyzed with ZPA: