This is to be expected. You're tearing down the helper between test runs.

All tests are green because you are not using assertions. Example:

assertNotNull(someInstance);

There's something very bad happening in these tests: you don't ever want
state to leak across tests. This is a very bad practice. You want each test
to exist in its own universe. When state leaks across tests, you become
dependent on the order of the tests being run (not guaranteed). You also
can't parallelize tests (this is important to some people). Your tests also
become incredible brittle because if a single test fails in the middle of
the chain, you have a ton of tests that will fail after it that you might
never be able to fix because they were all dependent on a state change in
the failing test  - you want that test and only that test to fail.

Here's how you should write the test instead:

@Test public void testFetch() {
            final EntityController ec = new EntityController();  // There's
no point caching this. Again, don't want to leak state.
        final Flight flight = new Flight("origin", "destination"); // There
also isn't really a point in making any of these final, but that's a minor
nitpick
        ec.create(flight);
        Flight returnedFlight = ec.find(Flight.class, 1);
        assertNotNull("Should be able to find a Flight that was just
created", returnedFlight);
}

--
Ikai Lan
Developer Programs Engineer, Google App Engine
plus.ikailan.com | twitter.com/ikai



On Fri, Dec 16, 2011 at 6:11 AM, Alexander Orlov
<alexander.or...@loxal.net>wrote:

> All tests are green but *retrive()* resp. *zFind()* are *empty* resp *
> null.*
>
> public class InitDatastore extends Common {
>     private final LocalServiceTestHelper helper =
>             new LocalServiceTestHelper(new
> LocalDatastoreServiceTestConfig());
>     final EntityController ec = new EntityController();
>
>     @Before
>     public void setUp() {
>         helper.setUp();
>     }
>
>     @After
>     public void tearDown() {
>         helper.tearDown();
>     }
>
>     @Test
>     public void create() {
>         final Flight flight = new Flight("origin", "destination");
>         ec.create(flight);
>     }
>
>     @Test
>     public void retrieve() {
>         System.err.println("isEmpty = " +
> ec.retrieve(Flight.class).isEmpty());
>     }
>
>     @Test
>     public void zFind() {
>         System.out.println("flight###1 = " + ec.find(Flight.class, 1));
>     }
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine-java/-/78mOAWSJ86EJ.
> To post to this group, send email to
> google-appengine-java@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
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 google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to