【发布时间】:2020-10-31 13:48:43
【问题描述】:
我目前正在开发一个 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();
}
ListsServiceTest.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);
assertEquals(expectedLists, receivedLists);
verify(this.listRepository, times(1)).findAll();
}
【问题讨论】:
-
以后请不要发布错误信息的截图,而是将错误信息本身作为文本发布。
-
@JoachimSauer 我现在没有这样做,但我无法复制完整的错误。这就是我截屏的原因。但我以后不会这样做了
标签: java list spring-boot