aconrad / pycobertura

A code coverage diff tool for Cobertura reports
MIT License
114 stars 39 forks source link

It cannot find sources inside other sources #182

Closed nbauma109 closed 5 months ago

nbauma109 commented 5 months ago

The script complained that it couldn't find a source file:

pycobertura.filesystem.FileSystem.FileNotFound: sources_new\com/mycompany/mypackage/SomeEnum.java

It turned out that Enum was declared in another source file:

com/mycompany/mypackage/SomeClass.java

package com.mycompany.mypackage;

enum SomeEnum {

}

public class SomeClass {

}

Unfortunately, this blocks the whole process!

aconrad commented 5 months ago

Can you provide more information about your setup?

nbauma109 commented 5 months ago

I'm currently working on a side project source-extractor to prepare the files to be processed by pycobertura. It's normal that pycobertura doesn't find the class/object definitions that are not defined in their own files, that would require parsing java and scala and I believe it's beyond the scope of pycobertura.

aconrad commented 5 months ago

I'm not sure I understand. But if your project generates cobertura reports when you run your tests, then pycobertura can parse those reports. Accessing the Java source files of your project is necessary if you want pycobertura to generate, say, an HTML report that highlights which source lines are covered or uncovered. Otherwise it's optional but you get less features out of pycobertura.

nbauma109 commented 5 months ago

Yes, I want to generate this html report with the highlights. Unfortunately, this "file not found" error blocks the whole process.

nbauma109 commented 5 months ago

Good news. I managed to generate the html report thanks to the source extractor.