-
Notifications
You must be signed in to change notification settings - Fork 158
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
Runtime dependency on scoverage? #84
Comments
@gijsbert802, what output do you get when run Personally I see the same issue both for |
|
Hi, any solution for this issue ? |
Hi @buzz2buzz You need to disable coverage with |
Hey @alexflav23 - I ran:
But I still ran into the above issue:
Could you please let me know of any other fixes? |
@alexflav23 has it right. It's in the README, but I'd argue it's not the clearest:
I wonder if the maintainers would appreciate a PR that made this part of the documentation more explicit. Maybe have an example that went |
@alexflav23, don't the results of this test repo (https://github.com/kevinmeredith/test_scoverage_instrumentation) demonstrate that running |
Any updates on this? Apparently the issue is still here, as @kevinmeredith suggested? @gslowikowski , as your'e the most recent and active contributor to this project, I'll mention you and kindly ask for help |
It works with This issue should be closed. @captify-akraievoy confirm if it still doesn't work for you. Additionally, |
Thanks, your solution - adding coverageOff to our builds - just did the trick, we are using 1.4.0 right now. |
If I was getting the FileNotFoundException even when I ran I'm leaving this note here for the posterity 🙂 |
Hi~ I'm using play framework and command
It seems that scoverage packaged my local file path to the application and will interfere the execution when the disted zip uploaded to production server. I have to set coverageEnabled to false to disable it. However, this is really inconvenient because I cannot control the unit test code coverage of our project. Hope this could be fixed soon. Thanks very much in advance. |
@scweang FYI, I removed |
@bugorz Thanks for your reply. I have resoulve the problem by setting as below: coverageEnabled in(Test, compile) := true,
coverageEnabled in(Compile, compile) := false, Seems it works fine. |
You should not add any
I know, the readme file is not clear in this area. |
This is actually quite easily missed, and in my opinion isn't well documented at all. While it's entirely my fault, I rather expected scoverage to work with runtime code injection via a JVM agent (similar to other coverage tools), and consequently On the other hand, it should be blatantly obvious that coverage-enabled artifacts are generally not intended to be published; how about modifying (As an aside, this might have undesirable ramifications on build times, but I believe this can be minimized fairly easily; also, publishing doesn't happen very often, so the actual impact ought to be acceptable). |
I am trying to generate coverageReport from a release plugin step. This doesn't work for me as no scoverage files are getting generated. Seems that the
|
|
I have these two lines in the build.sbt of my single module sbt project,
I still do see this error, when I build the jar file with assembly. |
Guys, can you provide simple test projects exposing the issue? |
I had the same problem last week. Tried everything in this thread and nothing seemed to fix the issue, until I realized it was one of our own dependencies in the project that had scoverage and 'coverageEnabled := true' in the build.sbt. |
I know there's a lot of discussion about setting 'coverageEnabled := false' in the build.sbt, but this ends up disabling scoverage in our build pipeline. This is what ended up working for us in the our build.sbt file Default / coverageEnabled := false |
Any update? But I think the test is running twice. One is for generating coverage file, the other one is for publish. Is there any way to optimize this? |
This worked for us. Removed |
We also encountered this problem when we decided to use sbt-scoverage in one of our projects. What is the recommended pattern for using sbt-scoverage? When should it be included in the build.sbt and when should it simply be called from the sbt shell? |
Hey @JeroenSchmidt personally I've found that having it in an alias works quite well. For example at work we use it in a |
@ckipp01 Thanks for the suggestion. Is there a reason why this should not be included in the SBT file? |
The `coverageEnabled := true` in `build.sbt` instruments the code unconditionally. The right way to enable coverage is to do `sbt clean coverageOn test coverageReport coverageAggregate` Also it is important to do `sbt clean` after doing the coverage, otherwise the code stay instrumented. The problems to figure out: 1. when instrumented code is included into jar this jar doesn't work on another machine 2. apparently the `sbt clean` is not sufficient and the `target` directories for each subproject need to be removed 3. setting `coverageEnabled := false` and trying to issue `sbt clean coverageOn ...` doesn't produce report files 4. when `sbt ... coverageOn test` is used junit xml test report is not generated 5. we should run eunit tests using coverage as well ``` sbt clean coverageOn make all-tests sbt coverageReport coverageAggregate ``` 6. we need to include mango tests into all-tests target See following - scoverage/sbt-scoverage#84 - scoverage/sbt-scoverage#228 - scoverage/sbt-scoverage#306 - https://github.com/viktortnk/kafka-storm-starter/blob/de6eac4ae635e0e54981a92555de05071c14518a/README.md?plain=1#L340C1-L342C58 - https://github.com/Facsimile/facsimile/blob/409dd67fd291161414401c97d128bf65c0fcc30f/Facsimile.sbt#L458
When I build artifacts (a jar) using
sbt coverage test package
, the class files in the artifact have references to scoverage files. I then get runtime exceptions when using the jar.This didn't happen before version 1.0 I think.
For example, this is the output of a unit test that uses the class DocumentGenerator from my jar:
Output of
javap -c DocumentGenerator.class
looks like this:Is this supposed to happen?
The text was updated successfully, but these errors were encountered: