Unit test success 100% does not work as expected

Hello,

  • SonarQube version: Enterprise Edition Version 7.9.1 (build 27448)

  • steps to reproduce:

  1. Find a Sonar project that has failed Unit Tests
  2. Add new metric to QG - Unit Test Success = 100%
  3. Run Jenkins job
  4. Verify that there are still failed Unit test in SonarQube project
  5. Verify that Quality Gate should be failed

Expected result:
Quality Gate should be failed, because there are failed Unit tests.

Actual result:
Quality Gate is still Passed, even if there are Failed Unit tests.

Hi,

What’s your project’s New Code Period set to? I’m going to guess

  • that it’s previous_version
  • you pass in a full build string as your sonar.projectVersion so that each analysis is a “new version” thus resetting New Code Period each time.

 
Ann

Hi Ann,

Thanks for your answer.
I don’t have much experience in SonarQube, so I actually couldn’t understand how unit test success metric can be related to new code period.
Could you please explain a bit more.

And yes, we use “previous version”.

At the moment we added other metrics to QG, unit test failures =0 and unit test errors=0. And it works fine, QG gets failed.
Just I wonder where we made a mistake with Unit test success metric.

Hi,

Are you saying the Unit tests fail every time, but sometimes the Quality Gate passes even with failed unit tests?

How about some screenshots?

 
Ann

Hi,

yes, there are several Unit tests, that always fail, every build.
As you can see, Quality Gate is failed, just because of one metric - Unit test Failures. But when there was just Unit test success 100%, then Quality Gate was passed, even if there were these 11 Failed unit tests.

Hi,

I’m confused. First I see a Quality Gate that failed for 2 reasons: duplications and unit test failures. Then I see a metric value list from the left side of the Measures page(?). And then I see … your Quality Gate configuration(?).

Everything you’ve shown here works together AFAICT.

 
Ann

As far as I know quality gate should show all failed metrics. In my case it shows, that quality gate is failed because of 2 metrics and one of them is unit test failures. Question, Why it does not show 3rd failed metric for unit test success 100%? I have failed unit tests, so success is not 100%, it should show me how much % I have passed.

And before that our quality gate was configured differently, there was only one metric for unit tests, we used only unit test success 100% and in that case QG was always Passed, like it doesn’t see that this metric even exist in QG.

Another example, maybe it will explain our situation better
Failed but passed

HI,

You don’t need to keep sending me a picture of the Quality Gate each time. I believe that you’re not editing it in between. :smiley:

However, it would be helpful to have a bigger screenshot that includes the Activity log at the bottom of the page. Something like this:

Because that would show whether the Quality Gate being applied in the analysis has changed.

Also, on the Activity page, you should be able to mouseover analyses with failing Quality Gates to see the failing conditions, like so:
Activity - Google Chrome_999(002)

It would be interesting to know whether there are always multiple conditions when the QG does fail, or if it ever fails just for unit test success.

 
Ann

Hi Ann,

Quality Gate fails time by time, but not even one time for Unit test success metric.

Olga

Hi Olga,

Okay! So maybe this metric is just broken, Quality-Gate-wise.

Referring internally…

 
Ann

Hi Ann,

What is the procedure in this case? Will I get info about the progress for this issue?

First time reporting something in this community, that’s why don’t know all the procedures.

Best regards,
Olga

Hi Olga,

I’ve referred this internally. Eventually someone should come back to this thread with a ticket you can watch/vote for.

 
Ann