October 2017
Intermediate to advanced
442 pages
12h 33m
English
Imagine the whole manufacture car use case shown in the previous example in the Unit tests section, needs to be tested. A car is created, using a delegate CarFactory, and then is persisted into the database. Testing the persistence layer is out of this test scope, therefore the entity manager will be mocked away.
The following code snippet shows the component test to the manufacture car use case:
public class ManufactureCarTest {
private CarManufacturer carManufacturer;
@Before
public void setUp() {
carManufacturer = new CarManufacturer();
carManufacturer.carFactory = new CarFactory(); carManufacturer.entityManager = mock(EntityManager.class); } @Test public void test() { when(carManufacturer.entityManager.merge(any())).then(a ...Read now
Unlock full access