App Engine is so great that you can not write unit tests using entities even if you don't persist them. Just calling the constructor of an entity makes all the datastore stuff load which is slow. You do not want your unit test to take 1 minute to run, do you? What we have done to be able to write unit tests is to not create objects directly but use a factory. So we have an EntitiesFactory which give us objects which are not actual entities but have the same properties. Apart from the benefit of running tests fast and isolated (because they are not real entities they can't alter database), we get a new layer that makes it easy to migrate to other persistence mechanisms.
Cheers On 28 oct, 19:52, "Ikai Lan (Google)" <[email protected]> wrote: > Do you need to mock Entity? Can you use a real instance of an Entity and > check for state changes? You can mock out DatastoreService, so it might make > more sense to write your expects() in those mocks instead. Entity classes > only really have getProperty() and setProperty(), and in my opinion, it's > not worth writing tests to see if these get called. What are you trying to > do? > > -- > Ikai Lan > Developer Programs Engineer, Google App Engine > Blogger:http://googleappengine.blogspot.com > Reddit:http://www.reddit.com/r/appengine > Twitter:http://twitter.com/app_engine > > On Thu, Oct 28, 2010 at 9:31 AM, Mayumi Liyanage < > > [email protected]> wrote: > > In the project I'm working on we are using GWT + GAE. We are unit > > testing using automocking container Jukito (http://code.google.com/p/ > > jukito/) which is build on top of Mokito (http://code.google.com/p/ > > mockito/) + JUnit. > > The problem is unit testing the Mapper API. Since Mapper API's map > > method takes an Entity as a argument so testing framework will have to > > have access to this Entity class. However we could not mock the Entity > > class since it is a final class. Also, we could not instantiate the > > Entity class outside of GAE environment. ' > > Does anyone have workaround for unit testing using Entity? > > > Thanks. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google App Engine" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<google-appengine%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-appengine?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" 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?hl=en.
