-
Notifications
You must be signed in to change notification settings - Fork 48
Coverage checking causes tests to run twice #61
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
Comments
Hi @jqno. Sorry for late reply. JaCoCo uses Java agent to instruments classes while loading them. Scoverage instruments classed during compilation. Instrumented classes are written to disk. I've implemented plugin in this way to avoid deploying applications with instrumented classes. This is very common problem reported by I know, how to do what you want, but I don't know, how to do it in a safe way. How to prevent users from accidentally deploying instrumented artifacts. |
OK, maybe I found a solution. Checkout and build add-additionalForkedProjectProperties-configuration-parameter branch locally. Change plugin version to
Tests will be executed only in forked |
Hi! Thanks for the background about agents vs instrumented bytecode, that explains a lot. I've tried out your solution on our codebase, and it works allright. A question though: can you have multiple settings inside Thank you! |
Yes, separate them with semicolon:
|
Awesome! |
@gslowikowski |
Did you guys test your projects with Scoverage plugin version from add-additionalForkedProjectProperties-configuration-parameter branch? Does it work without problems? |
I didn't but AFAIU it worked for @jqno based on his comment
|
Indeed. In fact, I'd also like a release if possible 😄 |
Is there something I can do to help get this released? |
Hi @jqno Actually yes. I thought that there should be documentation page about this feature. It's not straightforward, so should be described. I don't have enough time to sit down, think about it and write it down in a clear, understandable way (I'm not good when it comes to documentation, especially in English). Could you help me with this task? |
Of course! I'll send a PR your way, hopefully some time this week. I'll just add a little chapter to the README. Do we also need an update to the sample projects? |
I've opened a PR: #67. Please let me know if there is anything that I didn't describe correctly or in sufficient detail, or if there's anything else that can be improved. |
A release will be great 👍 |
Hi @jqno . I've merged my branch to master. Please rebase your branch to master (I've already changed base branch in PR). Can you add |
Done! |
Co-Authored-By: jqno <[email protected]>
Thank you guys for your help and patience.
If everything is OK I will perform release very soon. |
I tested it, and it (still) works! 👍 |
Version |
Awesome, thanks! |
Thats great, but doesnt seem to appear on maven central |
It's there - http://repo1.maven.org/maven2/org/scoverage/scoverage-maven-plugin/1.4.0-M5/ Probably https://mvnrepository.com needs some time to refresh. |
impatience me 👿 |
2.13.0-RC1 is already out Can we please cross publish for it? |
It's not possible. I found some incompatibilities between M5 and RC1. |
Version |
@jqno @gslowikowski which version of maven is this new feature known to work? or is there an example of the pom.xml which shows how this works? we are running maven 3.6.1, the plugins and the properties are defined in a parent pom, and this new configuration property is not affecting the run. "mvn -X" shows identical plugin configurations for scalatest and scalafmt in regular and scoverage-forked versions. |
We're using Maven 3.6.1 as well, at first with Scala 2.12 and currently Scala 2.13. It works fine for us. Did you forget to add |
@jqno thanks; i did include the skipTests=true. unfortunately, the scoverage run has the same exact plugin configurations (according to mvn -X), and ends up skipping tests as well, while running protoc, scalafmt and scalastyle etc. hence my question about your exact pom configuration which shows how this property override might work. perhaps my pom is just too complex (with parent pom, profiles, plugin management etc.), but i'd like to have a working example. |
Our build is quite complex as well, with a parent, a bunch of plugins including scalafmt and scalastyle, etc. No profiles though. Not sure if I can help you any further. These issues are always nasty to figure out. I think I'd just start over with a clean pom.xml and start adding complexity until it doesn't work anymore. At least then you know for sure where the culprit is. |
I ran into this issue as well, posting what worked for me, hopefully, can help others. The first issue is solved by setting both properties This the configurations I have in the parent pom: <properties>
<!-- Apparently you need to set these two props -->
<maven.test.skip>true</maven.test.skip>
<skipTests>true</skipTests>
</properties>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<configuration>
<additionalForkedProjectProperties>maven.test.skip=false;skipTests=false</additionalForkedProjectProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<configuration>
<filereports>WDFTestSuite.txt</filereports>
<skipTests>false</skipTests>
<!-- If set to never, scalatest, in a multi modules project, will only discover tests for the first maven module oO -->
<forkMode>once</forkMode>
</configuration>
</plugin> |
none of the solutions above worked for me but this did: |
Unfortunately, skip/non-skip options set by additionalForkedProjectProperties are ignored when using explicit option setting in command line. For example, if I run |
I'd like to check the minimum test coverage level in the
mvn verify
step of my build. I followed the instructions on the webpage: https://github.com/scoverage/scoverage-maven-plugin#checking-minimum-test-coverage-levelThis works fine, but it also causes our tests (and scala-fmt) to run twice, which is very annoying and time-consuming.
In scoverage/scoverage-maven-samples#2 you say it's better to split the call to maven into two separate ones, for example
mvn clean verify -DskipTests
andmvn scoverage:check
, which also works I suppose, but is also very unsatisfying: team members will have to learn to use Maven in a non-standward way if they want to verify their work before submitting it to the CI server. (Either having to remember both incantations and having to remember to type both, or having to use a shell script and remembering not to use Maven directly.)In the mean time, JaCoCo can do coverage level checking directly from
mvn verify
without running the tests twice, so our team members are very much used to only having to typemvn verify
ormvn install
to execute all of the checks that the CI server also executes.Would it be possible to add this behavior to scoverage-maven-plugin as well? It would make Scala adoption on our team so much easier.
The text was updated successfully, but these errors were encountered: