Page 1 of 1

JSCoverage with JSUnit

Posted: 2009-04-03 8:53 pm
by lowerEastSide
Hello,
I want to run JSUnit on jscoverage instrumented code. My .js files are in c:/ my .html files which using .js files are in D:/

Can I use jscoverage-server for this operation. I want to store coverage report in an html file. I am asking if relative paths ok inside instrumented js files.

Thanks,
LowerEastSide

Re: JSCoverage with JSUnit

Posted: 2009-04-03 9:09 pm
by Ed
Do you have a reference to the C: drive hard-coded in your HTML files, like this?

Code: Select all

<script src="file:///C:/script.js"></script>
If so, you will not get any code coverage statistics, because your HTML files will always be referring to the un-instrumented code.

Re: JSCoverage with JSUnit

Posted: 2009-04-03 9:54 pm
by lowerEastSide
Hello,

I am able to run JSUnit with Instrumented Code. While JSUnit suite is running I see "Coverage" button on the IE. If I click that button a new IT window pops up and I could see the coverage data. What can I do to make sure after the test is run coverage data is stored in an HTML file.

Thanks,
LowerEastSide

Re: JSCoverage with JSUnit

Posted: 2009-04-04 1:47 am
by Ed
Are you using the jscoverage-server.exe program now? Or are you using the jscoverage.exe program to create instrumented files?

Re: JSCoverage with JSUnit

Posted: 2009-04-06 2:18 pm
by lowerEastSide
Hello, I am using jscoverage.exe to instrument files and then running jsunit on that.

Re: JSCoverage with JSUnit

Posted: 2009-04-06 3:26 pm
by Ed
In order to save a coverage report, you will have to use jscoverage-server.exe instead of jscoverage.exe.

In order for this to work, you will have to access all your files via jscoverage-server - e.g., you can't have any references to file:/// URLs hard-coded in your HTML.

Re: JSCoverage with JSUnit

Posted: 2009-04-06 3:31 pm
by lowerEastSide
Hello,

Can you please point out to an example where JSUnit works with jscoverage-server.exe?

Please tell me if the following steps good

a) Copy all .js files inside jscoverage-server
b) start jscoverage-server.exe
c) change html files to get .js files from jscoverage-server
d) run jsunit and do coverage-report()

Regards,
LowerEastSide

Re: JSCoverage with JSUnit

Posted: 2009-04-06 3:48 pm
by Ed
lowerEastSide wrote:Hello,

Can you please point out to an example where JSUnit works with jscoverage-server.exe?
There is an example for JSUnit in the doc/example-jsunit directory of the JSCoverage distribution. You can run this:

Code: Select all

jscoverage-server.exe --verbose --document-root=doc/example-jsunit
Then visit the URL in your browser

Code: Select all

http://127.0.0.1:8080/jsunit/testRunner.html?testPage=http://127.0.0.1:8080/test.html&autoRun=true
lowerEastSide wrote: Please tell me if the following steps good

a) Copy all .js files inside jscoverage-server
b) start jscoverage-server.exe
c) change html files to get .js files from jscoverage-server
d) run jsunit and do coverage-report()
That looks about right ... are there any differences between what you are doing and the doc/example-jsunit example?

Re: JSCoverage with JSUnit

Posted: 2009-04-06 3:57 pm
by lowerEastSide
The only difference is that in the example-jsunit both html and .js files are inside doc-root for jscoverage-server where as in my case they both are outside.. So I will be copying .js files and update html to reference them. Then I can run jsunit and add coverage-report button on jsunit testRunner.html.

Thanks Ed

Regards,
LowerEastSide

Re: JSCoverage with JSUnit

Posted: 2009-04-06 4:06 pm
by lowerEastSide
Hello ED,

Another Question.

Should I have both .html files and .js files under jscoverage-server doc_root or only placing .js files are sufficient ?

Regards,
LES

Re: JSCoverage with JSUnit

Posted: 2009-04-06 4:31 pm
by Ed
I'm not sure if that arrangement will work - it may generate security warnings from your browser - I would recommend serving everything through jscoverage-server.