Unit Test Is Not Integration Test 📎
EntityManager
is going to be completely mocked-out as well:
class PersistentHitStoreTest extends JUnitSuite with MockitoSugar with ShouldMatchersForJUnit{
var cut:PersistentHitStore =_
@Before
def setUp: Unit = {
cut = new PersistentHitStore();
}
@Test
def persistCacheDeletesCache:Unit = {
cut.em = mock[EntityManager]
}
...
}
[sample from x-ray]
If you are using maven, see Trouble With Crippled Java EE 6 APIs in Maven Repository And The Solution and A Natural Separation of JUnit Tests in Maven (3). One of the FAQs: "How to unit test Java EE 6 applications" is extremely easy to answer: there is no difference between unit testing of Java SE and Java EE 6 applications :-). [See also page 109 "Unit Test Is Not Integration Test" in Real World Java EE Night Hacks--Dissecting the Business Tier.]