我已经生成了一个类并使用 greendao 1.3.1 进行了测试,一切看起来都不错;但是,我无法运行生成的 dao 测试。引发 java.lang.RuntimeException 说明“找不到测试类”。我的其他 Android 测试用例运行良好。
这是生成的代码:
package com.amec.amecsurvey.test;
import de.greenrobot.dao.test.AbstractDaoTestLongPk;
import com.amec.amecsurvey.entities.Project;
import com.amec.amecsurvey.persistence.ProjectDao;
public class ProjectTest extends AbstractDaoTestLongPk<ProjectDao, Project> {
public ProjectTest() {
super(ProjectDao.class);
}
public void testProjectDao() throws Exception{
ProjectTest test = new ProjectTest();
Project project = test.createEntity(1l);
project.generateUUID();
project.setProjectNumber("CCTEST");
project.setName("Test Project");
test.dao.insert(project);
project = dao.load(1l);
assertNotNull(project);
Project dbProject = dao.load(1l);
assertTrue(project.equals(dbProject));
}
@Override
protected Project createEntity(Long key) {
Project entity = new Project();
entity.setId(key);
return entity;
}
}