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 withDevAppServerTest
. 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)); } } </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"> </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<?> klass)</code> </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"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr id="i0" class="altColor"> <td class="colFirst"><code>protected void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/google/appengine/tools/development/testing/DevAppServerTestRunner.html#collectInitializationErrors-java.util.List-">collectInitializationErrors</a></span>(java.util.List<java.lang.Throwable> errors)</code> </td> </tr> <tr id="i1" class="rowColor"> <td class="colFirst"><code>protected Statement</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/google/appengine/tools/development/testing/DevAppServerTestRunner.html#withAfterClasses-Statement-">withAfterClasses</a></span>(Statement statement)</code> </td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> <!-- --> </a> <h3>Methods inherited from class java.lang.Object</h3> <code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li> </ul> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <!-- ========= CONSTRUCTOR DETAIL ======== --> <ul class="blockList"> <li class="blockList"><a name="constructor.detail"> <!-- --> </a> <h3>Constructor Detail</h3> <a name="DevAppServerTestRunner-java.lang.Class-"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>DevAppServerTestRunner</h4> <pre>public DevAppServerTestRunner(java.lang.Class<?> klass) throws InitializationError</pre> <dl> <dt><span class="throwsLabel">Throws:</span></dt> <dd><code>InitializationError</code></dd> </dl> </li> </ul> </li> </ul> <!-- ============ METHOD DETAIL ========== --> <ul class="blockList"> <li class="blockList"><a name="method.detail"> <!-- --> </a> <h3>Method Detail</h3> <a name="collectInitializationErrors-java.util.List-"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>collectInitializationErrors</h4> <pre>protected void collectInitializationErrors(java.util.List<java.lang.Throwable> errors)</pre> </li> </ul> <a name="withAfterClasses-Statement-"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>withAfterClasses</h4> <pre>protected Statement withAfterClasses(Statement statement)</pre> </li> </ul> </li> </ul> </li> </ul> </div> </div> <!-- ========= END OF CLASS DATA ========= --> </body> </html>