I want to write unit tests for my JPA classes. Can anyone suggest me best way to do it? Is there any good framework for this? If you have some example please share it.
From 'JPA Class', I understand you want to test Entity classes.
How is this going to be different from unit testing your other classes. A junit testcase to test persisting and retrieving your entity should be just fine.
I have integration test cases in which I am generating data using in memory database and test my functionality but Sonar don't consider them as coverage.
Thing is I have lots of different methods around my entities. I want to test all of them and make sure that Sonar also understand that I am covering all of my methods. So for this can you suggest some framework or some example?
1.) You can make sonar understand the integration tests results maybe via cobertura configs. This can be difficult to get right and will depend on versions of plugins you are using.
2.) You can move the JPA layer tests into unit tests. They depend on an in memory database so the should be fine to run as unit tests.
Curse your sudden but inevitable betrayal! And this tiny ad too!
a bit of art, as a gift, that will fit in a stocking