當前位置: 首頁>>代碼示例>>Java>>正文


Java Reporter.getCurrentTestResult方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Nordstrom,項目名稱:Selenium-Foundation,代碼行數:13,代碼來源:TestNgBase.java

示例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);
    }
}
 
開發者ID:Nordstrom,項目名稱:Selenium-Foundation,代碼行數:15,代碼來源:TestNgBase.java

示例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();
    }
}
 
開發者ID:Nordstrom,項目名稱:Selenium-Foundation,代碼行數:10,代碼來源:TestNgBase.java

示例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);
        }
    }
}
 
開發者ID:Nordstrom,項目名稱:Selenium-Foundation,代碼行數:11,代碼來源:TestNgBase.java

示例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");
}
 
開發者ID:Nordstrom,項目名稱:Selenium-Foundation,代碼行數:17,代碼來源:TestNgBase.java

示例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");
    
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:15,代碼來源:PropertyManagerTest.java

示例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]");
    }
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:10,代碼來源:SkipFromBefore.java

示例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);
    }
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:8,代碼來源:SkipFromBefore.java

示例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);
    }
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:9,代碼來源:HappyPathClass.java

示例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());
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:10,代碼來源:ListenerChainTestCases.java

示例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");
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:8,代碼來源:ArtifactCollectorTestCases.java

示例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");
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:8,代碼來源:ArtifactCollectorTestCases.java

示例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");
    
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:14,代碼來源:PropertyManagerTest.java

示例14: testMethod

import org.testng.Reporter; //導入方法依賴的package包/類
@Test
public void testMethod() {
    methodResult = Reporter.getCurrentTestResult();
    fromMethod = (String) methodResult.getAttribute(ATTRIBUTE);
    assertTrue(true);
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:7,代碼來源:SkipFromBefore.java

示例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]");
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:7,代碼來源:SkipFromMethod.java


注:本文中的org.testng.Reporter.getCurrentTestResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。