2
votes

We have huge E2E test cases with Protractor for our Angular App. Can anyone suggest how we can calculate the Coverage for these test cases?

P.S: They are separated from the code and are more into E2E and Selenium-based. Please pardon if a noob question.

2

2 Answers

0
votes

There is a Grunt plugin grunt-protractor-coverage which provides code coverage metrics for Protractor tests.

If you are using Angular CLI, code coverage for Protractor isn't supported out of the box yet. There is a feature request to add code coverage for e2e tests here

Unfortunately, as your product code and test code don't occupy the same code base, generating code coverage automatically will be difficult.

An alternative to code coverage for e2e tests is functional/feature coverage. This can be achieved by determining the number of user functions/features your application has and how many of those functions/features are covered by an e2e test. It is then possible to calculate the percentage of functions/features covered. I'm not aware of an automated tool which will do this however.

0
votes

I have managed to get the e2e coverage by pre-instrumenting the code with Istanbul/nyc and then downloading the coverage info via protractor. You can find a sample solution here: https://github.com/edvlucas/angular-e2e-coverage