tntim96 / JSCover

JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
GNU General Public License v2.0
399 stars 84 forks source link

How to measure JavaScript code coverage using JSCover & with Selenium UI tests? #185

Closed montoyo4me closed 9 years ago

montoyo4me commented 9 years ago

Hi Tim,

Below is my scenario,

  1. I am having FitNesse UI test cases developed using Java (eClipse) & Selenium libraries
  2. tomcat is running on a linux box
  3. From my windows box I want to run these fitnesse UI test cases which will run in any of the browser and generate code coverage report.

I am looking for is a step by step instruction to generate JS code coverage. Any help will be deeply appreciated. I went through http://tntim96.github.io/JSCover/ for this but couldn't make out perfect solution or rather I confused.

Thanks

tntim96 commented 9 years ago

I don't know to much about FitNesse. I'll take a look but it might be worth posting a question on that project.

montoyo4me commented 9 years ago

With command line I can execute these FitNesse test cases.

montoyo4me commented 9 years ago

Hi tntim96,

Have you got a chance to work on this?

tntim96 commented 9 years ago

I haven't had time to check out FitNesse in detail, but I think the key is to instrument the JS before running the tests, use JSCover's HTML5 localStorage to save coverage between page loads, and put a hook in at the end of your test to save the coverage data.

Take a look at the localStorage-file-system example.

bianxirui commented 9 years ago

If the web could not work well locally to be instrumented before running the test, what's the alternative choice?

tntim96 commented 9 years ago

I'm not sure what you mean. If you are limited to testing on a server, instrumenting the JS before-hand is generally the best choice.