In JUnit
is there a place where I can define how methods to be tested should flow?
I have class called Location
which I have written a test for. All tests pass apart from testGetName
which is called before testSetName
.
It makes the tests fail. How can I fix this?
public class LocationTest {
Location instance;
@Before
public void setUp() {
instance = new Location();
}
@Test
public void testGetLongitude() {
System.out.println("getLongitude");
double expResult = 0.0;
double result = instance.getLongitude();
assertEquals(expResult, result, 0.0);
}
@Test
public void testSetLongitude() {
System.out.println("setLongitude");
double longitude = 0.0;
instance.setLongitude(longitude);
}
@Test
public void testSetName() {
System.out.println("setName");
String name = "";
instance.setName(name);
}
/**
* Test of getName method, of class Location.
*/
@Test
public void testGetName() {
System.out.println("getName");
String expResult = "Mock Location";
String result = instance.getName();
assertEquals(expResult, result);
}
}