Closed abhibang closed 7 years ago
If you want to gather code coverage while testing your application on Glassfish (or any server) you can't use the server-mode (i.e. -ws
switch). That is for serving static test files like Jasmine and QUnit.
You can use proxy-mode, but it doesn't work over SSL, and I generally recommend using file-system mode.
To do this you need to (from the top of my head):
There's a working example using this technique in https://github.com/tntim96/JSCover/tree/master/examples/localStorage-file-system
Using JSCover to capture Java Script coverage of my application. Some brief about my application: Our application is not a pure JS application. It has java components on back end.
Currently JS cover is not collecting the reports with below approaches The application war is hosted on web server (Glassfish).
Approach1: To obtain the JS code coverage I've started JS Cover as specified in manual: java -jar target/dist/JSCover-all.jar -ws --document-root= --report-dir=target
Accessed my application url in http://localhost:8080/jscoverage.html
Where in the reports have coverage collected for the demo app.
Approach2: Used and modified WebDriverGeneralProxyTest (added my application url and navigation in @Test shouldRunExampleAndStoreResultProgrammatically) present in https://github.com/tntim96/JSCover-samples to collect the coverage data making selenium to do the navigations.
@Test public void shouldRunExampleAndStoreResultProgrammatically() { deleteJSON("/no-frames"); driver.get("myApplicationUrl"); userLogsInApplication(); doNaviagtion(); ((JavascriptExecutor) driver).executeScript("window.jscoverFinished = false;"); ((JavascriptExecutor) driver).executeScript("jscoverage_report('no-frames', function(){window.jscoverFinished=true;});"); (new WebDriverWait(driver, 10)) .until((ExpectedCondition<Boolean>) d -> (Boolean) ((JavascriptExecutor) driver).executeScript("return window.jscoverFinished;")); verifyCoverage("/no-frames"); }
Please guide me if I'm doing something wrong.