本文整理匯總了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]");
}