我想用gwt junit测试我的gwt应用程序,但似乎无法正确设置事物,使得对象化测试。 所有教程演示了测试数据存储而不是客体(这是数据库服务的更高层次) 我进行测试的基类看起来是这样的:gwt junit测试对象化
public class TestBase {
private static final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
protected static ObjectifyFactory fact;
@BeforeClass
public static void setUp() {
helper.setUp();
fact = new ObjectifyFactory() {
@Override
public Objectify begin(ObjectifyOpts opts)
{
opts.setSessionCache(false);
return super.begin(opts);
}
};
}
@AfterClass
public static void tearDown() {
helper.tearDown();
}
}
然后,我有一个扩展的基类:
public class UserServiceTest extends TestBase{
private User inactiveUser;
private UserService us;
Objectify _ofy;
@Rule
public ExpectedException thrown = ExpectedException.none();
@Before
public void beforeTest() {
//Register the classes used in the test
fact.register(User.class);
us = new UserService();
inactiveUser = new User();
}
@Test
public void basicTest(){
Objectify ofy = ObjectifyService.begin();
ofy.put(inactiveUser); //This fails with exception: An exception occurred: com.google.apphosting.api.ApiProxy$CallNotFoundException
//My goal is to reach these test but "addUser" uses also objectify
//UserService.addUser("[email protected]", "bye");
//assertNotNull(inactiveUser.get_id());
}
你知道我做错了什么吗?我找遍了整个互联网,没有发现溶液(有的甚至说要删除的.classpath应用引擎-SDK,但dosent似乎工作。
谢谢。
这与GWT有什么关系?我在这里只看到普通的JUnit,AppEngine和Objectify。 –
嗨托马斯,我的项目是一个gwt项目,我正在运行gwt junit测试。 – Michael
那么,这是一个JUnit 4测试,而不是GWTTestCase,所以它很难被称为“gwt junit测试”;这只是一个普通的JUnit测试,它没有任何与GWT相关的测试;就这个测试而言,在同一个项目中使用GWT并不重要。 –