Hi Mark/Evegeny,
below is the entire code, test code and Report in github link. Please look 
into it and let me know what i am missing.

https://github.com/sabyasachimishra/jacocopoc

Thanks in advance.

Thanks and Regards,
Sabyasachi Mishra

git hub link for code <https://github.com/sabyasachimishra/jacocopoc>



On Monday, 12 February 2018 15:02:49 UTC+5:30, Sabyasachi Mishra wrote:
>
> Hi Mark,
> I ran this command also.
>
> java -jar /Users/sabyasachi/Documents/JacocoJars/jacococli.jar report 
> /Users/sabyasachi/Documents/jacoco.exec --classfiles 
> /Users/sabyasachi/eclipse-workspace5/JACPOC/build/classes/com/math/pkg/MathTest.class
>  
> --html /Users/sabyasachi/Desktop/Rep1 --name jacocoReport --sourcefiles 
> /Users/sabyasachi/eclipse-workspace5/JACPOC/src/com/math/pkg/MathTest.java
>
> still same.
>
> Thanks and regards,
> Sabyasachi Mishra
>
> On Monday, 12 February 2018 11:52:58 UTC+5:30, Marc R. Hoffmann wrote:
>>
>> Hi Sabyasachi,
>>
>> one problem is with your parameter
>>
>> --sourcefiles /Users/sabyasachi/Documents/MathTest.java
>>
>> Please specify a directory here, which is the root of your java package 
>> structure. See FAQ <http://www.jacoco.org/jacoco/trunk/doc/faq.html>:
>> Why does the coverage report not show highlighted source code? 
>>
>> Make sure the following prerequisites are fulfilled to get source code 
>> highlighting in JaCoCo coverage reports:
>>
>>    - Class files must be compiled with debug information to contain line 
>>    numbers. 
>>    - Source files must be properly supplied at report generation time. 
>>    I.e. specified source folders must be the direct parent of the 
>>    folders that define the Java packages. 
>>
>> Regards,
>> -marc
>>
>>  
>>
>>  
>>
>>  
>>
>> On 2018-02-12 07:00, Sabyasachi Mishra wrote:
>>
>> Hi Evgeny, 
>> I have tried that. I am still getting stuck at the same point. 
>>  
>> So I made a poc. sharing all the steps and code with you. In the poc I am 
>> still getting stuck at the same point.
>>  
>> 1. Created a war file. put the war file in the webapps directory of 
>> tomcat.
>> 2. Then added the jacoco agent in tomcat in catalena.sh file in under 
>> JAVA_OPTS.
>>
>>
>> -javaagent:/Users/sabyasachi/Documents/JacocoJars/jacocoagent.jar=output=file,destfile=/Users/sabyasachi/Documents/jacoco.exec,dumponexit=true,includes=*,classdumpdir=/Users/sabyasachi/Documents/cla,append=false
>>
>>  
>> 3.  Then started the server.
>> 4. Created a small selenium webdriver suite and ran against the website.
>> 5. After the tests are completed I have stopped the tomcat server.
>> 6. Jacoco.exec file is generated.
>> 7. Then I ran the following command to generate the report.
>>  
>>
>> java -jar /Users/sabyasachi/Documents/JacocoJars/jacococli.jar report 
>> /Users/sabyasachi/Documents/jacoco.exec --classfiles 
>> /Users/sabyasachi/Documents/MathTest.class --html 
>> /Users/sabyasachi/Desktop/Rep1 --name jacocoReport --sourcefiles 
>> /Users/sabyasachi/Documents/MathTest.java
>>
>>  
>> 8. But still I am not able to generate the highlighted source code.
>>  
>> I am sharing the code war file and report.
>> Can you please look into this and tell me what I am doing wrong.
>>  
>> Thanks and Regards,
>> Sabyasachi Mishra
>>
>> On Wednesday, 24 January 2018 21:20:58 UTC+5:30, Evgeny Mandrikov wrote: 
>>>
>>> First make sure that you did clean build and classes were really 
>>> recompiled after your change.
>>>  
>>> Then lets verify that your changes do actually change result of 
>>> compilation - execute javap on BuyerViewGenerator (class from your 
>>> screenshot) as:
>>>  
>>> javap -v -p classes/package/name/of/BuyerViewGenerator.class
>>>  
>>> If you see occurrences
>>>  
>>> Compiled from "BuyerViewGenerator.java"
>>>  
>>> and
>>>  
>>> LineNumberTable
>>>  
>>> Then indeed this class file contains required debug information.
>>>  
>>> After that make sure that
>>>  
>>> classes/*package/name/of*/BuyerViewGenerator.class
>>>  
>>> has corresponding source file in a correct place
>>>  
>>> src/main/java/*package/name/of*/BuyerViewGenerator.java
>>>  
>>> After that make sure that you re-run your tests and 
>>> regenerated jacoco.exec , because otherwise generation of report produces 
>>> warning
>>>  
>>> [WARN] For report generation the same class files must be used as at 
>>> runtime.
>>>  
>>> and such classes are not linked with their sources. Rephrasing a bit - 
>>> make sure that you don't have warnings during generation of report.
>>>  
>>>
>>> On Wednesday, January 24, 2018 at 3:57:39 PM UTC+1, Sabyasachi Mishra 
>>> wrote: 
>>>>
>>>> Hi Evgeny, 
>>>> I have made changes to pom.xml as suggested. But still I am not able to 
>>>> see highlighted source code. Instead I can only see function.
>>>>  
>>>> Changes in POM:
>>>>
>>>>  <plugin>
>>>>
>>>>                                 
>>>> <groupId>org.apache.maven.plugins</groupId>
>>>>
>>>>                                 
>>>> <artifactId>maven-compiler-plugin</artifactId>
>>>>
>>>>                                 <configuration>
>>>>
>>>>                                         <source>1.8</source>
>>>>
>>>>                                         <target>1.8</target>
>>>>
>>>>                                         <debug>true</debug>
>>>>
>>>>                                 </configuration>
>>>>                         </plugin>
>>>>  
>>>> Attaching the screenshots of report.
>>>>  
>>>> Regards,
>>>> Sabyasachi Mishra 
>>>>
>>>> On Wednesday, 24 January 2018 14:24:03 UTC+5:30, Evgeny Mandrikov 
>>>> wrote: 
>>>>>
>>>>> Hi,
>>>>>  
>>>>> According to your first post you have "<debuglevel>lines</debuglevel>" 
>>>>> , which I believe translates into "javac -glines" , so that it will 
>>>>> preserve line numbers in class files, but not names of source files, 
>>>>> because last one requires "javac -glines,source" or "javac -g" - see 
>>>>> https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html 
>>>>> Therefore either set "<debuglevel>lines,source</debuglevel>", or 
>>>>> completely remove "<debuglevel>", last case together with 
>>>>> "<debug>true</debug>" is equivalent to "javac -g" i.e. all debug 
>>>>> information will be included.
>>>>>
>>>>> On Wednesday, January 24, 2018 at 9:05:51 AM UTC+1, Sabyasachi Mishra 
>>>>> wrote: 
>>>>>>
>>>>>> Hi Marc, 
>>>>>> This check is positive. But I still can't generate report with 
>>>>>> highlighted source code.
>>>>>> Sorry I cannot share any class files.
>>>>>> Can you please suggest any alternate approach?
>>>>>>  
>>>>>> Thanks and Regards,
>>>>>> Sabyasachi Mishra
>>>>>>
>>>>>> On Tuesday, 23 January 2018 21:52:57 UTC+5:30, Marc R. Hoffmann 
>>>>>> wrote: 
>>>>>>>
>>>>>>> Ok, this means your class files are compiled with debug information.
>>>>>>>
>>>>>>> Did you double check that your source files are available at the 
>>>>>>> location you provided?
>>>>>>>
>>>>>>>   --sourcefiles Path/src/main/java
>>>>>>>
>>>>>>> Note that this path needs to point to the parent folder of the Java 
>>>>>>> package hierarchy. E.g. if you have a class com.example.Foo the source 
>>>>>>> file 
>>>>>>> has to be in this folder:
>>>>>>>
>>>>>>>   Path/src/main/java/com/example/Foo.java
>>>>>>>
>>>>>>> If this check is positive can you please share one of your class 
>>>>>>> file?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> -marc
>>>>>>>
>>>>>>>  
>>>>>>>
>>>>>>>  
>>>>>>>
>>>>>>>  
>>>>>>>
>>>>>>>  
>>>>>>>
>>>>>>>  
>>>>>>>
>>>>>>> On 2018-01-23 16:46, Sabyasachi Mishra wrote:
>>>>>>>
>>>>>>> Hi Marc, 
>>>>>>> My HTML report shows a column called lines. Attaching the screenshot.
>>>>>>>  
>>>>>>>  
>>>>>>> Thanks and Regards,
>>>>>>> Sabyasachi Mishra
>>>>>>>
>>>>>>> On Tuesday, 23 January 2018 18:57:01 UTC+5:30, Marc R. Hoffmann 
>>>>>>> wrote: 
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> does your generated HTML report show a column called "Lines"? If 
>>>>>>>> not, the class files do not contain debug information.
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> -marc
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> On 2018-01-23 14:01, Sabyasachi Mishra wrote:
>>>>>>>>
>>>>>>>> HI Team, 
>>>>>>>>  
>>>>>>>> I am trying to compute code coverage for a build hosted in tomcat. 
>>>>>>>> I am following the below steps.
>>>>>>>>  
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> 1.     Added Java agent with Jacocoagent.jar in tomcat.conf file 
>>>>>>>> under JAVA_OPTS 
>>>>>>>>
>>>>>>>>
>>>>>>>> *javaagent:/opt/jacoco/lib/jacocoagent.jar=destfile=/opt/jacoco/Result/jacoco.exec,classdumpdir=/opt/jacoco/Result/classes,append=false,includes=**
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> 2.     Started Tomcat.
>>>>>>>>
>>>>>>>> 3.     Ran tests.
>>>>>>>>
>>>>>>>> 4.     After tests are complete stoped the tomcat in order to 
>>>>>>>> generate the .exec file.
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> 5.     Keep class files which I wanted to instrument in one place 
>>>>>>>> along with the exec file.
>>>>>>>>
>>>>>>>> 6.     Now ran the report generation command 
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> java -jar Path/jacococli.jar report Path/jacoco.exec --classfiles 
>>>>>>>> Path/classes --html Path/Report --name jacocoReport --sourcefiles 
>>>>>>>> Path/src/main/java
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> Now I am able to generate HTML report. *But not able to see the 
>>>>>>>> highlighted source code*. But from the report I can see the 
>>>>>>>> functions under the classes.
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> For adding debugging info to the class I have added below code to 
>>>>>>>> maven's pom.xml
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>> <plugin>
>>>>>>>>
>>>>>>>> <groupId>org.apache.maven.plugins</groupId>
>>>>>>>>
>>>>>>>> <artifactId>maven-compiler-plugin</artifactId>
>>>>>>>>
>>>>>>>> <configuration>
>>>>>>>>
>>>>>>>> <source>1.8</source>
>>>>>>>>
>>>>>>>> <target>1.8</target>
>>>>>>>>
>>>>>>>> <debug>true</debug>
>>>>>>>>
>>>>>>>>         <debuglevel>lines</debuglevel>
>>>>>>>>
>>>>>>>> </configuration>
>>>>>>>>
>>>>>>>> </plugin>
>>>>>>>>
>>>>>>>>  
>>>>>>>> Can anyone please tell me what I am missing or what I am doing 
>>>>>>>> wrong.
>>>>>>>>  
>>>>>>>> Thanks in advance.
>>>>>>>>  
>>>>>>>> Regards,
>>>>>>>> Sabyasachi Mishra 
>>>>>>>>
>>>>>>>>  
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "JaCoCo and EclEmma Users" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to [email protected].
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/jacoco/9d440a15-f2d2-49c3-91b8-2af73b0d6700%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/jacoco/9d440a15-f2d2-49c3-91b8-2af73b0d6700%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>>>  
>>>>>>>>
>>>>>>>  
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "JaCoCo and EclEmma Users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected].
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/jacoco/cfeda9f4-d697-49c3-ad08-959bf1e78582%40googlegroups.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/jacoco/cfeda9f4-d697-49c3-ad08-959bf1e78582%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>>  
>>>>>>>
>>>>>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/3fdac41d-b31c-48ad-b2ef-4a7899bb378d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/3fdac41d-b31c-48ad-b2ef-4a7899bb378d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>  
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/2828fc57-bd0a-4c14-8f47-aae0e57aaaf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to