Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine Appengine单元测试失败,Objectify-未注册任何类_Google App Engine_Objectify - Fatal编程技术网

Google app engine Appengine单元测试失败,Objectify-未注册任何类

Google app engine Appengine单元测试失败,Objectify-未注册任何类,google-app-engine,objectify,Google App Engine,Objectify,在单元测试期间,我得到了类未注册的异常,即使它已注册 这是我的测试: public class BaseObjectifyTest { private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig(), new LocalMemcacheServiceTestConfig

在单元测试期间,我得到了类未注册的异常,即使它已注册

这是我的测试:

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()并得到了相同的结果。任何帮助都会很好!希望编写测试,如果这不起作用,我将不得不模拟objectify服务。Objectify 5.1.1

在我的例子中,我将JUnit和TestNG结合使用,测试的设置没有被执行。

胡乱猜测:您的ofy()的静态导入不是ObjectifyService。ofyIt是。现在,我正在尝试复制Objectify项目中的测试,并使用TestObjectifyService.ofy-仍然不工作堆栈跟踪将有所帮助-它可能与测试执行顺序和静态/属性初始化顺序有关。谢谢大家的评论。我发现了问题。我同时使用JUnit和TestNG,测试的设置没有执行。现在一切都好了。@Patrick是否添加您的评论作为答案?