org.testng.IHookCallBack Java Examples

The following examples show how to use org.testng.IHookCallBack. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuickPerfTestNGListener.java    From quickperf with Apache License 2.0 5 votes vote down vote up
@Override
public void run(IHookCallBack hookCallBack, ITestResult testResult) {

    TestExecutionContext testExecutionContext = buildTestExecutionContext(testResult);

    if(testExecutionContext.isQuickPerfDisabled()) {
        hookCallBack.runTestMethod(testResult);
        return;
    }

    if(SystemProperties.TEST_CODE_EXECUTING_IN_NEW_JVM.evaluate()) {
        executeTestMethodInNewJvmAndRecordPerformance(testResult, testExecutionContext);
        return;
    }

    JvmOrTestIssue jvmOrTestIssue =
            executeTestMethodAndRecordPerformance(hookCallBack, testResult, testExecutionContext);

    SetOfAnnotationConfigs testAnnotationConfigs = quickPerfConfigs.getTestAnnotationConfigs();
    Collection<PerfIssuesToFormat> groupOfPerfIssuesToFormat = perfIssuesEvaluator.evaluatePerfIssuesIfNoJvmIssue(testAnnotationConfigs
                                                                                                                , testExecutionContext
                                                                                                                , jvmOrTestIssue);

    testExecutionContext.cleanResources();

    try {
        quickPerfReporter.report(jvmOrTestIssue, groupOfPerfIssuesToFormat, testExecutionContext);
    } catch (Throwable throwable) {
        testResult.setThrowable(throwable);
        testResult.setStatus(ITestResult.FAILURE);
    }

}
 
Example #2
Source File: QuickPerfTestNGListener.java    From quickperf with Apache License 2.0 5 votes vote down vote up
private JvmOrTestIssue executeTestMethodAndRecordPerformance(IHookCallBack hookCallBack
                                                                     , ITestResult testResult
                                                                     , TestExecutionContext testExecutionContext) {
    if (testExecutionContext.testExecutionUsesTwoJVMs()) {
        Method testMethod = extractTestMethod(testResult);
        return executeTestMethodInNewJwm(testMethod, testExecutionContext);
    }

    TestIssue testIssue = executeTestMethodAndRecordPerformanceInSameJvm(hookCallBack, testResult, testExecutionContext);
    return JvmOrTestIssue.buildFrom(testIssue);
}
 
Example #3
Source File: QuickPerfTestNGListener.java    From quickperf with Apache License 2.0 5 votes vote down vote up
private TestIssue executeTestMethodAndRecordPerformanceInSameJvm(IHookCallBack hookCallBack, ITestResult testResult, TestExecutionContext testExecutionContext) {
    performanceRecording.start(testExecutionContext);
    try {
        hookCallBack.runTestMethod(testResult);
        return TestIssue.NONE;
    } catch (Throwable throwable) {
        return TestIssue.buildFrom(throwable);
    } finally {
        performanceRecording.stop(testExecutionContext);
    }
}
 
Example #4
Source File: AbstractTestNGSpringContextTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Delegates to the {@link IHookCallBack#runTestMethod(ITestResult) test
 * method} in the supplied {@code callback} to execute the actual test
 * and then tracks the exception thrown during test execution, if any.
 *
 * @see org.testng.IHookable#run(org.testng.IHookCallBack,
 * org.testng.ITestResult)
 */
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
	callBack.runTestMethod(testResult);

	Throwable testResultException = testResult.getThrowable();
	if (testResultException instanceof InvocationTargetException) {
		testResultException = ((InvocationTargetException) testResultException).getCause();
	}
	this.testException = testResultException;
}
 
Example #5
Source File: ProgrammaticTxMgmtTestNGTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
	this.method = testResult.getMethod().getMethodName();
	super.run(callBack, testResult);
}
 
Example #6
Source File: ProgrammaticTxMgmtTestNGTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
	this.method = testResult.getMethod().getMethodName();
	super.run(callBack, testResult);
}
 
Example #7
Source File: ServiceTestBase.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void run(IHookCallBack hookCallBack) {
}
 
Example #8
Source File: DaoTestBase.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void run(IHookCallBack hookCallBack) {
}
 
Example #9
Source File: ProgrammaticTxMgmtTestNGTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
	this.method = testResult.getMethod().getMethodName();
	super.run(callBack, testResult);
}