13 |
<div id="jscoverage-main" class="yui-b"> |
<div id="jscoverage-main" class="yui-b"> |
14 |
<h2><abbr title="Frequently Asked Questions">FAQ</abbr></h2> |
<h2><abbr title="Frequently Asked Questions">FAQ</abbr></h2> |
15 |
|
|
16 |
<h3>Can JSCoverage be used with <a href="http://www.jsunit.net/">JsUnit</a>?</h3> |
<h3>Can I use JSCoverage to measure code coverage for a page on <code>http://<var>example.com</var>/</code>?</h3> |
17 |
|
|
18 |
<p> |
<p> |
19 |
It is necessary to run JSCoverage in <dfn>inverted mode</dfn>. You will have to |
In order to measure the code coverage of a page on <code>http://example.com/</code>, |
20 |
modify JsUnit to launch JSCoverage. |
you must run <code>jscoverage</code> to create a <code>jscoverage.html</code> file on the |
21 |
|
<code>example.com</code> server. You cannot use <code>http://example.org/jscoverage.html</code> |
22 |
|
to measure the code coverage of a page located on <code>http://example.com/</code>. |
23 |
</p> |
</p> |
24 |
|
|
25 |
<p> |
<p> |
26 |
See the directory <code>doc/example-jsunit</code> for an example. It |
The fundamental reason for this limitation is the |
27 |
contains a copy of JsUnit version 2.2alpha11, with the file |
<a href="http://www.mozilla.org/projects/security/components/same-origin.html">Same-Origin Policy</a> |
28 |
<code>jsunit/app/main-data.html</code> slightly modified to add a button |
for untrusted JavaScript. |
|
which launches JSCoverage. It also contains a simple unit test file <code>test.html</code>. You |
|
|
can instrument this example as follows: |
|
29 |
</p> |
</p> |
30 |
|
|
31 |
<pre> |
<p> |
32 |
jscoverage --no-instrument=jsunit doc/example-jsunit doc/instrumented-jsunit |
(In fact, the current version of JSCoverage is slightly more restrictive |
33 |
</pre> |
than this: it requires that the JavaScript being measured reside under the |
34 |
|
same <strong>directory</strong> as the <code>jscoverage.html</code> file.) |
35 |
<p> |
</p> |
|
You can then run the <code>test.html</code> file in JsUnit's <code>jsunit/testRunner.html</code>. |
|
|
The simplest way to do this is probably to copy the contents of <code>doc/instrumented-jsunit</code> |
|
|
to the root of a web server and then access |
|
|
<a href="http://127.0.0.1/jsunit/testRunner.html?testPage=http://127.0.0.1/test.html&autorun=true">this URL</a>. |
|
|
</p> |
|
36 |
|
|
37 |
<h3>I'm trying to load my code with the URL |
<h3>I'm trying to load my code with the URL |
38 |
<code>file:///C:/foo/bar/jscoverage.html?foo/bar.html</code> |
<code>file:///C:/foo/bar/jscoverage.html?foo/bar.html</code> |
65 |
</p> |
</p> |
66 |
|
|
67 |
<p> |
<p> |
68 |
See the discussion <a href="http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/631908bd63241136/783c307480f95d8c">here</a> for more information. |
See <a href="http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/631908bd63241136/783c307480f95d8c">this discussion</a> for more information. |
69 |
</p> |
</p> |
70 |
|
|
71 |
<h3>JSCoverage hangs sometimes when rendering the coverage report.</h3> |
<h3>JSCoverage hangs sometimes when rendering the coverage report.</h3> |
75 |
(More information <a href="http://ajaxian.com/archives/garbage-collection-in-ie6">here</a>.) |
(More information <a href="http://ajaxian.com/archives/garbage-collection-in-ie6">here</a>.) |
76 |
</p> |
</p> |
77 |
|
|
78 |
|
<h3>Can JSCoverage be used with <a href="http://www.jsunit.net/">JsUnit</a>?</h3> |
79 |
|
|
80 |
|
<p> |
81 |
|
It is necessary to run JSCoverage in <dfn>inverted mode</dfn>. You will have to |
82 |
|
modify JsUnit to launch JSCoverage. |
83 |
|
</p> |
84 |
|
|
85 |
|
<p> |
86 |
|
See the directory <code>doc/example-jsunit</code> for an example. It |
87 |
|
contains a copy of JsUnit version 2.2alpha11, with the file |
88 |
|
<code>jsunit/app/main-data.html</code> slightly modified to add a button |
89 |
|
which launches JSCoverage. It also contains a simple unit test file <code>test.html</code>. You |
90 |
|
can instrument this example as follows: |
91 |
|
</p> |
92 |
|
|
93 |
|
<pre> |
94 |
|
jscoverage --no-instrument=jsunit doc/example-jsunit doc/instrumented-jsunit |
95 |
|
</pre> |
96 |
|
|
97 |
|
<p> |
98 |
|
You can then run the <code>test.html</code> file in JsUnit's <code>jsunit/testRunner.html</code>. |
99 |
|
The simplest way to do this is probably to copy the contents of <code>doc/instrumented-jsunit</code> |
100 |
|
to the root of a web server and then access the URL |
101 |
|
</p> |
102 |
|
|
103 |
|
<pre> |
104 |
|
http://127.0.0.1/jsunit/testRunner.html?testPage=http://127.0.0.1/test.html&autoRun=true |
105 |
|
</pre> |
106 |
|
|
107 |
|
<p> |
108 |
|
After the test suite has been run, click on the "Coverage report" button |
109 |
|
to get a coverage report. |
110 |
|
</p> |
111 |
|
|
112 |
</div> |
</div> |
113 |
</div> |
</div> |
114 |
<div id="jscoverage-sidebar" class="yui-b"> |
<div id="jscoverage-sidebar" class="yui-b"> |
128 |
<div id="ft"> |
<div id="ft"> |
129 |
<address> |
<address> |
130 |
Copyright © 2007 siliconforks.com<br> |
Copyright © 2007 siliconforks.com<br> |
131 |
Last updated August 15, 2007<br> |
Last updated August 26, 2007<br> |
132 |
<a href="mailto:jscoverage@siliconforks.com">jscoverage@siliconforks.com</a> |
<a href="mailto:jscoverage@siliconforks.com">jscoverage@siliconforks.com</a> |
133 |
</address> |
</address> |
134 |
</div> |
</div> |