Integrating javascripts unit tests code coverage in MSBuild

Hemendra

I am using Jasmine and Karma for writing unit tests and code coverage. I have created the tasks using Gulp and running them through task runner explorer in VS 2015 update 3.

var gulp = require("gulp");
var Server = require('karma').Server;
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');

gulp.task('unit-tests', function (done) {
    new Server({
        configFile: __dirname + '/karma.conf.js'
    }, done).start();
});

gulp.task('code-coverage', function () {
    return gulp.src('_reports/coverage-javascript.json')
        .pipe(remapIstanbul({
            reports: {
                'json': '_reports/coverage-typescript.json',
                'html': '_reports/html-report'
            }
        }));
});

I want to read the generated html results file, i.e. from _reports/html-report/index.html file during Gated Builds or Nightly builds. I want to use this code coverage to perform certain actions like stopping the build if code coverage is below 80% or when a test failed.

How can I do that?

Hemendra

I have implemented one solution which fails MSBuild whenever any Unit Test failed. Basically I wrote a Custom Target in my project.csproj file which runs after 'CompileTypeScript' target.

<PropertyGroup>
    <CompileDependsOn>
      $(CompileDependsOn);
      GulpBuild;
    </CompileDependsOn>
</PropertyGroup>
<Target Name="GulpBuild" DependsOnTargets="CompileTypeScript">
    <Exec Command="./node_modules/.bin/gulp task-name" />
</Target>

This task will run after Visual studio compiles TS to JS. In build server 'Path' variable is not set for 'gulp', that's why passing the command through node_modules .bin folder.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Integration tests, unit tests and code coverage

From Java

What is a reasonable code coverage % for unit tests (and why)?

From Dev

Incremental code coverage for Python unit tests?

From Dev

Trying to Exclude Unit Tests from Code Coverage

From Dev

Unit Tests coverage in SONARQUBE

From Java

Does Visual Studio have code coverage for unit tests?

From Dev

Jacoco and Unit Tests Code Coverage with android-gradle-plugin >= 1.1

From Dev

How To do code coverage with emma during Android Unit Tests

From Dev

Unit Testing Code Coverage

From Dev

SonarQube 4.4 not displaying cobertura unit tests or code coverage for grails 2.4.3 with spock tests

From Dev

SonarQube 4.4 not displaying cobertura unit tests or code coverage for grails 2.4.3 with spock tests

From Dev

Why Xcode 7 shows around 12% code coverage when there are no unit tests at all?

From Dev

Using Visual Studio to do Code Coverage on gtest unit tests for native VS C++

From Dev

How to exclude Projects with names ending in ".Test" from my code coverage analysis in VS2012 Unit Tests

From Dev

golang code coverage in integration tests?

From Dev

Jacoco coverage of unit test code

From Dev

NCrunch Unit testing code coverage

From Dev

NCrunch Unit testing code coverage

From Dev

Code coverage percentage in unit testing

From Dev

Jacoco Unit and Integration Tests coverage - individual and overall

From Dev

Exclude unit tests from coverage in python

From Dev

AngularJS Directives - unit tests Karma coverage

From Dev

Jacoco coverage of unit and integration tests combined with coverageratio

From Dev

Code reusability in unit tests?

From Dev

Integrating JaCoCo, Arquillian and REST Assured brings me a code coverage of 0%

From Dev

Android - Jacoco code coverage ignores Robolectric tests

From Dev

How to see code coverage of Spock tests in Eclipse

From Dev

Coverage metrics do not consider code without tests?

From Dev

Scala: Code coverage for projects with tests in separate modules

Related Related

  1. 1

    Integration tests, unit tests and code coverage

  2. 2

    What is a reasonable code coverage % for unit tests (and why)?

  3. 3

    Incremental code coverage for Python unit tests?

  4. 4

    Trying to Exclude Unit Tests from Code Coverage

  5. 5

    Unit Tests coverage in SONARQUBE

  6. 6

    Does Visual Studio have code coverage for unit tests?

  7. 7

    Jacoco and Unit Tests Code Coverage with android-gradle-plugin >= 1.1

  8. 8

    How To do code coverage with emma during Android Unit Tests

  9. 9

    Unit Testing Code Coverage

  10. 10

    SonarQube 4.4 not displaying cobertura unit tests or code coverage for grails 2.4.3 with spock tests

  11. 11

    SonarQube 4.4 not displaying cobertura unit tests or code coverage for grails 2.4.3 with spock tests

  12. 12

    Why Xcode 7 shows around 12% code coverage when there are no unit tests at all?

  13. 13

    Using Visual Studio to do Code Coverage on gtest unit tests for native VS C++

  14. 14

    How to exclude Projects with names ending in ".Test" from my code coverage analysis in VS2012 Unit Tests

  15. 15

    golang code coverage in integration tests?

  16. 16

    Jacoco coverage of unit test code

  17. 17

    NCrunch Unit testing code coverage

  18. 18

    NCrunch Unit testing code coverage

  19. 19

    Code coverage percentage in unit testing

  20. 20

    Jacoco Unit and Integration Tests coverage - individual and overall

  21. 21

    Exclude unit tests from coverage in python

  22. 22

    AngularJS Directives - unit tests Karma coverage

  23. 23

    Jacoco coverage of unit and integration tests combined with coverageratio

  24. 24

    Code reusability in unit tests?

  25. 25

    Integrating JaCoCo, Arquillian and REST Assured brings me a code coverage of 0%

  26. 26

    Android - Jacoco code coverage ignores Robolectric tests

  27. 27

    How to see code coverage of Spock tests in Eclipse

  28. 28

    Coverage metrics do not consider code without tests?

  29. 29

    Scala: Code coverage for projects with tests in separate modules

HotTag

Archive