Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exclude set of Procs From Code Coverage report #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ntubati opened this issue May 2, 2025 · 3 comments
Open

Exclude set of Procs From Code Coverage report #1302

ntubati opened this issue May 2, 2025 · 3 comments

Comments

@ntubati
Copy link

ntubati commented May 2, 2025

Describe the bug
I have package that has 11 functions .
I am trying to get the sonar coverage report for this and when I run

When I run the below command I am getting the coverage report all on the lines one code. I only wrote test cases for 2 procs and sonar report is showing 2.5% coverage
utplsql run -c "apps/****@db" -p="apps.TEST_XXGCO_BRIDGE_SAAS_INTG_PKG" -f=ut_coverage_sonar_reporter -o="utplsql_coverage.xml" --coverage-schemes=APPS -include=APPS.XXGCO_BRIDGE_SAAS_INTG_PKG

I am trying to exclude the other procs except the two procs that i wrote test cases. I tried to exclude one proc with following command

utplsql run -c "apps/****@db" -p="apps.TEST_XXGCO_BRIDGE_SAAS_INTG_PKG" -f=ut_coverage_sonar_reporter -o="utplsql_coverage.xml" --coverage-schemes=APPS -include=APPS.XXGCO_BRIDGE_SAAS_INTG_PKG -exclude=APPS.XXGCO_BRIDGE_SAAS_INTG_PKG.PROCESS_SALES_ORDER_EXTRACT

But it is giving me blank coverage report like below

Provide version info

Running on utPLSQL v3.1.14.4197

utPLSQL-cli 3.1.9.local

utPLSQL-java-api 3.1.9.local

Java-Version: 1.8.0_431

ORACLE_HOME: null

NLS_LANG: null

Thanks for testing!


**Information about client software**
What client was used to run utPLSQL tests? Was it from TOAD, SQLDeveloper, SQLPlus, PLSQL Developer etc...

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Example code**
If applicable, add sample code to help explain your problem.
Please avoid putting your company private/protected code in an issue, as it might violate your company's privacy and security policies.

**Additional context**
Add any other context about the problem here.
@jgebal
Copy link
Member

jgebal commented May 2, 2025

Hello @ntubati

The code coverage is a metric that indicates the percentage of code that is executed during a test run.
You can read more about this for example here.

utPLSQL provides line coverage and a block coverage (branches per line of code).
The coverage is calculated at the level of compiled unit of code (package/procedure/function./trigger).

It is not possible to exclude/include individual functions of a single package from a coverage report.

That would also be very much confusing as the percentage of coverage is presented for the whole compiled program unit (package) not for the fragments of that program unit.

I am not sure what is the goal that you are trying to achieve.

In my opinion, since the coverage report says that 2.5% of code is covered with tests, than it is clear that the remaining part is not tested.
This is perfect as it allows you to see the progress of coverage increasing as you write tests to cover the rest of the functionality of the package.

@ntubati
Copy link
Author

ntubati commented May 2, 2025

Thanks for the detailed reply. We have never done unit testing cover for PLSQL in our application and we have lot of legacy code. we are planning to start using this and doing a poc. One of the ask is to see how we can calculate the code coverage only for incremental code not for the legacy code. I guess in this case first we have to upload as is code coverage which will show 0 and then look for coverage for incremental code.

Ba based on what you explained , if i have custom package procedure which calls the standard oracle procedure , I can't exclude it from coverage report , but i can exclude it from testing?

@jgebal
Copy link
Member

jgebal commented May 3, 2025

You can exclude separate units of compiled code.
So you can exclude packages, standalone procedures and standalone functions.

I suspect that you do not change oracle supplied packages by adding your custom code into their program units.
If you do I would be very concerned.

So you should be able to exclude program units that you do not own and only measure coverage on program units that you own and are responsible for.

I hope this answers your questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants