I am a novice programmer and was wondering how I can create a test method that calls the object from the setUp() method above. Is there a better way to do this where a method is used to initialize the objects and the test method does the testing??
Any tips are appreciated..
public class ProjectTeamRemoveMemberTest {
//Initialize test object
public static void setUp() {
Date date = new Date();
Employee e = new Employee("Alice", date);
Project p = new Project();
}
@Test
public void removeTeamMember_True_ifMemberIsSelected() {
setUp();
assertEquals(true, p.removeTeamMember(e));
}
}
You can create those variables on class level, assign values in setup and refere to them in a test.
public class ProjectTeamRemoveMemberTest {
static Date date;
static Employee e;
static Project p;
//Initialize test object
public static void setUp() {
date = new Date();
e = new Employee("Alice", date);
p = new Project();
}
@Test
public void removeTeamMember_True_ifMemberIsSelected() {
assertEquals(true, p.removeTeamMember(e));
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments