Incorrect configuration of the App Engine test environment

I am trying to use unit test app api endpoint. I follow the example from udacity . They seem to be using LocalServiceTestHelper , but I'm trying to figure out why, since it is not used later in the code.

Here is my gradle backend file:

 buildscript { repositories { jcenter() } dependencies { classpath 'com.google.appengine:gradle-appengine-plugin:1.9.28' } } repositories { jcenter(); } apply plugin: 'java' apply plugin: 'war' apply plugin: 'appengine' sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 dependencies { appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.28' compile 'com.google.appengine:appengine-endpoints:1.9.28' compile 'com.google.appengine:appengine-endpoints-deps:1.9.28' compile 'javax.servlet:servlet-api:2.5' compile 'com.googlecode.objectify:objectify:5.0.3' compile 'javax.jdo:jdo-api:3.0.1' compile 'junit:junit:4.12' compile 'com.google.appengine:appengine-testing:1.9.24' } appengine { downloadSdk = true appcfg { oauth2 = true } endpoints { getClientLibsOnBuild = true getDiscoveryDocsOnBuild = true } } 

Here is the Endpoint test class (import instructions and other trivial details were omitted for brevity):

 private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig() .setDefaultHighRepJobPolicyUnappliedJobPercentage(100)); /** * Set up the local service tester before running tests and an instance of the magpieApi. * @throws Exception */ @Before public void setUp() throws Exception { //helper.setUp(); user = new User(EMAIL, "gmail.com" ,USER_ID); magpieApi = new MagpieEndpoint(); } /** * After running tests clear objectify and tear down the local test helper. * @throws Exception */ @After public void tearDown() throws Exception { ofy().clear(); helper.tearDown(); } 

Here is the important part of the error log:

 java.lang.NoClassDefFoundError: com/google/appengine/api/datastore/dev/LocalDatastoreService$AutoIdAllocationPolicy at com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig.<init>(LocalDatastoreServiceTestConfig.java:24) at test.MagpieEndpointTest.<init>(MagpieEndpointTest.java:54) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.datastore.dev.LocalDatastoreService$AutoIdAllocationPolicy 

I am new to the Google engine and have never tested my code before. There are no syntax errors, so I'm curious what causes the problem. Line 54 is obviously the source of the problem in which I initiate and declare a helper variable.

+5
source share

All Articles