Problem with Multiple scripts

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

Problem with Multiple scripts

Post by Vishu » 2009-01-28 6:08 pm

I have a huge web application where I am placing my jscoverage.html and other jscoverage files in the directory containing my Home HTML file.
Suppose my application is located in C:\Applications\App and Home page HTML is in C:\Applications\App\Data\Home\Landing.html, I copied jscoverage.html and other jscoverage files in C:\Applications\App\Data\Home.
There are different folders under C:\Applications\App. I instrumented all of them.
Now to access the application, I have to access landing.html. I embed a button in that HTML to open jscoverage.html located in the same directory.
But it shows only a few js files, not all files under C:\Applications\App though I am sure other js files have been executed too.

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

Re: Problem with Multiple scripts

Post by Ed » 2009-01-28 8:03 pm

You will probably have to instrument the top-level C:\Applications\App directory:

Code: Select all

jscoverage C:\Applications\App C:\Applications\App-instrumented
Then access the C:\Applications\App-instrumented\jscoverage.html file.

Generally a generated jscoverage.html file can measure coverage only for those files generated with it under the same directory, not in any other directories.

Vishu

Re: Problem with Multiple scripts

Post by Vishu » 2009-01-29 5:40 am

But in the above case, I have pasted my jscoverage.html under C:\Applications\App\Data\Home and I have multiple js files under C:\Applications\App.
I am getting only 2 js files. Those js files are under C:\Applications\App\<Some Other folder>

How are these 2 coming then?

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

Re: Problem with Multiple scripts

Post by Ed » 2009-01-29 6:15 am

It may work, depending on your exact directory structure, but generally you should use the jscoverage.html at the top of the instrumented directory.

Also, check that all of the .js files you are using are instrumented. The easiest way to do this is to use Firefox + Firebug and visit C:\Applications\App\Data\Home\Landing.html, then look at the script source under the "Script" tab. Make sure they all have a "Generated by JSCoverage" comment at the top.

Vishu

Re: Problem with Multiple scripts

Post by Vishu » 2009-01-29 8:59 am

All the files are instrumented. I instrumented App folder to App1, took a backup of App in some other folder and renamed App1 as App so that Web Applications refer instrumented files now.

I pasted the jscoverage.html inside App(newly created App). It didn't show any js files under Summary tab.

Earlier I kept it in C:\Applications\App\Data\Home. Then it showed me only 2 js files. But suddenly it showed me all the js files. I thought its working now. But then again, it started showing only 2 js files. I am not able to proceed further because of this.

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

Re: Problem with Multiple scripts

Post by Ed » 2009-01-29 4:06 pm

Vishu wrote:All the files are instrumented. I instrumented App folder to App1, took a backup of App in some other folder and renamed App1 as App so that Web Applications refer instrumented files now.

I pasted the jscoverage.html inside App(newly created App). It didn't show any js files under Summary tab.
Is there a jscoverage.html file being generated in the App directory? There should be one automatically generated when you run the jscoverage executable.

Vishu

Re: Problem with Multiple scripts

Post by Vishu » 2009-01-29 7:39 pm

Yes, it is being created along with some other files for jscoverage like a js file and css files and a gif file.

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

Re: Problem with Multiple scripts

Post by Ed » 2009-01-29 8:03 pm

Can you execute your tests by visiting your test page within the jscoverage.html iframe, like this:

http://SERVER/jscoverage.html?Data/Home/Landing.html

Vishu

Re: Problem with Multiple scripts

Post by Vishu » 2009-01-29 9:18 pm

Ok. I feel I am getting the result now. I am doing actions in app and getting the result in JS Coverage report. But now I am facing another issue. If I do action A, I get js files in report which get executed. Now if I do action B, I get js files for action B, but files for action A are lost.

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

Re: Problem with Multiple scripts

Post by Ed » 2009-01-29 9:49 pm

OK, I have 2 questions:
  • Are you navigating to another page? (Is this what you mean by action B?)
  • If so, are you doing it within the jscoverage.html iframe?
Basically if you navigate to another page your existing code coverage data will be lost, UNLESS you do it within the jscoverage.html iframe. As long as the outer jscoverage.html location doesn't change, your code coverage data will be preserved.

See the scriptaculous test suite demo for an example of this.

Vishu

Re: Problem with Multiple scripts

Post by Vishu » 2009-01-29 10:03 pm

Hey ED,
Thanks for replying so early to all my queries.

By action B here, I mean clicking a tab which actually takes me to another page.
Basically, this is what I am doing.

1. I have embedded a button in the Home Page to open up the jscoverage.html.
2. I open up the jscoverage.html by clicking button. It shows me few js files as they get executed on loading the Home Page itself.
3. Now I do some action (like clicking some tab which opens another page.
4. jscoverage.html file still shows the old js files. I refresh it.
5. It shows new js files but old ones are lost.

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

Re: Problem with Multiple scripts

Post by Ed » 2009-01-29 10:14 pm

Is it possible to execute your tests within the jscoverage.html iframe, instead of in a separate window? If you do that it should preserve all the coverage data for all the .js files.

Vishu

Re: Problem with Multiple scripts

Post by Vishu » 2009-01-29 10:28 pm

Yeah. I tried that. Its preserving the results then. But what if I don't want to test it in jscoverage.html iframe?
Using that frame takes lot of space which then does not allow to do UI testing from user's point of view. A user won't be using any such frame.

Isn't it possible to preserve the results while I am trying to see the result in jscoverage.html in a seperate window?

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

Re: Problem with Multiple scripts

Post by Ed » 2009-01-30 12:26 am

You will need some sort of frame to preserve the results. I will see if I can make the frame smaller in a future release. In the meantime you might want to try "Full Screen" mode in your browser (usually the F11 key) to get more screen space.

Guest

Re: Problem with Multiple scripts

Post by Guest » 2009-02-04 6:19 am

Hey ED,

Thanks for the information given so far. It was really very helpful.

After reaching this level, we have to move forward. Our web application is such that we all (3-4 guys) access it remotely via some linux machine.

We all have windows on our machines. When we access the app, js files actually get executed on the linux machine and from there we get the appropriate response. So, is there any provision that we all keep running our app from our windows machines and get the code coverage information for all of us merged somewhere?

Post Reply