Home > OS >  Get Code Coverage from utPLSQL within Azure DevOps Pipeline?
Get Code Coverage from utPLSQL within Azure DevOps Pipeline?

Time:08-05

I'm using utPLSQL 3.1.12.3589 on an Oracle 19c database. The business logic to be tested is deployed in schema BUSINESS_LOGIC, the unit tests are deployed in schema UNIT_TESTS.

When I collect the code coverage within an Azure DevOps pipeline it seems to pick up only that from schema UNIT_TESTS. How can I get the coverage from schema BUSINESS_LOGIC?

utPLSQL-cli is called from a Powershell script (connection parameters are in the variables):

$argstr = @("run $db_user/$db_pw@$db_conn", "-f=UT_JUNIT_REPORTER", "-o=dbtest.xml", "-f=UT_COVERAGE_COBERTURA_REPORTER", "-o=dbcoverage.xml", "-f=UT_COVERAGE_HTML_REPORTER", "-o=html_coverage/coverage.html")
Start-Process -FilePath "\\my-server\utPLSQL-cli\bin\utplsql.bat" -ArgumentList $argstr -Wait -NoNewWindow

This is necessary because the tests are integrated in an Azure DevOps pipeline. Thus the recommended approach to set the coverage does not work for me ( http://www.utplsql.org/utPLSQL/latest/userguide/coverage.html):

exec ut.run(ut_varchar2_list('BUSINESS_LOGIC'), ut_coverage_html_reporter());

I simply don't know where I could place the above statement to run the tests, gather the code coverage and report back to DevOps? I thought the command for the appropriate schema must be passed to the utPLSQL-cli?

CodePudding user response:

I noticed that I used an up-to-date version of utPLSQL but not of utPLSQL-cli. Version 3.1.9 now supports a command line parameter to pass a list of coverage schemes: coverage-schemes.

This can be added to the argument list:

$argstr = @("run $db_user/$db_pw@$db_conn", ..., "--coverage-schemes=BUSINESS_LOGIC")

Now the coverage from BUSINESS_LOGIC is retrieved!

  • Related