JUnit report to show test functionality, not coverage

Adam

One of the problems of a team lead is that people on the team (sometimes even including myself) often create JUnit tests without any testing functionality.

It's easily done since the developers use their JUnit test as a harness to launch the part of the application they are coding, and then either deliberately or forgetfully just check it in without any assert tests or mock verifies.

Then later it gets forgotten that the tests are incomplete, yet they pass and produce great code coverage. Running up the application and feeding data through it will create high code coverage stats from Cobertura or Jacoco and yet nothing is tested except its ability to run without blowing up - and I've even seen that worked-around with big try-catch blocks in the test.

Is there a reporting tool out there which will test the tests, so that I don't need to review the test code so often?

I was temporarily excited to find Jester which tests the tests by changing the code under test (e.g. an if clause) and re-running it to see if it breaks the test.

However this isn't something you could set up to run on a CI server - it requires set-up on the command line, can't run without showing its GUI, only prints results onto the GUI and also takes ages to run.

Tom G

PIT is the standard Java mutation tester. From their site:

Mutation testing is conceptually quite simple.

Faults (or mutations) are automatically seeded into your code, then your tests are run. If your tests fail then the mutation is killed, if your tests pass then the mutation lived.

...

Traditional test coverage (i.e line, statement, branch etc) measures only which code is executed by your tests. It does not check that your tests are actually able to detect faults in the executed code. It is therefore only able to identify code the is definitely not tested.

The most extreme example of the problem are tests with no assertions. Fortunately these are uncommon in most code bases. Much more common is code that is only partially tested by its suite. A suite that only partially tests code can still execute all its branches (examples).

As it is actually able to detect whether each statement is meaningfully tested, mutation testing is the gold standard against which all other types of coverage are measured.

The quality of your tests can be gauged from the percentage of mutations killed.

It has a corresponding Maven plugin to make it simple to integrate as part of a CI build. I believe the next version will also include proper integration with Maven site reports too.

Additionally, the creator/maintainer is pretty active here on StackOverflow, and is good about responding to tagged questions.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JaCoCo Debug Coverage Test Report

From Dev

JUNIT test report

From Dev

Generate JUnit Test report

From Dev

Junit : how to show the report in a Jframe

From Dev

SonarQube: including a subset of test coverage classes in report

From Dev

How to generate test coverage report in Meteor / Velocity?

From Dev

Jacoco Test coverage report shows 0%

From Dev

JaCoCo coverage report setups(exclude test classes)

From Dev

Android test coverage report for multi module app

From Dev

Jacoco Test coverage report shows 0%

From Dev

JaCoCo coverage report setups(exclude test classes)

From Dev

Does coverage.py show test coverage on python bindings properly?

From Dev

Code coverage in VS2013 show coverage of Test and not actual code

From Dev

How to generate pdf report of junit test results?

From Dev

Why does my coverage report show covered lines in red?

From Dev

Functional test coverage report with node-jscoverage , mocha and express

From Dev

I Need enable livereload in my coverage test report

From Dev

Jacoco generate coverage report for only a single test class

From Dev

I Need enable livereload in my coverage test report

From Dev

How to Junit test and expect an exception whilst maintaining code coverage

From Dev

How to Junit test and expect an exception whilst maintaining code coverage

From Dev

Junit Integration Test issue for testing create and exception functionality

From Dev

Coverage show test get_serializer_class as untested

From Dev

Jenkins build fail due to Junit test report not found : Intern Framework

From Dev

integrate ant junit generated test-results in gradle html report

From Dev

Report is not generated, If I run my test cases(JUnit) through Maven?

From Dev

Generate coverage report with stack

From Dev

Generate coverage report with stack

From Dev

Coverage report with istanbul and mocha

Related Related

  1. 1

    JaCoCo Debug Coverage Test Report

  2. 2

    JUNIT test report

  3. 3

    Generate JUnit Test report

  4. 4

    Junit : how to show the report in a Jframe

  5. 5

    SonarQube: including a subset of test coverage classes in report

  6. 6

    How to generate test coverage report in Meteor / Velocity?

  7. 7

    Jacoco Test coverage report shows 0%

  8. 8

    JaCoCo coverage report setups(exclude test classes)

  9. 9

    Android test coverage report for multi module app

  10. 10

    Jacoco Test coverage report shows 0%

  11. 11

    JaCoCo coverage report setups(exclude test classes)

  12. 12

    Does coverage.py show test coverage on python bindings properly?

  13. 13

    Code coverage in VS2013 show coverage of Test and not actual code

  14. 14

    How to generate pdf report of junit test results?

  15. 15

    Why does my coverage report show covered lines in red?

  16. 16

    Functional test coverage report with node-jscoverage , mocha and express

  17. 17

    I Need enable livereload in my coverage test report

  18. 18

    Jacoco generate coverage report for only a single test class

  19. 19

    I Need enable livereload in my coverage test report

  20. 20

    How to Junit test and expect an exception whilst maintaining code coverage

  21. 21

    How to Junit test and expect an exception whilst maintaining code coverage

  22. 22

    Junit Integration Test issue for testing create and exception functionality

  23. 23

    Coverage show test get_serializer_class as untested

  24. 24

    Jenkins build fail due to Junit test report not found : Intern Framework

  25. 25

    integrate ant junit generated test-results in gradle html report

  26. 26

    Report is not generated, If I run my test cases(JUnit) through Maven?

  27. 27

    Generate coverage report with stack

  28. 28

    Generate coverage report with stack

  29. 29

    Coverage report with istanbul and mocha

HotTag

Archive