I have an application that consist of a web server in Java EE (EJBs and JAX-RS RESTful services) and a client module in Angular that runs in a browser.
The components that I can unit test automatically are:
- Java EE presentation layer (RESTful services)
- Java EE business logic (EJBs)
- Java EE data access layer (DAOs)
- Angular javascript layer
- Common javascript functions
In addition to that, I could test a Java EE Restful service end-to-end, with or without mocking objects. And lastly, a browser end-to-end test.
The Java tests are done with jUnit/Mockito and the Angular tests with Karma.
Question: if I unit test each of the Java classes (points 1, 2 & 3) and later the Java EE Restful end-to-end (without the browser), wouldn't I be testing the same thing twice?
On top of that, I could test Java EJBs starting an application server context (with Arquillian) or without starting the context (mocking with with Mockito).
Since writing tests takes time, I'm trying to find the best way to test the software without overlapping. What would be the best strategies? Where I should mock objects and where I should not?