SonarQube5.3 displays the coverage of a java file as 0.0% even though there exist a test file for it. This test file is not included in SonarExclusions.json.
Also, in eclipse which uses Eclemma tool for code coverage highlights the source with red color indicating the source code is not covered completely.
What must be the reason for the coverage not being reflected?
This can be helpful.
If this is correct, then SonarQube might require something else like cobertura or jacoco to provide it the test coverage. Please try adding such a analysis tool and try running Sonar again.
I would need to use Eclipse to find code coverage of a test file generated by an automated tool with respect to a certain project.
I am thinking of using the "Emma" plugin but, as the project was not originally an Eclipse one, am having some difficulties importing it. I can open individual files, but that is not of much use as I can't run the plugin then.
Any ideas? :)
Thanks!
I started learning JUnit testing within Eclipse. The plugin that is used to show the test results presents a nice clean view of the test and you can click on items that take you to the areas in code that are under test.
When I started working with Maven, I noticed that you can have Maven carry out your JUnit tests as well. However, because Maven is a command line process and the results get written to the console, the JUnit results get sent there as well. And it looks like crap. You have to parse your way through all the console text to find the results of the test. Everything is just plain old text.
This raises the question as to what purpose Maven has in testing with JUnit (or any other test frameworks for that matter)? I must be missing the point. Why would anyone want to read a large text dump when the Eclipse plugin provides an elegant way of viewing, executing and evaluating tests?
Generally speaking, you build on the command line because you've got everything working correctly in your IDE. The command line build is the final sanity check and possibly the way in which you are releasing your software (e.g. mvn release:perform etc.).
While there are a few plugins that make Maven test output slightly nicer, the expectation is that the tests will pass. If they don't, fire up Eclipse and run the tests again.
Maven is a build tool. Its goal and purpose is to produce repeatable and protable result. This is especially important when we talk about build/continuous integration servers.
So the normal workflow is/should be: Developers usually develop using their IDE (eclipse), they run their tests in the IDE, because it is developer centric and more comfortable.
The build server, lacking a graphical environment runs the build tool, i.e. maven.
Sometimes, the results between maven and the eclipse might differ, in that case might become necessary for developers to also run maven on their machine.
Another reason to use maven directly might be integration test which specifically us maven lifecycle integrations for say starting and stopping a server.
Some specific points: Maven quite comfortably shows you which tests failed in a summary:
00:46:21.988 Results :
00:46:21.988
00:46:21.988 Failed tests:
00:46:21.988 MyTest.testPersistErrorStateNewTransaction:48 Test for 'testPersistErrorStateNewTransaction()' not yet implemented!
00:46:21.988
00:46:21.988 Tests in error:
00:46:21.988 MyOtherTest.testMethod
00:46:21.989
00:46:21.989 Tests run: 1162, Failures: 1, Errors: 1, Skipped: 491
00:46:21.989
00:46:22.003 [ERROR] There are test failures.
00:46:22.004
Also, when run, from maven, you can still open the results of the surefire tests in your eclipse junit view by double-clicking on a test result (.xml) in the surefire-reports directory.
what purpose Maven has in testing with JUnit?
Unit testing is one of the part in Application Development(usually do while coding/developing components), Apache Maven is the project management tool, (as Duncan told) it helps us to releasing software.
includes - Dependency Management, Module Management, Plugin Management, and reporting configuration for tests.
Maven Objectives:
Making the build process easy
Providing a uniform build system
Providing quality project information
Providing guidelines for best practices development
Allowing transparent migration to new features
please look at below threads for more details about Maven:
Why do so few people use Maven?
Why maven ? What are the benefits?
Why would anyone want to read a large text dump when the Eclipse plugin provides an elegant way of viewing, executing and evaluating tests?
For software release purpose we need maintain statistics of the application(how many scenarios covered, test cases passed..etc). Maven supports different plugins to format the results, Maven Surefire Plugin, maven-site-plugin..etc plugins help us to generate reports different formats.
please refer below threads for more details:
JUnit3 and Junit4 XML Reports with Maven
Is there a decent HTML Junit report plugin for Maven?
We have got SCCT to produce some pretty web-pages showing the coverage of our unit tests. And now we want to integrate this into our Jenkins continuous integration build.
I have created a Jenkins job to run the SCCT tests but how to a) fail the build if the coverage is below n% and b) how to display these pretty web-pages?
The build is a maven-multi-module project.
Cheers
We are using the jenkins cobertura plugin. SCCT emits a cobertura-format coverage xml file for each module (I didn't spot at first) and the cobertura plugin collates these. One problem is that the cobertura plugin needed to be downgraded to 1.3 as otherwise it thinks that the mojo hasn't been run and doesn't do anything.
Since this is possible for other coverage tools like cobertura via a jenkins plugin, you could either
convert the output of SCCT to something looking like the results of an existing tool and use the matching jenkins plugin.
write your own jenkins plugin, possibly borrowing code from existing plugins for other coverage tools.
Is there a way to run all the tests in multiple eclipse projects?
I have a maven multi module project and want to use emma to show me code, that is not covered by any tests, not matter in which submodule it lies. So my idea is to have a single emma-coverage run, that includes all the tests of all my modules.
is there a way to do this?
You could have a look at jacoco which runs your tests in an ant/emma context and generates a report - the report component is able to merge the results from each submodule into a single report.