本文整理匯總了Java中org.testng.ITestResult.isSuccess方法的典型用法代碼示例。如果您正苦於以下問題:Java ITestResult.isSuccess方法的具體用法?Java ITestResult.isSuccess怎麽用?Java ITestResult.isSuccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.testng.ITestResult
的用法示例。
在下文中一共展示了ITestResult.isSuccess方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: afterInvocation
import org.testng.ITestResult; //導入方法依賴的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);
}
}
}
示例2: afterInvocation
import org.testng.ITestResult; //導入方法依賴的package包/類
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
if (method.isTestMethod() && !testResult.isSuccess()) {
attachScreenshot();
}
}
示例3: retryMethod
import org.testng.ITestResult; //導入方法依賴的package包/類
@Override
public boolean retryMethod(ITestResult result) {
boolean willRetry = !result.isSuccess();
if (willRetry) {
result.setAttribute("retry", true);
}
return willRetry;
}
示例4: retry
import org.testng.ITestResult; //導入方法依賴的package包/類
/**
* If a testcase is failed and if baseUrl is not pingable, retry the test case.
*/
@Override
public boolean retry(ITestResult testResult)
{
LOG.info("@EnvAwareRetryAnalyzer retry");
String maxRetryStr = (String) testResult.getTestContext().getAttribute("maxRetryCount");
if (null != maxRetryStr)
{
try
{
maxRetryCount = Integer.valueOf(maxRetryStr);
} catch (NumberFormatException e)
{
e.printStackTrace();
maxRetryCount = 3;
}
} else
{
maxRetryCount = 3;
}
if (!testResult.isSuccess() && (retryCount++ < maxRetryCount))
{
String message = testResult.getThrowable().getMessage().toLowerCase();
if (message.contains("time-out"))
{
LOG.info("Retrying for time out... ");
return true;
}
}
return false;
}
示例5: afterMethod
import org.testng.ITestResult; //導入方法依賴的package包/類
@AfterMethod
public void afterMethod(ITestResult result) {
System.out.println("BaseCase: afterMethod");
String testClassName = String.format("%s.%s", result.getMethod()
.getRealClass().getName().toString(), result.getMethod().getMethodName());
System.out.println("---->"+testClassName);
if (!result.isSuccess()) {
Log.fail(result.getThrowable());
}
Log.info("==============����ִ�����==============");
if(Log.isPass()){
TestReport.successCount ++;
}else{
if(LogConfig.retryTimes > 0){
try {
Class<?> c = Class.forName(result.getMethod().getRealClass().getName());
Method m = c.getMethod(result.getMethod().getMethodName());
while(retryCounter < LogConfig.retryTimes){
Log.flush();
Log.info("<<<<<<<<<<<<<<<<<< ��ʼ����ִ��\""+ result.getMethod().getMethodName() +"\"���� >>>>>>>>>>>>>>>>>>");
m.invoke(c.newInstance(), (Object[])null);
Log.info("<<<<<<<<<<<<<<<<<< ����ִ��\""+ result.getMethod().getMethodName() +"\"������� >>>>>>>>>>>>>>>>>>");
retryCounter ++;
}
} catch (Exception e) {
e.printStackTrace();
}
if(retryCounter >= LogConfig.retryTimes) {
retryCounter = 0;//��ʼ��
TestReport.failureCount ++;
}
}else{
TestReport.failureCount ++;
}
}
Log.commit();
}
示例6: retry
import org.testng.ITestResult; //導入方法依賴的package包/類
@Override
public synchronized boolean retry(ITestResult result) {
//Failed and parameters has not retry.
if (!result.isSuccess() && !hasRetried(result.getParameters())) {
log.info("Retry method [" + result.getMethod().getMethodName() + "] with parameters:"
+ Arrays.toString(result.getParameters()));
result.setStatus(ITestResult.SKIP);
paramsHasRetried.add(result.getParameters());
return true;
}
return false;
}
示例7: retry
import org.testng.ITestResult; //導入方法依賴的package包/類
@Override
public synchronized boolean retry(ITestResult result) {
//Failed and parameters has not retry.
if (!result.isSuccess() && getRetriedCount(result) < retryCount) {
log.info("Retry method [" + result.getMethod().getMethodName() + "] with parameters:"
+ Arrays.toString(result.getParameters()));
result.setStatus(ITestResult.SKIP);
increaseRetryCount(result);
return true;
}
return false;
}
示例8: afterInvocation
import org.testng.ITestResult; //導入方法依賴的package包/類
@Override
public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) {
if (method.isTestMethod()) {
addByteAttachmentAsync("Test log", "text/plain", "afterInvocationContent"::getBytes);
if (!testResult.isSuccess()) {
addStreamAttachmentAsync("Failure screenshot", "image/png", () ->
getSystemResourceAsStream("attachments/screenshot.png"));
}
}
}
示例9: after
import org.testng.ITestResult; //導入方法依賴的package包/類
@AfterMethod
public void after(ITestResult result) {
if (!result.isSuccess()) {
List<Object> list = new ArrayList<>();
Collections.addAll(list, result.getParameters());
list.add(context.toString());
result.setParameters(list.toArray(new Object[list.size()]));
}
}
示例10: copyErrors
import org.testng.ITestResult; //導入方法依賴的package包/類
@AfterMethod
public void copyErrors(ITestResult result) {
if (!result.isSuccess()) {
suiteErrors.addAll(diags.errorKeys());
List<Object> list = new ArrayList<>();
Collections.addAll(list, result.getParameters());
list.add("Test case: " + getTestCaseDescription());
for (Pair<String, Template> e : sourceFiles)
list.add("Source file " + e.fst + ": " + e.snd);
if (diags.errorsFound())
list.add("Compile diagnostics: " + diags.toString());
result.setParameters(list.toArray(new Object[list.size()]));
}
}