I am trying to write unit tests for a Cloud Endpoints backend, specifically using Datastore. (Unit testing without access to any specific Android modules is working as expected.)
Per this question, I added the following to my backend's build.gradle:
testCompile 'com.google.appengine:appengine-api-labs:1.9.8'
testCompile 'com.google.appengine:appengine-api-stubs:1.9.8'
testCompile 'com.google.appengine:appengine-testing:1.9.8'
testCompile 'junit:junit:4.12+'
My code is minimized from this tutorial and located at backend/src/test/java/<package>:
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import org.junit.Test;
import static junit.framework.Assert.assertTrue;
public class ExampleDatastoreTest {
private final LocalServiceTestHelper datastoreHelper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
@org.junit.Before
public void setUp() throws Exception {
datastoreHelper.setUp();
}
@org.junit.After
public void tearDown() throws Exception {
datastoreHelper.tearDown();
}
@Test
public void testExample() {
assertTrue(true);
}
}
I am getting NoClassDefFoundError when I call tearDown on my LocalServiceTestHelper.
Per that tutorial, I still need to include:
${SDK_ROOT}/lib/impl/appengine-api.jar
${SDK_ROOT}/lib/impl/appengine-tools-sdk.jar
Using File > Project Structure in Android Studio 1.2.2, I found these options:
testCompile 'com.google.appengine:appengine-tools-sdk:1.9.25'
testCompile 'com.google.appengine:appengine-api-1.0-sdk:1.9.25'
testCompile 'com.google.appengine:appengine:1.9.25'
The appengine-tools-sdk looks good, but I don't seem to be able to find appengine-api. The two I listed above are the closest I found. I continue to get the same error.
What am I missing here?
Aucun commentaire:
Enregistrer un commentaire