Skip to content

Won't this run tests twice? #2

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

Closed
babineaum opened this issue Oct 4, 2017 · 8 comments
Closed

Won't this run tests twice? #2

babineaum opened this issue Oct 4, 2017 · 8 comments

Comments

@babineaum
Copy link

<report>report</report> <!-- select only one report from: report, integration-report and report-only reporters -->

Accoring to this closed issue scoverage/scoverage-maven-plugin#39, this pom file would run tests twice, is that correct?

@babineaum
Copy link
Author

@gslowikowski wondering if you might be able to help me out. i tried to follow what you were saying over in the closed ticket i reffed above but im still getting 2 runs of test if i turn of all scoverage i dont get a report... so im kinda confused as to why you said to disable all tasks for scoverage in the pom.xml

@gslowikowski
Copy link
Member

Hi @babineaum

Sorry for not responding for some time.

IMPORTANT!
When I'm writing about (not) adding scoverage tasks to pom.xml file I'm thinking about build section, not reporting. In short, reporting is OK.

Generally, I never add scoverage tasks to my poms (build section).
If I want coverage check, I run something like this mvn clean package scoverage:check.
If I want coverage report - mvn scoverage:report
If report must be added to Maven site, it has to be added to reporting section, like in the line you cited above.
If you run e.g. mvn test scoverage:check or mvn test scoverage:report the tests will run twice, once on uninstrumented classes (in test task) and second time on instrumented classes (in test task executed in lifecycle forked by scoverage:report task)

The issue scoverage/scoverage-maven-plugin#39 was about forking scoverage lifecycle from already forked scoverage lifecycle. It is possible, but does not make sense.

@babineaum
Copy link
Author

babineaum commented Oct 11, 2017

Hmmm ok well i seem to have the same problem as the other person "ghost".

I guess my question is, is there a way to run a 'mvn clean install' and have the build create an artifact that I can deploy and also run instrumented tests without running the non instrumented tests as well?

Edit: I'll note that I am getting two runs of the tests, one pre the scoverage fork during the test phase, by scalattest-maven-plugin and the other during the scoverage fork when scoverage calls scalatest-maven-plugin and runs tests after instrumentation.

@gslowikowski
Copy link
Member

gslowikowski commented Oct 11, 2017

You need two Maven calls, for example:

  • mvn clean install -DskipTests
  • mvn scoverage:report

There is no way (IMO) to set and clear skipTests flag interpreted by Surefire plugin depending on the context (scoverage or not).

@tenstriker
Copy link

For me single mvn clean process-classes scoverage:report command works. proccess-classes generates classed dir under target so I can run my application. I don't attach any scoverage goal to build lifecycle in pom configuration.

@ahmedriza
Copy link

@gslowikowski
mvn clean package scoverage:check
still runs the build and tests twice. Is there a way to run the build and tests just once (similar to what JaCoCo does for Java) ?

@gslowikowski
Copy link
Member

There is a way to avoid running tests twice now. Check this issue scoverage/scoverage-maven-plugin#61 please.

@gliu-nova
Copy link

solution:
remove scoverage:report goal, then run
mvn scoverage:report AFTER your mvn clean test/verify

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

No branches or pull requests

5 participants