本文整理汇总了Java中org.testng.Reporter.getCurrentTestResult方法的典型用法代码示例。如果您正苦于以下问题:Java Reporter.getCurrentTestResult方法的具体用法?Java Reporter.getCurrentTestResult怎么用?Java Reporter.getCurrentTestResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.testng.Reporter
的用法示例。
在下文中一共展示了Reporter.getCurrentTestResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: set
import org.testng.Reporter; //导入方法依赖的package包/类
/**
* Store the specified object in the attributes collection.
*
* @param obj object to be stored; 'null' to discard value
* @return (optional) specified object
*/
private <T> Optional<T> set(T obj) {
ITestResult result = Reporter.getCurrentTestResult();
Optional<T> val = TestBase.optionalOf(obj);
result.setAttribute(key, val);
return val;
}
示例2: nab
import org.testng.Reporter; //导入方法依赖的package包/类
/**
* If present, get the object from the attributes collection.
*
* @return (optional) stored object
*/
private Optional<?> nab() {
ITestResult result = Reporter.getCurrentTestResult();
Object val = result.getAttribute(key);
if (val != null) {
return (Optional<?>) val;
} else {
return set(null);
}
}
示例3: getOutputDirectory
import org.testng.Reporter; //导入方法依赖的package包/类
@Override
public String getOutputDirectory() {
ITestResult testResult = Reporter.getCurrentTestResult();
if (testResult != null) {
return testResult.getTestContext().getOutputDirectory();
} else {
return PathUtils.ReportsDirectory.ARTIFACT.getPath().toString();
}
}
示例4: adjustTimeout
import org.testng.Reporter; //导入方法依赖的package包/类
@Override
public void adjustTimeout(long adjust) {
ITestResult testResult = Reporter.getCurrentTestResult();
if (testResult != null) {
long timeout = testResult.getMethod().getTimeOut();
if (timeout > 0) {
testResult.getMethod().setTimeOut(timeout + adjust);
}
}
}
示例5: getLinkedListener
import org.testng.Reporter; //导入方法依赖的package包/类
/**
* Get the listener of the specified type that's attached to the listener chain.
*
* @param <T> listener type
* @param listenerType listener type
* @return listener of the specified type
*/
public static <T extends ITestNGListener> T getLinkedListener(Class<T> listenerType) {
ITestResult testResult = Reporter.getCurrentTestResult();
Optional<T> optListener =
ListenerChain.getAttachedListener(testResult, listenerType);
if (optListener.isPresent()) {
return optListener.get();
}
throw new IllegalStateException(listenerType.getSimpleName() + " listener wasn't found on the listener chain");
}
示例6: testAttributeInjection
import org.testng.Reporter; //导入方法依赖的package包/类
@Test
public void testAttributeInjection() {
ITestResult testResult = Reporter.getCurrentTestResult();
PropertyManager.injectAttributes(attributeMap, testResult);
Set<String> actualNames = testResult.getAttributeNames();
assertEquals(actualNames, expectNames, "Actual names differ from expected names");
assertEquals(testResult.getAttribute(BOOLEAN_KEY), BOOLEAN_VAL, "Boolean value is incorrect");
assertEquals(testResult.getAttribute(STRING_KEY), STRING_VAL, "String value is incorrect");
assertEquals(testResult.getAttribute(OBJECT_KEY), OBJECT_VAL, "Object value is incorrect");
}
示例7: beforeMethod
import org.testng.Reporter; //导入方法依赖的package包/类
@BeforeMethod
public void beforeMethod(Method method) {
if ("testMethod".equals(method.getName())) {
fromBefore = VALUE;
beforeResult = Reporter.getCurrentTestResult();
beforeResult.setAttribute(ATTRIBUTE, fromBefore);
throw new SkipException("Skip from [before]");
}
}
示例8: afterMethod
import org.testng.Reporter; //导入方法依赖的package包/类
@AfterMethod
public void afterMethod(Method method) {
if ("testMethod".equals(method.getName())) {
afterResult = Reporter.getCurrentTestResult();
fromAfter = (String) afterResult.getAttribute(ATTRIBUTE);
}
}
示例9: beforeMethod
import org.testng.Reporter; //导入方法依赖的package包/类
@BeforeMethod
public void beforeMethod(Method method) {
if ("testMethod".equals(method.getName())) {
fromBefore = VALUE;
beforeResult = Reporter.getCurrentTestResult();
beforeResult.setAttribute(ATTRIBUTE, fromBefore);
}
}
示例10: testAttachedListeners
import org.testng.Reporter; //导入方法依赖的package包/类
@Test(groups = {"happyPath"})
public void testAttachedListeners() {
System.out.println("testAttachedListeners");
ITestResult result = Reporter.getCurrentTestResult();
Optional<ChainedListener> optChained = ListenerChain.getAttachedListener(result, ChainedListener.class);
assertTrue(optChained.isPresent());
Optional<ServiceLoadedListener> optService = ListenerChain.getAttachedListener(result, ServiceLoadedListener.class);
assertTrue(optService.isPresent());
}
示例11: testCanNotCapture
import org.testng.Reporter; //导入方法依赖的package包/类
@Test(groups = {"canNotCapture"})
public void testCanNotCapture() {
System.out.println("canNotCapture");
ITestResult result = Reporter.getCurrentTestResult();
UnitTestArtifact.disableCapture(result);
fail("canNotCapture");
}
示例12: testWillNotCapture
import org.testng.Reporter; //导入方法依赖的package包/类
@Test(groups = {"willNotCapture"})
public void testWillNotCapture() {
System.out.println("willNotCapture");
ITestResult result = Reporter.getCurrentTestResult();
UnitTestArtifact.crippleCapture(result);
fail("willNotCapture");
}
示例13: testAttributeExtraction
import org.testng.Reporter; //导入方法依赖的package包/类
@Test
public void testAttributeExtraction() {
ITestResult testResult = Reporter.getCurrentTestResult();
testResult.setAttribute(BOOLEAN_KEY, BOOLEAN_VAL);
testResult.setAttribute(STRING_KEY, STRING_VAL);
testResult.setAttribute(OBJECT_KEY, OBJECT_VAL);
Map<String, Object> extractedMap = PropertyManager.extractAttributes(testResult);
assertEquals(extractedMap, attributeMap, "Extracted map differs from expected map");
}
示例14: testMethod
import org.testng.Reporter; //导入方法依赖的package包/类
@Test
public void testMethod() {
methodResult = Reporter.getCurrentTestResult();
fromMethod = (String) methodResult.getAttribute(ATTRIBUTE);
assertTrue(true);
}
示例15: testMethod
import org.testng.Reporter; //导入方法依赖的package包/类
@Test
public void testMethod() {
methodResult = Reporter.getCurrentTestResult();
fromMethod = (String) methodResult.getAttribute(ATTRIBUTE);
throw new SkipException("Skip from [method]");
}