LocalServiceTestHelper

com.google.appengine.tools.development.testing

Class LocalServiceTestHelper

  • java.lang.Object
    • com.google.appengine.tools.development.testing.LocalServiceTestHelper


  • public class LocalServiceTestHelper
    extends java.lang.Object
    Helper class for testing against local app engine services. Construct the helper with one LocalServiceTestConfig instance for each service that you wish to access as part of your test. Then call setUp() before each test executes and tearDown() after each test executes. No specific test-harness is assumed, but here's a JUnit 3 example that uses task queues and the datastore.
     public void MyTest extends TestCase {
    
       private final LocalServiceTestHelper helper = new LocalServiceTestHelper(
         new LocalTaskQueueTestConfig(), new LocalDatastoreServiceTestConfig());
    
       @Override
       public void setUp() {
         super.setUp();
         helper.setUp();
       }
    
       @Override
       public void tearDown() {
         helper.tearDown();
         super.tearDown();
       }
     }
     
    • Constructor Detail

      • LocalServiceTestHelper

        public LocalServiceTestHelper(LocalServiceTestConfig... configs)
        Constructs a LocalServiceTestHelper with the provided configurations.
        Parameters:
        configs - for the local services that need to be set up and torn down.
    • Method Detail

      • setEnvAppId

        public LocalServiceTestHelper setEnvAppId(java.lang.String envAppId)
        The value to be returned by ApiProxy.getCurrentEnvironment().getAppId()
        Parameters:
        envAppId -
        Returns:
        this (for chaining)
      • setEnvModuleId

        public LocalServiceTestHelper setEnvModuleId(java.lang.String envModuleId)
        The value to be returned by ApiProxy.getCurrentEnvironment(