Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying the Original Src folder #142

Closed
nitsakh opened this issue Jun 21, 2014 · 8 comments
Closed

Copying the Original Src folder #142

nitsakh opened this issue Jun 21, 2014 · 8 comments
Assignees

Comments

@nitsakh
Copy link

nitsakh commented Jun 21, 2014

I am storing the reports in json in a separate folders. However, to merge them there needs to be the original-src folder inside each report folder.
Is this the same as the one generated in root instrumented folder ?
Besides, I have hundreds of tests, and copying this folder to all the tests will lead to a lot of redundancy, and waste of storage space.
Is there a way to just have the reports json, and then merge them to get final total coverage report ?
Thanks a lot. JSCover is a great tool.

@tntim96
Copy link
Owner

tntim96 commented Jun 22, 2014

to merge them there needs to be the original-src folder inside each report folder

JSCover will merge the original-src folders as it's possible to merge reports with overlapping or exclusive sets of source files. I've removed that requirement from merging, instead just logging (at Level.INFO) if the directory is not found. You can test from build from source, or try the binary.

I have hundreds of tests, and copying this folder to all the tests...

One way around this is to use the same browser to run all the tests, and the coverage data will just accumulate. You can even retain data between page loads by using the local-storage switch.

Is there a way to just have the reports json

You can retrieve the JSON in your test infrastructure code (e.g. WebDriver, PhantomJS) as described here.

Alternatively, I could add a switch, say --save-json-only, which only saves the jscoverage.json. Would that be better for you?

@tntim96
Copy link
Owner

tntim96 commented Jun 22, 2014

I could add a switch, say --save-json-only

I've added this as well. Again, you can test by building source yourself, or try the temporary binary.

@nitsakh
Copy link
Author

nitsakh commented Jun 23, 2014

Thanks tntim96. You're great !
However, maybe my issue is not perfectly clear. I would just like to describe the steps that I do. So that you can confirm.

  1. Instrument the build in folder "InstrumentedBuild".
  2. Run automated "test1". This test opens new browser window, performs operations using Selenium library, and stores jscoverage.json file in "folder1". Closes the browser window.
  3. The original-src folder is copied from the folder "InstrumentedBuild" to "folder1". Also the other files jscoverage.html, css etc. (generated in the server mode to view report) are also copied into the "folder1".
  4. Run automated "test2", "test3", ..... i.e. run all the tests and do steps 2 and 3.
  5. Merge all folders "folder1", "folder2", .... with jscover command into "totalcoverage" folder.

So, basically I want to avoid step 3, and merge "folder1", "folder2" etc. directly.
I think #142 does that, but I am not sure of the consequences, as to any information loss in the process.
Will it affect as per the overlapping or exclusive set of source files in the reports ?

Thanks a lot for the support !

@tntim96
Copy link
Owner

tntim96 commented Jun 23, 2014

Instrument the build in folder "InstrumentedBuild"

So you're using file-system mode? If so, the original-src folder will be generated at this stage.

stores jscoverage.json file in "folder1"

How are you triggering this? I assume you are doing this manually (i.e. not using JSCover's 'Store' button), and that jscoverage.html (and related files) are not generated.

The original-src folder is copied from the folder "InstrumentedBuild" to "folder1"

How are you triggering this? I assume this is a manual step you perform to avoid the (now fixed) merge error.

I am not sure of the consequences, as to any information loss in the process

The coverage data will be all there in jscoverage.json.

The only potential issue would be missing original-src files if you were instrumenting on the fly which you don't appear to be doing. In server mode, only instrumented files that are served to the browser will be included in original-src, so if the original-src were discarded for some reports, you could be missing some JS source files. This would only affect viewing the report at the source level, but you shouldn't have this problem.

@nitsakh
Copy link
Author

nitsakh commented Jun 23, 2014

Thanks a lot for the support !
Yes, I am using file system mode and storing report through selenium by triggering store report javascript.
Thanks for clearing the doubt. Now, I just need to have the jsons separately, and merge them to "totalcoverage" folder. Copy the "original-src" folder and the other jscoverage files to "totalcoverage" and view the report.
Thanks a lot.
Edit: I haven't tried your fix yet.

@nitsakh
Copy link
Author

nitsakh commented Jun 26, 2014

It's great ! Thanks a lot !

@nitsakh nitsakh closed this as completed Jun 26, 2014
@nitsakh
Copy link
Author

nitsakh commented Jul 7, 2014

Hello, I am experiencing the following bug.
I have a folder Reports, and folders A and B inside those. Each of these folders has the jscoverage.json and another file temp.html. This html file is just for my use.
Whenever, I execute the command,
java -cp JSCover-all.jar jscover.report.Main --merge Reports/A Reports/B TotalReport

I get the jscoverage.json in the TotalReport folder. However, the temp.html file is also copied. This is not as desired. What can the reason be ?

Thanks.

Edit: Actually, if temp.html is present only in folder B (i.e. in the last folder from the list of folders), and not in A, then still the issue is seen.

@tntim96
Copy link
Owner

tntim96 commented Jul 7, 2014

Is it much of a hassle to move the file before merging? Some users may want extra files copied across.

I've raised issue #149 for this - let me know (in that issue) if that would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants