1

We are working on a big Java project where we use JUnit tests. Our Jenkins helps us to monitor the code coverage and shows us the progress we make with this.

But there seems to be something lacking here. In our case, one of the apps results in a zip file with data files generated based on different source files.

All code to generate these data files is covered, but that doesn't tell us if the content of the generated files itself is OK. Is this just a matter of generating additional JUnit tests and rely on the knowledge of the team to know what needs to be tested? Or can this be controlled and monitored in some way?

1

The way I would approach this would be to have a second part of the junit test that reads the generated zip file and then verifies it is correct. You are right that if you are only ensuring you can generate the file, but the file is incorrect, the unit test is incomplete.

1

This is my opinion: Coverage says nothing about correctness, so if you are writing unit tests for coverage, you are doing it wrong. Unit tests shall originate in requirements, the resulting coverage is a measure for completeness of your test suite and your code quality. If the coverage is low, chances are that

  • your unit tests don't cover all requirements.
  • there is dead code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.