gpt4 book ai didi

android - 测试房间数据库,可迭代包含 "Item"但 !item 0 是 "Item"

转载 作者:行者123 更新时间:2023-11-28 21:35:37 27 4
gpt4 key购买 nike

下午好,

我按数据库搜索以测试特定类测试,当我放置一个新项目时,如果列表包含该项目。

@Test
public void insertAndDeleteTask() throws InterruptedException {


Project projectTartampion = new Project(1L, "Projet Tartampion", 0xFFEADAD1);
long projectID1L = projectDao.inserProject(projectTartampion);
Task task1L = new Task(1,projectID1L,"Test",3);
taskDao.insertTask(task1L);


List<Project> allProjects = LiveDataTestUtil.getValue(projectDao.getAllProjects());
assertNotNull(allProjects);
assertFalse(allProjects.isEmpty());

List<Task> allTasks = LiveDataTestUtil.getValue(taskDao.getAllTasks());
assertNotNull(allTasks);
assertFalse(allTasks.isEmpty());

Log.i("TAG","***********************************"+LiveDataTestUtil.getValue(taskDao.getAllTasks()));

assertThat(allTasks, contains(task1L));//HERE TO TEST IF allTasks contains task1L/////

日志测试的错误结果:

iterable containing info Task{id=1, projectId=1, name='Test', creationTimestamp=3}
but: item 0: was Task{id=1, projectId=1, name='Test', creationTimestamp=3}

但我不完全明白发生了什么,因为当我使用 Log.i 查看我的项目是否在列表中时,它是打开的。

感谢您的回答

最佳答案

确切的错误信息是:

Expected: iterable containing [<Task{id=1, projectId=1, name='Test', creationTimestamp=3}>]
but: item 0: was <Task{id=1, projectId=1, name='Test', creationTimestamp=3}>

谢谢

关于android - 测试房间数据库,可迭代包含 "Item"但 !item 0 是 "Item",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59116332/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com