Methods Summary |
---|
protected void | setUp()
super.setUp();
mStubContext = new StubContext(getClass().getClassLoader());
mAndroidTestRunner = new AndroidTestRunner();
mAndroidTestRunner.setContext(mStubContext);
|
public void | testLoadNoTestCases()
mAndroidTestRunner.setTestClassName(TestSuite.class.getName(), null);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
assertNotNull(testCases);
assertEquals(1, testCases.size());
assertEquals("warning", testCases.get(0).getName());
assertEquals(TestSuite.class.getSimpleName(), mAndroidTestRunner.getTestClassName());
|
public void | testRunSingleTestMethod()
String testMethodName = "testTwo";
mAndroidTestRunner.setTestClassName(TwoTestTestCase.class.getName(), testMethodName);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
List<String> testNames = Lists.newArrayList();
for (TestCase testCase : testCases) {
testNames.add(testCase.getName());
}
assertEquals(Arrays.asList(testMethodName), testNames);
|
public void | testRunSkipExecution()
String testMethodName = "testFail";
mAndroidTestRunner.setTestClassName(
OnePassOneErrorOneFailTestCase.class.getName(), testMethodName);
TestListenerStub testListenerStub = new TestListenerStub();
mAndroidTestRunner.addTestListener(testListenerStub);
// running the failing test should pass - ie as if its not run
mAndroidTestRunner.runTest();
assertTrue(testListenerStub.saw("testFail"));
|
public void | testRunTest()
mAndroidTestRunner.setTestClassName(OneTestTestCase.class.getName(), null);
TestListenerStub testListenerStub = new TestListenerStub();
mAndroidTestRunner.addTestListener(testListenerStub);
mAndroidTestRunner.runTest();
assertTrue(testListenerStub.saw("testOne"));
|
public void | testRunTestWithAndroidTestCase()
mAndroidTestRunner.setTestClassName(
OneAndroidTestTestCase.class.getName(), "testOneAndroid");
TestListenerStub testListenerStub = new TestListenerStub();
mAndroidTestRunner.addTestListener(testListenerStub);
assertNull(((AndroidTestCase) mAndroidTestRunner.getTestCases().get(0)).getContext());
mAndroidTestRunner.runTest();
assertTrue(testListenerStub.saw("testOneAndroid"));
assertSame(mStubContext,
((AndroidTestCase) mAndroidTestRunner.getTestCases().get(0)).getContext());
|
public void | testRunTestWithAndroidTestCaseInNestedSuite()
mAndroidTestRunner.setTestClassName(AndroidTestCaseTestSuite.class.getName(), null);
TestListenerStub testListenerStub = new TestListenerStub();
mAndroidTestRunner.addTestListener(testListenerStub);
mAndroidTestRunner.runTest();
assertTrue(testListenerStub.saw("testOneAndroid"));
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
for (TestCase testCase : testCases) {
assertSame(mStubContext, ((AndroidTestCase) testCase).getContext());
}
|
public void | testRunTestWithAndroidTestCaseInSuite()
mAndroidTestRunner.setTestClassName(OneAndroidTestTestCase.class.getName(), null);
TestListenerStub testListenerStub = new TestListenerStub();
mAndroidTestRunner.addTestListener(testListenerStub);
mAndroidTestRunner.runTest();
assertTrue(testListenerStub.saw("testOneAndroid"));
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
for (TestCase testCase : testCases) {
assertSame(mStubContext, ((AndroidTestCase) testCase).getContext());
}
|
public void | testRunTestWithNullListener()
mAndroidTestRunner.setTestClassName(OneTestTestCase.class.getName(), null);
mAndroidTestRunner.addTestListener(null);
try {
mAndroidTestRunner.runTest();
} catch (NullPointerException e) {
fail("Should not add a null TestListener");
}
|
public void | testSetTestClassInvalidClass()
try {
mAndroidTestRunner.setTestClassName("class.that.does.not.exist", null);
fail("expected exception not thrown");
} catch (RuntimeException e) {
// expected
}
|
public void | testSetTestClassWithTestSuite()
mAndroidTestRunner.setTestClassName(SampleTestSuite.class.getName(), null);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
List<String> testNames = Lists.newArrayList();
for (TestCase testCase : testCases) {
testNames.add(testCase.getName());
}
assertEquals(Arrays.asList("testOne", "testOne", "testTwo"), testNames);
|
public void | testSetTestClassWithTestSuiteProvider()
mAndroidTestRunner.setTestClassName(SampleTestSuiteProvider.class.getName(), null);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
List<String> testNames = Lists.newArrayList();
for (TestCase testCase : testCases) {
testNames.add(testCase.getName());
}
// Use the test suite provided by the interface method rather than the static suite method.
assertEquals(Arrays.asList("testOne"), testNames);
|
public void | testSetTestSuiteWithOneTestCase()
mAndroidTestRunner.setTestClassName(OneTestTestCase.class.getName(), null);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
assertNotNull(testCases);
assertEquals(1, testCases.size());
assertEquals("testOne", testCases.get(0).getName());
assertEquals(OneTestTestCase.class.getSimpleName(), mAndroidTestRunner.getTestClassName());
|