我目前正在开发一个 Spring Boot 应用程序,我正在其中编写单元测试。但是当我运行命令“mvn test”时,出现以下错误:
这是代码
BoardServiceTest.java
@Test
public void testGetBoards() {
Set<Lists> list = new HashSet<Lists>();
List<Board> expectedBoards = List.of(
new Board(1, "Studie", list),
new Board(2, "Todo Applicatie", list)
);
when(this.boardRepo.findAll()).thenReturn(expectedBoards);
var receivedBoards = this.boardService.getBoards();
assertEquals(expectedBoards, receivedBoards);
verify(this.boardRepo, times(1)).findAll();
}
Run Code Online (Sandbox Code Playgroud)
列表服务测试.java
@Test
public void testGetLists() throws Exception {
int boardId = 1;
Set<Task> task = new HashSet<>();
List<Lists> expectedLists = List.of(
new Lists(1, "registered", new Board(), task),
new Lists(2, "open", new Board(), task)
);
when(this.listRepository.findAll()).thenReturn(expectedLists);
var receivedLists = this.listService.getLists(boardId); …Run Code Online (Sandbox Code Playgroud)