Re: Coverage of angular e2e tests

414 views
Skip to first unread message

Vojta Jína

unread,
Feb 12, 2013, 7:51:00 PM2/12/13
to testa...@googlegroups.com
The coverage is for unit tests. All the source files need to be instrumented (that's why you have coverage preprocessor). When you run e2e tests, your app files are served by your web server, testacular only proxies it.

It might be a feature - allow processing even proxied stuff, however I don't have time for it (it's not a priority).

V.


On Mon, Feb 11, 2013 at 11:07 AM, <shah...@gmail.com> wrote:
Hey guys,

I've got the following testacular e2e conf file:

// Sample Testacular configuration file, that contain pretty much all the available options
// It's used for running client tests on Travis (http://travis-ci.org/#!/vojtajina/testacular)
// Most of the options can be overriden by cli arguments (see testacular --help)


// base path, that will be used to resolve files and exclude
basePath = '../'

// list of files / patterns to load in the browser
files = [
    //ANGULAR_SCENARIO,
    'test/lib/angular/1.1.2/angular-scenario.js',
    ANGULAR_SCENARIO_ADAPTER,
    'test/common/js/angular-scenario.dsl.js',
    'test/common/js/angular-scenario.matchers.js',
    //'test/e2e/**/*.js',

    // home module
    'home/js/app.js',
    'home/js/controllers.js',

    // action (helper) files
    'test/ui/home/actions/client.actions.js',

    // test scenarios
    'test/ui/login/tests/login.tests.js',
    'test/ui/home/tests/homepage.tests.js',
    'test/ui/home/tests/client.tests.js',
    'test/ui/login/tests/logout.tests.js'
];

// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;

// Auto run tests on start (when browsers are captured) and exit
singleRun = true;


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari
// - PhantomJS
browsers = ['Chrome'];

proxies = {
};

reporters = ['coverage'];

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 25000;

preprocessors = {
    '**/home/js/*.js': 'coverage'
};

coverageReporter = {
    type : 'html',
    dir : 'test/coverage/'
};

And a coverage report is generated, but essentially nothing is actually covered. Is code coverage not supported for angular-scenario / e2e, or am I doing something wrong?

File
Statements
Branches
Functions
Lines
app.js 66.67% (2 / 3) 100.00% (0 / 0) 0.00% (0 / 1) 66.67% (2 / 3)
controllers.js 2.71% (8 / 295) 0.00% (0 / 97) 0.00% (0 / 68) 2.71% (8 / 295)

--
You received this message because you are subscribed to the Google Groups "testacular" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testacular+...@googlegroups.com.
To post to this group, send email to testa...@googlegroups.com.
Visit this group at http://groups.google.com/group/testacular?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

aric...@sqli.com

unread,
Sep 11, 2013, 11:12:28 AM9/11/13
to karma...@googlegroups.com, testa...@googlegroups.com
Hi,

Is there some update on this ?

I saw this merged PR: https://github.com/karma-runner/karma-ng-scenario/pull/7
So, I tried to get code coverage from my e2e tests, without success.

I'm using Karma 0.10.2.
And this config :

           frameworks: ['ng-scenario'],

        files: [
            'src/test/javascript/e2e/**/*.js',
            'src/main/javascript/**/*.js'
        ],

        reporters: ['junit', 'coverage'],

        preprocessors: {
            'src/main/javascript/**/*.js': 'coverage'
        },

        coverageReporter: {
            type: 'lcov',
            dir: 'target/coverage/e2e/'
        },


Any hints ?
Has anyone managed to get coverage with e2e tests ?


Thanks,
Antoine

Vojta Jína

unread,
Sep 11, 2013, 8:33:06 PM9/11/13
to karma...@googlegroups.com
The problem is, that if you wanna get coverage out of the e2e test, you need to instrument the app files. These files are served by your web server, which Karma only proxies to. So you need to instrument these files (using istanbul) on your own.

V.


--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.

aric...@sqli.com

unread,
Sep 12, 2013, 4:52:47 AM9/12/13
to karma...@googlegroups.com
Thanks for this clarification, Vojta.

Antoine

jianb...@gmail.com

unread,
Oct 31, 2013, 1:43:30 AM10/31/13
to karma...@googlegroups.com, testa...@googlegroups.com, aric...@sqli.com
Hi antoine, 

i'm working on a Angular project which also need end2end coverage, i saw your post, did you find a good way to measure the coverage? 
Could you mind give me some solution you did? i'll very appreciate for that.

thanks,
Jack

aric...@sqli.com

unread,
Oct 31, 2013, 12:31:13 PM10/31/13
to karma...@googlegroups.com, testa...@googlegroups.com, aric...@sqli.com, jianb...@gmail.com
Hi Jack,

Sorry I won't be very helpful. I haven't worked on this task since. (greater priorities had arrived in my backlog...). I hope I'll have time to investigate into this soon (maybe when migrating my projects to Protractor).

What Vojta says is that your application code (served by your server, and tested by your e2e tests) must already be instrumented.
See the Istanbul documentation for instrumentation API : http://gotwarlost.github.io/istanbul/public/apidocs/classes/Instrumenter.html

Please, keep us posted with your progress.
Antoine
Reply all
Reply to author
Forward
0 new messages