[comixed-dev] Re: Add front code coverage to sonarcloud ?

  • From: Frédéric Fouret <fouretfrederic@xxxxxxxxx>
  • To: comixed-dev@xxxxxxxxxxxxx
  • Date: Mon, 15 Jun 2020 21:25:23 +0200

Very nice :)

Le lun. 15 juin 2020 à 21:16, Darryl L. Pierce <mcpierce@xxxxxxxxx> a
écrit :

That appears to have done the trick! The report are looking even better
now: 2 bugs, 11 vulnerabilities, 142 code smells, 80.4Q% code coverage and
0.8% duplication. Previously it was <30% code coverage, so that's great
that it's now apparently more accurate. :D

On Mon, Jun 15, 2020 at 1:53 PM Darryl L. Pierce <mcpierce@xxxxxxxxx>
wrote:

Trying that now. I didn't realize that the sonary.test.inclusions wasn't
also including the Jasmine tests. So I've added the following changes:

diff --git a/.github/workflows/sonarcloud-analysis.yml
b/.github/workflows/sonarcloud-analysis.yml
index cab0e46c8..b48983b72 100644
--- a/.github/workflows/sonarcloud-analysis.yml
+++ b/.github/workflows/sonarcloud-analysis.yml
@@ -29,8 +29,8 @@ jobs:
           -Dsonar.organization=comixed
           -Dsonar.projectKey=comixed_comixed
           -Dsonar.sources=./src
-          -Dsonar.exclusions=**/*test*/**
-          -Dsonar.test.inclusions=**/*test*/**
+          -Dsonar.exclusions=**/*test*/**,**/*spec.ts
+          -Dsonar.test.inclusions=**/*test*/**,**/*spec.ts
           -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
           -Pci
         env:

Also, I added caching of Maven artifacts to the Github workflows and
that's significantly sped things up as far as builds for PRs and releases
are concerned! :D

On Mon, Jun 15, 2020 at 10:50 AM Frédéric Fouret <
fouretfrederic@xxxxxxxxx> wrote:

Nice :) Thank you for taking time to try this solution.

I think we need just a last modification : spec.ts files are not
excluded from the coverage. I think we need to add the exclusion : 
sonar.exclusions=
**/*.spec.ts with this, global coverage will be more than 60% even 70% ...
:)

Le lun. 15 juin 2020 à 16:24, Darryl L. Pierce <mcpierce@xxxxxxxxx> a
écrit :

Okay, I've added the changes you mentioned and the build looks better.
The report still fails but now it's because of bugs and issues SonarCloud
is reporting that we should probably fix.

On Mon, Jun 15, 2020 at 8:14 AM Darryl L. Pierce <mcpierce@xxxxxxxxx>
wrote:

Good suggestions. I'll try them out on my fork of the project and see
if the coverage gets better.

On Sun, Jun 14, 2020 at 4:10 PM Frédéric Fouret <
fouretfrederic@xxxxxxxxx> wrote:

I'm not a SonarCloud expert (i used it only one time for a school
project). I'm not an expert in front testing too :) But when I see only
29.2% of test coverage and only 551 unit Tests it's frustrating because
there is more than 95% of the front with unit tests.
It's not very important but it's good for the quality image of the
work that's been done.

I've searched for some modification to test.
Actually when the front phase testing is done, it seems there is no
coverage report generated. If we replace in the package.json (in
frontend) "test": "ng test" by "test": "ng test --code-coverage", and if 
we
add in karma.conf.js in coverageIstanbulReporter the line : "dir:
require('path').join(__dirname, '../coverage')," the coverage is 
generated
in html format and in Icov.info format (in a folder
comixed-frontend/coverage).
Now we just need to say to sonar where to find this Icov report.
Seems we just need to add the option
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info to the run
job in sonarcloud-analysis.yml.

As I said, I don't know much about sonarcloud and that's why I don't
make changes directly in the code... Maybe what I'm proposing doesn't 
work
at all... maybe one day you'll have a little time to try and see if these
modifications can solve the lack of front coverage.



Le dim. 14 juin 2020 à 18:21, Darryl L. Pierce <mcpierce@xxxxxxxxx>
a écrit :

I thought it was already in there. At least, it's there enough to
give errors when there's something missing in the froent. For example,  
I
just finished fixing some issues it brought up with the changes I've 
made
for an enhancement to let users see the contents of a comic file's 
archive.

I'm not a SonarCloud expert so am not sure what we can do to make
the testing better. But I'm open to whatever can be done to achieve 
better,
more reliable feedback from it.

On Sun, Jun 14, 2020 at 11:53 AM Frédéric Fouret <
fouretfrederic@xxxxxxxxx> wrote:

Today I went to look at the sonarcloud of the project. We're seeing
weak code coverage and quality gate failed.... It's a pity because 
there is
a lot of testing done on the frontend that is not taken into account.

Can we add frontend code coverage to sonarcloud ?




--
Darryl L. Pierce <mcpierce@xxxxxxxxx>
"Le centre du monde est partout." - Blaise Pascal
"Let's try and find some point of transcendence and leap together."
- Gord Downie



--
Darryl L. Pierce <mcpierce@xxxxxxxxx>
"Le centre du monde est partout." - Blaise Pascal
"Let's try and find some point of transcendence and leap together." -
Gord Downie



--
Darryl L. Pierce <mcpierce@xxxxxxxxx>
"Le centre du monde est partout." - Blaise Pascal
"Let's try and find some point of transcendence and leap together." -
Gord Downie



--
Darryl L. Pierce <mcpierce@xxxxxxxxx>
"Le centre du monde est partout." - Blaise Pascal
"Let's try and find some point of transcendence and leap together." -
Gord Downie



--
Darryl L. Pierce <mcpierce@xxxxxxxxx>
"Le centre du monde est partout." - Blaise Pascal
"Let's try and find some point of transcendence and leap together." - Gord
Downie

Other related posts: