即使已经注册,我也会在单元测试期间获得Class not registered exception。
这是我的测试:
public class BaseObjectifyTest {
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig(),
new LocalMemcacheServiceTestConfig());
Closeable session;
@Before
public void setup() {
helper.setUp();
session = ObjectifyService.begin();
}
@Test
public void testThis() {
MyEntity test = new MyEntity();
ObjectifyService.register(MyEntity.class);
ofy().save().entity(test).now();
}
@After
public void tearDown() throws IOException {
helper.tearDown();
session.close();
session = null;
}
}
我尝试过ObjectifyService.run()并得到相同的结果。任何帮助都会很棒!想写测试,如果这不起作用,我将不得不嘲笑客观化服务。客观化5.1.1
答案 0 :(得分:0)
在我的情况下,我使用的是JUnit和TestNG togeth,并且没有执行测试的设置。