本文整理汇总了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()]));
}
}