I foolishly tried to simultaneously upgrade from v5 to v6, and from old gradle plugin to cloud SDK.
All my unit tests were failing bizarrely with things like:
@Test
public void example_test() {
List<SCFUser> users = ofy().load().type(SCFUser.class).list();
createUser(...);
assertEquals(1, users.size());
}
java.lang.AssertionError:
Expected :1
Actual :22439
Each time I ran the test, the actual count was increasing. I was getting really confused until I realised it was authenticated against my LIVE DATASTORE and writing dummy data to that! GAH!
Luckily it was easy to tidy up but could have been a nightmare.
My question is, how should I be configuring unit tests with objectify v6? I was hoping I could use the in-memory datastore for fast, reproducible tests... I can't find any documentation anywhere for what I want to do.