Hi Ravi
Following example puts data in [projectDir]/WEB-INF/appengine-
generated/local_db.bin
(not war/WEB-INF), and does not clear the data.
So testInsert2 will fail, and second running of testInsert1 will also
fail.
==
private static LocalServiceTestHelper helper;
@BeforeClass
public static void setUpBeforeClass() {
LocalDatastoreServiceTestConfig config = new
LocalDatastoreServiceTestConfig();
config.setNoStorage(false);
helper = new LocalServiceTestHelper(config);
helper.setUp();
}
@AfterClass
public static void tearDownAfterClass() {
// helper.tearDown();
ApiProxy.setDelegate(null);
ApiProxy.setEnvironmentForCurrentThread(null);
}
private void doTest() {
DatastoreService ds =
DatastoreServiceFactory.getDatastoreService();
ds.prepare(new Query("yam")).countEntities();
assertEquals(0, ds.prepare(new Query("yam")).countEntities());
ds.put(new Entity("yam"));
ds.put(new Entity("yam"));
assertEquals(2, ds.prepare(new Query("yam")).countEntities());
}
@Test
public void testInsert1() {
doTest();
}
@Test
public void testInsert2() {
doTest();
}
==
If you want to prepare data using tests, I think it's ok.
But if you want to run tests depending on other tests, I don't
recommend that.
Tests should be independent of other tests.
- bufferings
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.