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


Java ITestResult.setAttribute方法代碼示例

本文整理匯總了Java中org.testng.ITestResult.setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java ITestResult.setAttribute方法的具體用法?Java ITestResult.setAttribute怎麽用?Java ITestResult.setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.testng.ITestResult的用法示例。


在下文中一共展示了ITestResult.setAttribute方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: set

import org.testng.ITestResult; //導入方法依賴的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: testAttributeExtraction

import org.testng.ITestResult; //導入方法依賴的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

示例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;
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:9,代碼來源:RetryTest.java

示例4: recordArtifactPath

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * Record the path at which the specified artifact was store in the indicated test result.
 * @param artifactPath path at which the captured artifact was stored 
 * @param result TestNG test result object
 */
private static void recordArtifactPath(Path artifactPath, ITestResult result) {
    @SuppressWarnings("unchecked")
    List<Path> artifactPaths = (List<Path>) result.getAttribute(ARTIFACT_PATHS);
    if (artifactPaths == null) {
        artifactPaths = new ArrayList<>();
        result.setAttribute(ARTIFACT_PATHS, artifactPaths);
    }
    artifactPaths.add(artifactPath);
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:15,代碼來源:ArtifactCollector.java

示例5: getConfig

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * Get the TestNG configuration object for the specified context.
 * 
 * @param testResult configuration context (TestNG test result object)
 * @return TestNG configuration object
 */
public static TestNGConfig getConfig(ITestResult testResult) {
    if (testResult == null) {
        return testNGConfig.get();
    }
    
    TestNGConfig config = (TestNGConfig) testResult.getAttribute(TESTNG_CONFIG);
    
    if (config == null) {
        config = testNGConfig.get();
        testResult.setAttribute(TESTNG_CONFIG, config);
    }
    
    return config;
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:21,代碼來源:TestNGConfig.java

示例6: injectAttributes

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * Inject the entries of the specified {@link Map} into the attribute collection of the specified test result.
 * 
 * @param attributes map of test result attributes
 * @param testResult test result object
 */
public static void injectAttributes(Map<String, Object> attributes, ITestResult testResult) {
    if (attributes != null) {
        for (Entry<String, Object> thisEntry : attributes.entrySet()) {
            testResult.setAttribute(thisEntry.getKey(), thisEntry.getValue());
        }
    }
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:14,代碼來源:PropertyManager.java

示例7: setLog

import org.testng.ITestResult; //導入方法依賴的package包/類
private void setLog(ITestResult tr) {
	StringWriter exception = new StringWriter();
	if (tr.getThrowable() != null) {
		tr.getThrowable().printStackTrace(new PrintWriter(exception));
	}
	tr.setAttribute("log", MTLogBuffer.getStringLog() + exception);
}
 
開發者ID:21ca,項目名稱:selenium-testng-template,代碼行數:8,代碼來源:HtmlReporter.java

示例8: takeScreenshot

import org.testng.ITestResult; //導入方法依賴的package包/類
private void takeScreenshot(ITestResult tr) {
	if (Config.driver() != null) {
		String file = SeleniumUtils.takeScreenShot();
		String imageFile = SeleniumUtils.SCREENSHOT_PATH + file;
		String thumbFile = SeleniumUtils.SCREENSHOT_PATH + "thumb_" + file;
		buildThumbImage(imageFile, thumbFile);
		tr.setAttribute("screenshot", imageFile);
		tr.setAttribute("thumbScreenshot", thumbFile);
	}
}
 
開發者ID:21ca,項目名稱:selenium-testng-template,代碼行數:11,代碼來源:HtmlReporter.java

示例9: baseCleanup

import org.testng.ITestResult; //導入方法依賴的package包/類
@AfterMethod(alwaysRun = true)
public void baseCleanup(ITestContext context, ITestResult result, Object[] params) throws IOException {
	if (params.length > 0 && params[0] instanceof WebDriverInstance){
		WebDriverInstance webDriverInstance = (WebDriverInstance)params[0];
		webDriverInstance.cleanup();
	}
	logTestResult(result);
	String tag = ThreadContext.get(THREAD_TAG);
	logger.info("Test is finished, removing the tag [{}]...", tag);
	ThreadContext.remove(THREAD_TAG);
	result.setAttribute(THREAD_TAG, tag);
}
 
開發者ID:3pillarlabs,項目名稱:AutomationFrameworkTPG,代碼行數:13,代碼來源:TestBase.java

示例10: disableCapture

import org.testng.ITestResult; //導入方法依賴的package包/類
static void disableCapture(ITestResult result) {
    result.setAttribute(CAPTURE_DISABLED, Boolean.TRUE);
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:4,代碼來源:UnitTestArtifact.java

示例11: crippleCapture

import org.testng.ITestResult; //導入方法依賴的package包/類
static void crippleCapture(ITestResult result) {
    result.setAttribute(CAPTURE_CRIPPLED, Boolean.TRUE);
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:4,代碼來源:UnitTestArtifact.java

示例12: setCaptureState

import org.testng.ITestResult; //導入方法依賴的package包/類
static void setCaptureState(ITestResult result, CaptureState state) {
    result.setAttribute(CAPTURE_STATE, state);
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:4,代碼來源:UnitTestArtifact.java

示例13: captureArtifact

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * Capture artifact from the current test result context.
 * <br><br>
 * <b>NOTE</b>: This override is here solely to record the artifact path for the benefit of the unit tests,
 * as verification meta-data. It makes no contribution to the actual process of artifact capture
 * 
 * @param testResult TestNG test result object
 * @return path at which the captured artifact was stored
 */
@Override
public Optional<Path> captureArtifact(ITestResult testResult) {
    Optional<Path> artifactPath = super.captureArtifact(testResult);
    testResult.setAttribute(ARTIFACT_PATH, artifactPath);
    return artifactPath;
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:16,代碼來源:UnitTestCapture.java


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