我为我的一种方法创建了一个单元测试,但我不知道为什么会出现这个错误。我对 Java 比较陌生,我知道当您传递的变量之一为 null 时会发生 NullPointerException 错误,但我不确定它在我的代码中的位置。任何帮助将不胜感激,谢谢!
public void testCreateProject() throws TrexException {
TrexProject project = new TrexProject();
String projectName = "CoolNewProject";
project.setTitle(projectName);
try {
final List<TrexProject> projects = this.getTrexProjectService().findAllProjects();
Assert.assertNotNull(projects);
final int count = projects.size();
project = this.getTrexProjectService().createProject("Project-" + UUID.randomUUID().toString());
Assert.assertNotNull(project);
final List<TrexProject> projects2 = this.getTrexProjectService().findAllProjects();
Assert.assertNotNull(projects2);
Assert.assertEquals(count + 1, projects2.size());
} finally {
if (project != null) {
this.getTrexProjectLifecycleService().deleteProject(project.getTrexProjectId());
}
}
}