I’ve tried to create a test for the Owner.getPet method in the Spring petclinic project, but Cover did not succeed. It says that it cannot load a class. Can anyone help me resolve the problem?
Thanks @phagobit for your detailed report. Looking at your screenshot it seems that you have a compilation error in the PetType class and for that reason Cover does not produce a test. Can you fix this compilation error and then try again?
Oh, thanks for the prompt reply. I didn’t notice the compilation error. Yes, after fixing it, I got a test. Does that mean that my code always has to compile before I can use Cover to write tests? I mean doesn’t Cover just look at the source code?
No, Cover does not look at the source code. It requires the class files of your project and all dependencies (jar files, which are usually downloaded by your build system, e.g. Maven or Gradle). Essentially, it needs everything that you need to run your unit tests (e.g. running mvn test
).