本文整理匯總了Java中org.testng.IInvokedMethod類的典型用法代碼示例。如果您正苦於以下問題:Java IInvokedMethod類的具體用法?Java IInvokedMethod怎麽用?Java IInvokedMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IInvokedMethod類屬於org.testng包,在下文中一共展示了IInvokedMethod類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: beforeInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
public void beforeInvocation(IInvokedMethod method, ITestResult tr,
ITestContext context) {
QAFTestBase stb = TestBaseProvider.instance().get();
stb.getLog().clear();
stb.clearVerificationErrors();
stb.getCheckPointResults().clear();
logger.debug("beforeInvocation: " + method.getTestMethod().getMethodName());
tr.setAttribute("context", context);
ConfigurationManager.getBundle().setProperty(ApplicationProperties.CURRENT_TEST_CONTEXT.key, context);
ConfigurationManager.getBundle().setProperty(ApplicationProperties.CURRENT_TEST_NAME.key,
tr.getName());
ConfigurationManager.getBundle().setProperty(ApplicationProperties.CURRENT_TEST_DESCRIPTION.key,
tr.getMethod().getDescription());
ConfigurationManager.getBundle().setProperty(ApplicationProperties.CURRENT_TEST_RESULT.key,
tr);
}
示例2: afterInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) {
if (method.isTestMethod() && testResult.getStatus() == SUCCESS) {
try {
getSoftAssert().assertAll();
} catch (AssertionError e) {
testResult.getTestContext().getPassedTests().removeResult(testResult.getMethod());
testResult.setStatus(TestResult.FAILURE);
testResult.setThrowable(e);
}
THREAD_LOCAL_CONTAINER_FOR_SOFT_ASSERTIONS.remove();
}
}
示例3: afterInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void afterInvocation(final IInvokedMethod method, final ITestResult testResult,
final ITestContext context) {
final ITestNGMethod testMethod = method.getTestMethod();
if (isSupportedConfigurationFixture(testMethod)) {
final String executableUuid = currentExecutable.get();
currentExecutable.remove();
if (testResult.isSuccess()) {
getLifecycle().updateFixture(executableUuid, result -> result.withStatus(Status.PASSED));
} else {
getLifecycle().updateFixture(executableUuid, result -> result
.withStatus(getStatus(testResult.getThrowable()))
.withStatusDetails(getStatusDetails(testResult.getThrowable()).orElse(null)));
}
getLifecycle().stopFixture(executableUuid);
if (testMethod.isBeforeMethodConfiguration() || testMethod.isAfterMethodConfiguration()) {
final String containerUuid = currentTestContainer.get();
validateContainerExists(getQualifiedName(testMethod), containerUuid);
currentTestContainer.remove();
getLifecycle().stopTestContainer(containerUuid);
getLifecycle().writeTestContainer(containerUuid);
}
}
}
示例4: onTestSkipped
import org.testng.IInvokedMethod; //導入依賴的package包/類
/**
* [ITestListener]
* Invoked each time a test is skipped.
*
* @param result {@code ITestResult} containing information about the run test
* @see ITestResult#SKIP
*/
@Override
public void onTestSkipped(ITestResult result) {
// >>>>> ENTER workaround for TestNG bug
// https://github.com/cbeust/testng/issues/1602
ITestContext context = result.getTestContext();
IInvokedMethod method = new InvokedMethod(
result.getTestClass(), result.getMethod(), System.currentTimeMillis(), result);
beforeInvocation(method, result, context);
// <<<<< LEAVE workaround for TestNG bug
synchronized (testListeners) {
for (ITestListener testListener : testListeners) {
testListener.onTestSkipped(result);
}
}
}
示例5: afterInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
if (testResult.getInstance() instanceof IInvokedMethodListenerEx) {
((IInvokedMethodListenerEx) testResult.getInstance()).afterInvocation(method, testResult);
}
if (method.getTestMethod().isBeforeMethodConfiguration()) {
// merge with attributes from prior methods
Map<String, Object> attributes = fromBefore.get();
attributes.putAll(PropertyManager.extractAttributes(testResult));
fromBefore.set(attributes);
} else if (method.isTestMethod()) {
fromMethod.set(PropertyManager.extractAttributes(testResult));
} else if (method.getTestMethod().isAfterMethodConfiguration()) {
// nothing to do here
}
}
示例6: beforeInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
if (method.getTestMethod().isBeforeMethodConfiguration()) {
// nothing to do here
} else if (method.isTestMethod()) {
PropertyManager.injectAttributes(fromBefore.get(), testResult);
fromBefore.remove();
} else if (method.getTestMethod().isAfterMethodConfiguration()) {
PropertyManager.injectAttributes(fromMethod.get(), testResult);
fromMethod.remove();
}
if (testResult.getInstance() instanceof IInvokedMethodListenerEx) {
((IInvokedMethodListenerEx) testResult.getInstance()).beforeInvocation(method, testResult);
}
}
示例7: beforeInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
Object testInstance = method.getTestMethod().getInstance();
if (runningTests.containsValue(testInstance)) {
return;
}
long currentThreadId = Thread.currentThread().getId();
if (isNewTestInProgress(testInstance)) {
preDestroy(runningTests.remove(currentThreadId));
}
String testName = testInstance.getClass().getName();
try {
LOG.info("Dependencies injection in {}", testName);
injectDependencies(testResult.getTestContext(), testInstance);
} catch (Exception e) {
String errorMessage = "Failed to inject fields in " + testName;
LOG.error(errorMessage, e);
throw new TestException(errorMessage, e);
} finally {
runningTests.put(currentThreadId, testInstance);
}
}
示例8: beforeInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
try {
SkipIf skip =
method.getTestMethod()
.getConstructorOrMethod()
.getMethod().getAnnotation(SkipIf.class);
if (skip != null) {
String info = skip.platform();
if (AppiumDriverManager.getDriver().getPlatformName().contains(info)) {
System.out.println("skipping childTest");
throw new SkipException("Skipped because property was set to :::" + info);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: afterInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
if (method.getTestMethod().isBeforeClassConfiguration()
| method.getTestMethod().isBeforeGroupsConfiguration()
| method.getTestMethod().isBeforeMethodConfiguration()
| method.getTestMethod().isBeforeSuiteConfiguration()
| method.getTestMethod().isBeforeTestConfiguration()) {
afterSetup(method, testResult);
} else if (method.getTestMethod().isAfterClassConfiguration()
| method.getTestMethod().isAfterGroupsConfiguration()
| method.getTestMethod().isAfterMethodConfiguration()
| method.getTestMethod().isAfterSuiteConfiguration()
| method.getTestMethod().isAfterTestConfiguration()) {
afterTeardown(method, testResult);
}
}
示例10: beforeInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
if (method.getTestMethod().isBeforeClassConfiguration()
| method.getTestMethod().isBeforeGroupsConfiguration()
| method.getTestMethod().isBeforeMethodConfiguration()
| method.getTestMethod().isBeforeSuiteConfiguration()
| method.getTestMethod().isBeforeTestConfiguration()) {
beforeSetup(method, testResult);
} else if (method.getTestMethod().isAfterClassConfiguration()
| method.getTestMethod().isAfterGroupsConfiguration()
| method.getTestMethod().isAfterMethodConfiguration()
| method.getTestMethod().isAfterSuiteConfiguration()
| method.getTestMethod().isAfterTestConfiguration()) {
beforeTeardown(method, testResult);
}
}
示例11: afterInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
/**
* After invocation.
*
* @param method
* the method
* @param result
* the result
* @see org.testng.IInvokedMethodListener#afterInvocation(org.testng.IInvokedMethod,
* org.testng.ITestResult)
*/
@Override
public final void afterInvocation(final IInvokedMethod method,
final ITestResult result) {
if (method.isTestMethod()) {
if (result.getStatus() == ITestResult.SKIP) {
endTestReporting("skipped");
} else if (result.getStatus() == ITestResult.FAILURE) {
endTestReporting("failed");
} else if (result.getStatus() == ITestResult.SUCCESS) {
endTestReporting("passed");
}
}
}
示例12: afterInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context)
{
if ( method.isTestMethod() )
{
RetryContext retryContext = (RetryContext)context.getAttribute(ATTRIBUTE_NAME);
if ( retryContext == null )
{
log.error("No retryContext!");
}
else
{
if ( testResult.isSuccess() || (testResult.getStatus() == ITestResult.FAILURE) )
{
retryContext.isRetrying.set(false);
if ( retryContext.runVersion.incrementAndGet() > 1 )
{
context.setAttribute(ATTRIBUTE_NAME, null);
}
}
}
}
}
示例13: beforeInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void beforeInvocation(IInvokedMethod m, ITestResult res) {
if (m.isTestMethod()) {
File videoFile = new File(
res.getTestContext().getOutputDirectory(),
m.getTestMethod().getMethodName() + ".flv");
screencaster = new VideoCreator(videoFile);
videoThread = new Thread(new Runnable() {
@Override
public void run() {
screencaster.createVideoFromScreens();
}
});
videoThread.start();
}
}
示例14: afterInvocation
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public void afterInvocation(IInvokedMethod m, ITestResult res) {
if (m.isTestMethod() && screencaster != null) {
try {
Thread.sleep(2000);
screencaster.setPleaseStop(true);
while (! screencaster.isStoppedCreation()) {
Thread.sleep(500);
}
videoThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
screencaster = null;
videoThread = null;
}
}
示例15: apply
import org.testng.IInvokedMethod; //導入依賴的package包/類
@Override
public boolean apply(IInvokedMethod method) {
if (!method.isTestMethod()) {
return false;
}
Test testAnnotation = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class);
if (null == testAnnotation) {
return false;
}
if (testAnnotation.expectedExceptions().length == 0) {
return false;
}
return Arrays.asList(testAnnotation.expectedExceptions()).contains(SoftAssertException.class);
}