March 2018
Intermediate to advanced
324 pages
8h 30m
English
Our specifications forced us to create the second constructor, since changing the original one would break the existing tests. However, now that everything is green, we can do some refactoring and get rid of the single argument constructor. The specification class already has the beforeTest method that is run before each test. We can move everything, but the assert itself to this method:
public class ShipSpec {
...
private Planet planet;
@BeforeMethod
public void beforeTest() {
Point max = new Point(50, 50);
location = new Location(new Point(21, 13), Direction.NORTH);
planet = new Planet(max);
// ship = new Ship(location);
ship = new Ship(location, planet);
} public void whenInstantiatedThenPlanetIsStored() { // Point max = new ...Read now
Unlock full access