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)
     &#64DevAppServerTest(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;
         }
       }
    
       &#64Before
       public void setUpHelper() {
         testHelper.setUp();
       }
    
       &#64After
       public void tearDownHelper() {
         testHelper.tearDown();
       }
    
       &#64Test
       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));
       }
     }
     </pre>
     </blockquote></div>
    </li>
    </ul>
    </div>
    <div class="summary">
    <ul class="blockList">
    <li class="blockList">
    <!-- ======== CONSTRUCTOR SUMMARY ======== -->
    <ul class="blockList">
    <li class="blockList"><a name="constructor.summary">
    <!--   -->
    </a>
    <h3>Constructor Summary</h3>
    <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
    <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
    <tr>
    <th class="colOne" scope="col">Constructor and Description</th>
    </tr>
    <tr class="altColor">
    <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../com/google/appengine/tools/development/testing/DevAppServerTestRunner.html#DevAppServerTestRunner-java.lang.Class-">DevAppServerTestRunner</a></span>(java.lang.Class&lt;?&gt;&nbsp;klass)</code>&nbsp;</td>
    </tr>
    </table>
    </li>
    </ul>
    <!-- ========== METHOD SUMMARY =========== -->
    <ul class="blockList">
    <li class="blockList"><a name="method.summary">
    <!--   -->
    </a>
    <h3>Method Summary</h3>
    <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
    <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a>