This is the test class, It runs pretty well initially but after fixing some bugs from javax validation it started giving error
**Actually I am new to JUnit testing and am very confused with this error I am getting. The error, Null Pointer exception. Please I will appreciate I some can lead me to solution **
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
class NhSystemApplicationTests {
@Autowired
private UserService userService;
@Autowired
private TaskService taskService;
@Before(value = "")
public void initDb() {
{
User newUser = new User("testUser@mail.com", "testUser", "****");
userService.createUser(newUser);
}
{
User newUser = new User("testAdmin@mail.com", "testUser", "*****");
userService.createUser(newUser);
}
Task userTask = new Task("02/01/2018", "00:11", "11:00", "You need to work Today");
User user = userService.findOne("testUser@mail.com");
taskService.addTask(userTask, user);
}
@Test
public void testUser() {
User user = userService.findOne("testUser@mail.com");
assertNotNull(user);
User admin= userService.findOne("testAdmin@mail.com");
assertEquals(admin.getEmail(), "testAdmin@mail.com");
}
@Test
public void testTask() {
User user = userService.findOne("testUser@mail.com");
List<Task> task = taskService.findUserTask(user);
assertNotNull(task);
}
}
Here is the image of the error java.lang.NullPointerException
Aucun commentaire:
Enregistrer un commentaire