The specification for this requirement can be the following:
@Test public class ShipSpec { public void whenInstantiatedThenLocationIsSet() { Location location = new Location(new Point(21, 13), Direction.NORTH); Ship ship = new Ship(location); assertEquals(ship.getLocation(), location); } }
This was an easy one. We're just checking whether the Location object we're passing as the Ship constructor is stored and can be accessed through the location getter.
The @Test annotation—When TestNG has the @Test annotation set on the class level, there is no need to specify which methods should be used as tests. In this case, all public methods are considered to be TestNG tests.