Test Coverage: Coverage report not generating when running unit tests with ZPM
I read a great article by @Timothy Leavitt here, where he wrote about unit testing and test coverage with ZPM. I am facing a slight problem and was wondering if someone has some insight into the matter.
I am running my unit tests in the following way with ZPM, as instructed. They work well and test reports are generated correctly. Test coverage is also measured correctly according to the logs. However, even though I instructed ZPM to generate Cobertura-style coverage reports, it is not generating one. When I run the GenerateReport() method manually, the report is generated correctly.
I tried to add some logging to TestCoverage Manager to see if UserParam property gets populated but it is empty no matter what I try to input to UserParam via ZPM using -D flag.
I am wondering what I am doing wrong. I used the test flags from the ObjectScript-Math repository example, but they seem not to have any effect.
Here is the ZPM command I use to run the unit tests:
zpm "common-unit-tests test -only -verbose -DUnitTest.ManagerClass=TestCoverage.Manager -DUnitTest.JUnitOutput=/opt/iris/test/TestReports/junit.xml -DUnitTest.FailuresAreFatal=1 -DUnitTest.Manager=TestCoverage.Manager -DUnitTest.UserParam.CoverageReportClass=TestCoverage.Report.Cobertura.ReportGenerator -DUnitTest.UserParam.CoverageReportFile=/opt/iris/test/CoverageReports/coverage.xml":1
The test suite runs okay, but coverage reports do not generate. However, when I run these commands stated in the TestCoverage documentation, the reports are generated.
Set reportFile = "/opt/iris/test/CoverageReports/coverage.xml" Do ##class(TestCoverage.Report.Cobertura.ReportGenerator).GenerateReport(<index>, reportFile)
Here is a short snippet from the logs where you can see that test coverage analysis is run:
Collecting coverage data for Test: .036437 seconds Test passed Mapping to class/routine coverage: .041223 seconds Aggregating coverage data: .019707 seconds Code coverage: 41.92% Use the following URL to view the result: http://192.168.208.2:52773/csp/sys/%25UnitTest.Portal.Indices.cls?Index=19&$NAMESPACE=COMMON Use the following URL to view test coverage data: http://IRIS-LOCALDEV:52773/csp/common/TestCoverage.UI.AggregateResultViewer.cls?Index=17 All PASSED [COMMON|common-unit-tests] Test SUCCESS
What am I doing wrong? FYI I am also using the Mocking Framework introduced here. I wonder if it causes any issues?
Thank you, and have a good day!