October 2017
Intermediate to advanced
442 pages
12h 33m
English
It is more advisable to use delegation rather than extension.
Mocking and verification logic that depends on the used components is delegated to separate test objects. The delegates thus encapsulate and manage this logic individually.
The following code snippet shows the test case using components that define the car manufacture and car factory dependencies:
public class ManufactureCarTest {
private CarManufacturerComponent carManufacturer;
private CarFactoryComponent carFactory;
@Before
public void setUp() {
carFactory = new CarFactoryComponent();
carManufacturer = new CarManufacturerComponent(carFactory); } @Test public void test() { Specification spec = ... Car expected = ... assertThat(carManufacturer.manufactureCar(spec)).isEqualTo(expected); ...Read now
Unlock full access