private static Throwable getConfigFailureException(ITestContext context) { for (IInvokedMethod method : context.getSuite().getAllInvokedMethods()) { ITestNGMethod m = method.getTestMethod(); if (m.isBeforeSuiteConfiguration() && (!method.getTestResult().isSuccess())) { return method.getTestResult().getThrowable(); } } return null; }
@Override public void printStackTrace(PrintStream s) { reduceStackTrace(); super.printStackTrace(s); }
private Throwable getTestResultException(ITestResult testResult) { Throwable testResultException = testResult.getThrowable(); if (testResultException instanceof InvocationTargetException) { testResultException = ((InvocationTargetException) testResultException).getCause(); } return testResultException; }
@AfterClass void afterClass() { assertEquals(numSetUpCalls, NUM_TESTS, "number of calls to setUp()."); assertEquals(numSetUpCallsInTransaction, NUM_TX_TESTS, "number of calls to setUp() within a transaction."); assertEquals(numTearDownCalls, NUM_TESTS, "number of calls to tearDown()."); assertEquals(numTearDownCallsInTransaction, NUM_TX_TESTS, "number of calls to tearDown() within a transaction."); }
@Test(dependsOnMethods = { "verifyContextWasDirtied" }) public void verifyContextWasNotDirtied() { assertSame(this.applicationContext, this.dirtiedApplicationContext, "The application context should NOT have been 'dirtied'."); }
@Override public void afterTestExecution(TestContext testContext) { org.testng.Assert.fail("always failing afterTestExecution()"); } }
private void assertNumRowsInPersonTable(int expectedNumRows, String testState) { assertEquals(countRowsInTable("person"), expectedNumRows, "the number of rows in the person table (" + testState + ")."); }
protected void assertApplicationContextWasAutowired() { org.testng.Assert.assertNotNull(this.applicationContext, "The application context should have been autowired."); } }
@Override public void run(IHookCallBack callBack, ITestResult testResult) { this.method = testResult.getMethod().getMethodName(); super.run(callBack, testResult); }
@Override public void onFinish(ITestContext testContext) { this.failedConfigurationsCount += testContext.getFailedConfigurations().size(); }
@AfterClass void afterClass() { assertEquals(numSetUpCalls, NUM_TESTS, "number of calls to setUp()."); assertEquals(numSetUpCallsInTransaction, NUM_TX_TESTS, "number of calls to setUp() within a transaction."); assertEquals(numTearDownCalls, NUM_TESTS, "number of calls to tearDown()."); assertEquals(numTearDownCallsInTransaction, NUM_TX_TESTS, "number of calls to tearDown() within a transaction."); }
@Override public void afterTestMethod(TestContext testContext) { org.testng.Assert.fail("always failing afterTestMethod()"); } }
private void performCommonAssertions() { assertInTransaction(true); assertNotNull(super.applicationContext, "The application context should have been set due to ApplicationContextAware semantics."); assertNotNull(super.jdbcTemplate, "The JdbcTemplate should have been created in setDataSource() via DI for the DataSource."); }
@Override public void beforeTestMethod(TestContext testContext) { org.testng.Assert.fail("always failing beforeTestMethod()"); } }
@Override public void afterTestClass(TestContext testContext) { org.testng.Assert.fail("always failing afterTestClass()"); } }
@Override public void prepareTestInstance(TestContext testContext) throws Exception { org.testng.Assert.fail("always failing prepareTestInstance()"); } }
@Override public void beforeTestClass(TestContext testContext) { org.testng.Assert.fail("always failing beforeTestClass()"); } }
@Override public void beforeTestExecution(TestContext testContext) { org.testng.Assert.fail("always failing beforeTestExecution()"); } }
@AfterTransaction public void afterTransaction() { org.testng.Assert.fail("always failing afterTransaction()"); } }
@BeforeTransaction public void beforeTransaction() { org.testng.Assert.fail("always failing beforeTransaction()"); } }