Class DevAppServerTestRunner

java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
com.google.appengine.tools.development.testing.DevAppServerTestRunner
All Implemented Interfaces:
org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Orderable, org.junit.runner.manipulation.Sortable

public class DevAppServerTestRunner extends org.junit.runners.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:
 invalid input: '&#64'RunWith(DevAppServerTestRunner.class)
 invalid input: '&#64'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;
     }
   }

   invalid input: '&#64'Before
   public void setUpHelper() {
     testHelper.setUp();
   }

   invalid input: '&#64'After
   public void tearDownHelper() {
     testHelper.tearDown();
   }

   invalid input: '&#64'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
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected org.junit.runners.model.Statement
    withAfterClasses(org.junit.runners.model.Statement statement)
     

    Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner

    computeTestMethods, createTest, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout

    Methods inherited from class org.junit.runners.ParentRunner

    childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withBeforeClasses, withInterruptIsolation

    Methods inherited from class org.junit.runner.Runner

    testCount

    Methods inherited from class java.lang.Object

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

    • DevAppServerTestRunner

      public DevAppServerTestRunner(Class<?> klass) throws org.junit.runners.model.InitializationError
      Throws:
      org.junit.runners.model.InitializationError
  • Method Details

    • collectInitializationErrors

      protected void collectInitializationErrors(List<Throwable> errors)
      Overrides:
      collectInitializationErrors in class org.junit.runners.BlockJUnit4ClassRunner
    • withAfterClasses

      protected org.junit.runners.model.Statement withAfterClasses(org.junit.runners.model.Statement statement)
      Overrides:
      withAfterClasses in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>