Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

OpenCover report
simongh
#1 Posted : Tuesday, January 10, 2023 12:52:15 PM(UTC)
Rank: Member

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 21
Location: United Kingdom

I'm trying to use the data generated by NCrunch with SonarCloud. Are tests are written in XUnit the build is being run by TeamCity.

I can feed it the test results in NUnit format report & it seems happy with that. When I try to feed it the OpenCover.xml report, I get errors about the line number. It seems like an off-by-one error.

For example, this:

Code:

ERROR: Error during SonarScanner execution

12:30:34 
  INFO: ------------------------------------------------------------------------

12:30:34 
  java.lang.IllegalStateException: Line 162 is out of range in the file project/myclass.cs (lines: 161)


Any idea why this might be?
Remco
#2 Posted : Tuesday, January 10, 2023 11:19:46 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,696

Thanks: 880 times
Was thanked: 1196 time(s) in 1116 post(s)
Hi, thanks for sharing this.

Are you able to share the source file and export file with me? (you can upload them through the contact form).

I don't have a way to verify or troubleshoot the behaviour of SonarScanner but I can check to see whether the details in the export file are correct.
simongh
#3 Posted : Wednesday, January 11, 2023 9:59:29 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 21
Location: United Kingdom

That would be helpful. I'm not entirely sue what I am looking for in the opencover xml and it's a big file.
Remco
#4 Posted : Wednesday, January 11, 2023 11:02:46 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,696

Thanks: 880 times
Was thanked: 1196 time(s) in 1116 post(s)
Thanks for sending through the details. I've examined the export file in the context of the source it was generated from. To my knowledge, the export file appears to be correct and without problems. I note the following sequence points that are shown in the file for the source file triggering the error:

Code:

<SequencePoints>
<SequencePoint vc="1" uspid="8501" ordinal="0" offset="0" sl="8" sc="3" el="8" ec="39" bec="0" bev="0" fileid="615" />
<SequencePoint vc="1" uspid="8502" ordinal="1" offset="7" sl="9" sc="3" el="9" ec="4" bec="0" bev="0" fileid="615" />
<SequencePoint vc="1" uspid="8503" ordinal="2" offset="8" sl="10" sc="4" el="11" ec="17" bec="0" bev="0" fileid="615" />
<SequencePoint vc="1" uspid="8504" ordinal="3" offset="77" sl="13" sc="4" el="16" ec="81" bec="0" bev="0" fileid="615" />
<SequencePoint vc="1" uspid="8505" ordinal="4" offset="166" sl="18" sc="4" el="19" ec="17" bec="0" bev="0" fileid="615" />
<SequencePoint vc="1" uspid="8506" ordinal="5" offset="235" sl="20" sc="3" el="20" ec="4" bec="0" bev="0" fileid="615" />
</SequencePoints>


Note the 'sl' and 'el' (start line and end line) do not include line 23, which is specified in the error given by SonarScanner. NCrunch makes no reference to this line. However, I did notice something else interesting.

There is another method defined in the export file which has a sequence point ID that is equal to the file ID of the source file mentioned by the error message:

Code:

<SequencePoint vc="0" uspid="615" ordinal="1" offset="1" sl="23" sc="4" el="23" ec="38" bec="0" bev="0" fileid="200" />


This method makes reference to line 23, which is perfectly valid for the method in which it refers. But it makes me suspect that there may be an issue here with how SonarScanner is parsing these IDs.

The root problem here is that the partcover export file format isn't really a published format or standard - it's just a file that gets output from another tool. We have to guess at what these fields mean, and I suppose for the developers of SonarScanner, it's the same.

My understanding is that the 'uspid' field represents the sequence point ID as specified in the assembly's PDB file. I recommend raising a support request with the developers of SonarScanner to establish their thoughts on this.
simongh
#5 Posted : Thursday, January 12, 2023 10:00:14 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/20/2017(UTC)
Posts: 21
Location: United Kingdom

Thanks for your help. Your comments around partcover reinforce what I was thinking. OpenCover has been retired, as it's not really supported any more. I had considered seeing about getting coverlet working. It's just convenient that NCrunch generates the file.

I'll get in touch with Sonar & see if they have any comments.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.037 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download