utPLSQL / utPLSQL-maven-plugin

Maven plugin for running Unit Tests with utPLSQL v3
Apache License 2.0
13 stars 10 forks source link

Maven utplsql plugin creates empty code coverage report #46

Closed sak-82 closed 4 years ago

sak-82 commented 4 years ago

I'm using utplsql 3.1.3 version and tried to use maven utplsql plugin for CI in jenkins. Though I could run the test and produce test report, i could not get code coverage report. Can you help on this ?

jgebal commented 4 years ago

We can. But first help us by providing come details. your pom config (especially reporters section)

Can you produce coverage usin utplsql-cli or by running utplsql from an IDE like SQLDeveloper?

What output are you getting when runing mvn?

sak-82 commented 4 years ago

Yes, I could produce code coverage using SQL developer and i don't have utplsql-cli installed n my machine. While running n mvn, i get empty coverage report with just the html tags.

Below is the reporter section in my pom file

<reporters><reporter> <name>UT_COVERAGE_SONAR_REPORTER</name> <fileOutput>utplsql/coverage-sonar-reporter.xml</fileOutput> <consoleOutput>true</consoleOutput> </reporter> <reporter> <name>UT_SONAR_TEST_REPORTER</name> <fileOutput>utplsql/sonar-test-reporter.xml</fileOutput> <consoleOutput>false</consoleOutput> </reporter> </reporters>

jgebal commented 4 years ago

Do you use the same user to connect via SQLDeveloper and Maven? Do you run the same set of unit tests?

When running coverage with maven, do you provide file-mapping for your project?

Can you try running maven with debug enabled and provide full output from maven console (you can hide sensitive data like username/pass/db_name etc.)

sak-82 commented 4 years ago

I run both maven and IDE commands with same user. I did tried providing file mapping for DB objects as well. I attached all logs n below repos, can u check ? https://github.com/sak-82/utplsql-maven-plugin

jgebal commented 4 years ago

Did you try to run maven without file-mapping? If you don't provide sources/tests path as well as mappings, your coverage should be object-based.

I suspect that your regular expression might be wrong.

It all comes down to how your directory structure is organized and what file extensions are you using.

Your regex says <sourcesRegexExpression>\\((\w+)\.)?(\w+)\.(\w{3})$</sourcesRegexExpression> and the matching group for object type is: <sourcesTypeSubexpression>1</sourcesTypeSubexpression>

So you're saying that your object type is this part of regex ((\w+))\.) - the regex part in very first brackets.

Now. given that, you didn't provide any type mapping. The type mapping is described here

The way I solve this is:

Here are few links to regex101.com with examples (from documentation). https://regex101.com/r/0lk0rV/1/ https://regex101.com/r/Vd97v0/1 https://regex101.com/r/4qP6Aj/3

sak-82 commented 4 years ago

Thanks for the help, indeed updating regex and pom properties helped in solving the issue. I am able to see coverage and test execution results in sonarqube now.