I'm using Clover in a project, to help get test coverage over 7%.
I separated and renamed unit tests and integration tests into *Test.java and *IT.java, and added Surefire to reduce build times.
All tests run fine.
Now suddenly Clover says test coverage is 0%.
What can be the reason for this, and how do I fix it?
I managed to get it working again by removing Clover and Surefire, and then adding Clover with only simple settings
Related
In my Java app, in order to generate coverage reports for my Unit Tests, I have tried several approaches to setup Jacoco as in Run with coverage or this page. However, I cannot generate coverage reports as expected and I think I need some steps describing the setup of Jacoco on IntelliJ. So, does anybody else have experience for setup and run it via command line as shown below:
mvn --global-settings ../settings.xml
-Dtest="/com/mycompany/core/service/impl/unit/ProductServiceImplTest.java" test
Any help would be appreciated.
hi all i have build unit testing for controller, repository and Service but why in my sonarqube code coverage always give me code coverage only 0 percent. my question is how to make my percentage up ?
here what i was code in my testing
Sonarqube uses existing code coverage reports from JaCoCo (in the case of Java). Usually, you would set up the JaCoCo Maven plugin (or Gradle) to gather coverage info on test run and Sonarqube then loads this report.
See also the Sonarqube docs for info on setup. But if you are using Maven/Gradle, I believe Sonarqube is able to automatically pick up the correct file unless you have some special configuration.
I'm hitting a weird issue were my unit tests fail when running mvn install but they pass when running in IntelliJ.
I've looked at posts online about debugging maven, but I don't want to debug maven itself, or a maven plugin. I want to debug my unit tests when they have been called by maven. More specifically, I want to debug my code but using the Junit tests as an entry point for the debugging via a breakpoint.
Hope that makes sense.
My issue is relating to using introspection to look at some classes the application is importing from another project. This succeeds when the project is running or running in debug mode, but fails when maven runs the tests as a part of an install. i.e. the code doesn't find the classes in the other project when running under maven...
As this application uses multiple maven projects that all need to be installed, I've had to move my unit tests out into another project just so that the installs don't fail and I can carry on development.
However, for obvious reasons I would like to put my unit tests in each individual project, so am very keen to debug this and find out what is failing.
My project is called infinite-state-machine and can be found here - https://github.com/museadmin/infinite-state-machine
The unit tests are currently in their own project here - https://github.com/museadmin/infinite-state-machine-test
If anyone can advise me how to run maven in debug mode and attach IntelliJ to it so that I can set a breakpoint in my failing unit tests I will be forever in their debt :)
Thanks in advance for any help.
Brad
I'm using Maven's failsafe plugin to run integration test suites. The tests themselves are selenium-webdriver tests that use JUnit for the asserts and categories. When I launch an individual test with:
mvn clean verify -Dfailsafe.rerunFailingTestsCount=N -Pfunctional-test,env-stage -Denvironment=env-stage -DtestBuildNumber=${testBuildNumber} -Dit.test=TestName -Dwebdriver=${browser} -Dselenium.grid.2.hub=${hub}
It will rerun failing tests N times.
However if I launch a test suite with that same command it will not rerun failing tests. Is there some way to get rerunFailingTestsCount to work with suites?
What version of failsafe plugin do you use?
Your problem looks like this bug: https://issues.apache.org/jira/browse/SUREFIRE-1152
Option rerunFailingTestsCount silently fails with test suites
After a test failure (with rerunFailingTestsCount > 0), the
JUnit4*Provider.executeWithRerun calls execute again with a list of
the failing testMethods, but JUnit4*Provider.execute silently fails to
find the requested methods.
Should be fixed in 2.19
My development environment is Netbeans 7.4 and Maven 3.0.5 (bundled with Netbeans). I'm using JUnit 4.11 to build unit (class names ending with Test) and integration tests (class names ending with IT). I'm running unit tests and excluding integration tests with the "-DskipITs" Maven option. I have a custom action which runs just the integration tests with the failsafe plugin. Both execute successfully. However, I only see the results in the "Test Results" window when running the unit tests. How can I get the integration tests to show in the "Test Results" window? With the integration tests, I'm only seeing the output in the console.
The maven-failsafe-plugin only executes in integration-test and verify (and of course the help) goal while the maven-surefire-plugin runs during test goal.
NetBeans Test Results window only shows the tests that were executed using the 'test' goal.
My solution for this situation is to categorize my integration tests into
testintegration - just lightweight ITs, I run them with surefire (to see them in Test Results window)
testheavy - those that will require me to bootstrap something I run with the fail-safe plugin
I hope you have the option of doing something close to that.