# Unit Test Success (%) Question

**URL:** <https://community.sonarsource.com/t/unit-test-success-question/103353>\
**Category:** SonarQube Server / Community Build\
**Tags:** cppunit, unit-test\
**Created:** [October 26, 2023, 6:18pm UTC](https://community.sonarsource.com/t/unit-test-success-question/103353 "2023-10-26T18:18:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimSVector](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/timsvector/32/50428_2.png) [@TimSVector](https://community.sonarsource.com/u/TimSVector)\
**Post date:** [October 26, 2023, 6:18pm UTC](https://community.sonarsource.com/t/unit-test-success-question/103353/1 "2023-10-26T18:18:30Z")

</div>

Must-share information (formatted with [Markdown](https://commonmark.org/help/)):

- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)  
SQ version: Version 10.2.1.78527  
SonarScanner 5.0.1.3006  
build-wrapper: version 6.48.1 (win-x86-64), version 6.49 (linux-x86)
- how is SonarQube deployed: zip, Docker, Helm  
Deployed locally
- what are you trying to achieve  
Make sense of unit test metrics
- what have you tried so far to achieve this  
Adding unit tests via cppunit and looking at the history

**Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!**

After import 100+ test cases in cppunit format, i see the passes and fails, but this trend chart for Unit Test Success (%) has a yellow triangle and says “This metric has no historical data to display”

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/3/c/3c25388b0ee213d529e754cec5278a277b59766d.png)

Is the Unit Test Success % not something calculated? If not, where should that success rate come from? I don’t see anything in cppunit specification that allows for passing that data along.

Any help would be greatly appreciated.

Tim

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [October 27, 2023, 3:20pm UTC](https://community.sonarsource.com/t/unit-test-success-question/103353/2 "2023-10-27T15:20:41Z")

</div>

Hi Tim,

This is probably a dumb question, but have you been passing test execution reports into analysis all along, or did that just start?

Also, tangentially, it looks like you’re passing a commit SHA in as your analysis `sonar.projectVersion`? If so,… that’s not the best idea.

Every time the `sonar.projectVersion` string changes, we set an Event on the analysis, which excepts it from [housekeeping](https://docs.sonarsource.com/sonarqube/latest/instance-administration/housekeeping/). And of course, if you’re using a ‘previous version’ New Code definition, then it’s messing up your Quality Gate calculation too.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![TimSVector](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/timsvector/32/50428_2.png) [@TimSVector](https://community.sonarsource.com/u/TimSVector)\
**Post date:** [October 27, 2023, 5:11pm UTC](https://community.sonarsource.com/t/unit-test-success-question/103353/3 "2023-10-27T17:11:37Z")

</div>

Yes I’ve been working on getting VectorCAST Unit Testing results into SonarQube for the weeks I’ve been using SQ 😃 We have a joint customer who is expecting this, so we do the work and ask the questions.

? So should the Unit Test Success (%) be calculated or passed in? If passed in, how?

* * *

I’ll update the projectVersion to not use `git rev-parse HEAD`. I was just sad the see the continued Version Not provided message. I was trying to just solve that. YOu have any suggestions on that?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [October 27, 2023, 5:44pm UTC](https://community.sonarsource.com/t/unit-test-success-question/103353/4 "2023-10-27T17:44:00Z")

</div>

Hi,

I believe Unit Test Success % will be calculated based on your test execution reports. TBH, I’ve never looked closely at this area, but I think test execution reports reflect which tests passed/failed and we do the math.

So assuming you’ve passed in execution reports all this time, you should have a metric history, [like so](https://next.sonarqube.com/sonarqube/project/activity?custom_metrics=test_success_density&graph=custom&id=sonarqube).

 ![Selection_1411](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/e/3/e3dd1c29a14427e6b958280cc4289cf3b92d201b.png)

So let’s back up. If you go to the measures tab, do you have [current values for Unit Test Success](https://next.sonarqube.com/sonarqube/component_measures?metric=test_success_density&id=sonarqube)?

If not, we need to back up further and look at your analysis log.

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

[This guide](https://community.sonarsource.com/t/how-to-find-logs-about-importing-code-coverage/73317) will help you find them.

Regarding project version, the idea is that you would change the value (to the next, upcoming version string) each time you released.

&nbsp;  
Ann
