JSCoverage with JSUnit

Questions, problems, suggestions, bug reports, and so on.
Post Reply
lowerEastSide

JSCoverage with JSUnit

Post by lowerEastSide » 2009-04-03 8:53 pm

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

Ed
Posts: 120
Joined: 2008-10-11 6:52 pm

Re: JSCoverage with JSUnit

Post by Ed » 2009-04-03 9:09 pm

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.

lowerEastSide

Re: JSCoverage with JSUnit

Post by lowerEastSide » 2009-04-03 9:54 pm

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

Ed
Posts: 120
Joined: 2008-10-11 6:52 pm

Re: JSCoverage with JSUnit

Post by Ed » 2009-04-04 1:47 am

Are you using the jscoverage-server.exe program now? Or are you using the jscoverage.exe program to create instrumented files?

lowerEastSide

Re: JSCoverage with JSUnit

Post by lowerEastSide » 2009-04-06 2:18 pm

Hello, I am using jscoverage.exe to instrument files and then running jsunit on that.

Ed
Posts: 120
Joined: 2008-10-11 6:52 pm

Re: JSCoverage with JSUnit

Post by Ed » 2009-04-06 3:26 pm

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.

lowerEastSide
Posts: 6
Joined: 2009-04-06 3:19 pm

Re: JSCoverage with JSUnit

Post by lowerEastSide » 2009-04-06 3:31 pm

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

Ed
Posts: 120
Joined: 2008-10-11 6:52 pm

Re: JSCoverage with JSUnit

Post by Ed » 2009-04-06 3:48 pm

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?

lowerEastSide
Posts: 6
Joined: 2009-04-06 3:19 pm

Re: JSCoverage with JSUnit

Post by lowerEastSide » 2009-04-06 3:57 pm

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

lowerEastSide
Posts: 6
Joined: 2009-04-06 3:19 pm

Re: JSCoverage with JSUnit

Post by lowerEastSide » 2009-04-06 4:06 pm

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

Ed
Posts: 120
Joined: 2008-10-11 6:52 pm

Re: JSCoverage with JSUnit

Post by Ed » 2009-04-06 4:31 pm

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.

Post Reply