DevAppServerTestRunner

com.google.appengine.tools.development.testing

Class DevAppServerTestRunner

  • java.lang.Object
    • BlockJUnit4ClassRunner
      • com.google.appengine.tools.development.testing.DevAppServerTestRunner


  • public class DevAppServerTestRunner
    extends BlockJUnit4ClassRunner
    A JUnit4 test runner that runs tests in the isolated classloader of a running app engine app. Test classes that are run with this test runner must also be annotated with DevAppServerTest. For example:
     @RunWith(DevAppServerTestRunner.class)
     @DevAppServerTest(MyTest.TestConfig.class)
     public void MyTest {
    
       private final LocalServiceTestHelper testHelper = new LocalServiceTestHelper(
         new LocalURLFetchServiceTestConfig(), new LocalDatastoreServiceTestConfig());
    
       public static class TestConfig extends BaseDevAppServerTestConfig {
    
         public File getSdkRoot() {
           return sdkRoot;
         }
    
         public File getAppDir() {
           return appDir;
         }
    
         public List getClasspath() {
           return urls;
         }
       }
    
       @Before
       public void setUpHelper() {
         testHelper.setUp();
       }
    
       @After
       public void tearDownHelper() {
         testHelper.tearDown();
       }
    
       @Test
       public void testEndToEnd() throws Exception {
         URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
         HTTPResponse resp = fetchService.fetch(new URL("http://localhost:" +
           System.getProperty(DevAppServerTest.DEFAULT_PORT_SYSTEM_PROPERTY) + "/insertFoo?id=33"));
         assertEquals(200, resp.getResponseCode());
         DatastoreServiceFactory.getDatastoreService().get(KeyFactory.createKey("foo", 33));
       }
     }
     
    • Constructor Summary

      Constructors 
      Constructor and Description
      DevAppServerTestRunner(java.lang.Class<?> klass) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      protected void collectInitializationErrors(java.util.List<java.lang.Throwable> errors) 
      protected Statement withAfterClasses(Statement statement) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DevAppServerTestRunner

        public DevAppServerTestRunner(java.lang.Class<?> klass)
                               throws InitializationError
        Throws:
        InitializationError
    • Method Detail

      • collectInitializationErrors

        protected void collectInitializationErrors(java.util.List<java.lang.Throwable> errors)
      • withAfterClasses

        protected Statement withAfterClasses(Statement statement)