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


Java ITestResult.getParameters方法代碼示例

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


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

示例1: getTestInputArguments

import org.testng.ITestResult; //導入方法依賴的package包/類
private String getTestInputArguments( ITestResult result ) {

        StringBuilder inputArguments = new StringBuilder();

        Object[] inputArgs = result.getParameters();
        inputArguments.append("( ");
        if (inputArgs != null && inputArgs.length > 0) {
            for (Object inputArg : inputArgs) {
                if (inputArg == null) {
                    inputArguments.append("null");
                } else {
                    inputArguments.append(inputArg.toString());
                }
                inputArguments.append(", ");
            }
            inputArguments.delete(inputArguments.length() - 2, inputArguments.length() - 1); //removing the last comma
        }
        inputArguments.append(")");

        return inputArguments.toString();
    }
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:22,代碼來源:AtsTestngTestListener.java

示例2: onTestFailure

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * This method is useful to print the output console log in case of test failed.
 * We are assuming that we put in the context an attribute whose name is the complete test case ID (example: TEST_SUITE.001) and whose value is
 * 'PASSED' or 'SKIPPED' or 'FAILED'.
 * @param tr test case result - testNG handling
 */
@Override
public void onTestFailure(ITestResult tr) {
    if (tr.getParameters().length > 0) {
        Map<String, String> paramMap = (HashMap<String, String>) tr.getParameters()[0];
        ITestContext testContext = tr.getTestContext();
        //testCaseCompleteID - Example: TEST_SUITE.001
        String testCaseCompleteID = testContext.getName() + TestBaseRunner.TESTCASE_ID_SEPARATOR + testContext.getAttribute(TestBaseRunner.ATTR_TESTCASE_ID);
        logger.error("[{}][{}][{}] -- FAILED", testCaseCompleteID,
                    testContext.getAttribute(TestBaseRunner.SUITE_DESCRIPTION_CTX_ATTR).toString(),
                    testContext.getAttribute(TestBaseRunner.TC_DESCRIPTION_CTX_ATTR).toString());

        if (testContext.getAttribute("failedTestCases") == null) {
            failedTc = new ArrayList<>();
        } else {
            failedTc = (List<ITestResult>) testContext.getAttribute("failedTestCases");
        }
        failedTc.add(tr);
        testContext.setAttribute("failedTestCases", failedTc);

    } else {
        super.onTestFailure(tr);
    }
}
 
開發者ID:HotelsDotCom,項目名稱:heat,代碼行數:30,代碼來源:CustomTestNgListener.java

示例3: onTestSuccess

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * This method is useful to print the output console log in case of test success or test skipped.
 * We are assuming that we put in the context an attribute whose name is the complete test case ID (example: TEST_SUITE.001) and whose value is
 * 'PASSED' or 'SKIPPED' or 'FAILED'.
 * @param tr test case result - testNG handling
 */
@Override
public void onTestSuccess(ITestResult tr) {
    if (tr.getParameters().length > 0) {
        Map<String, String> paramMap = (HashMap<String, String>) tr.getParameters()[0];
        ITestContext testContext = tr.getTestContext();
        //testCaseCompleteID - Example: TEST_SUITE.001
        String testCaseCompleteID = testContext.getName() + TestBaseRunner.TESTCASE_ID_SEPARATOR + testContext.getAttribute(TestBaseRunner.ATTR_TESTCASE_ID);
        if (testContext.getAttributeNames().contains(testCaseCompleteID)
                && TestBaseRunner.STATUS_SKIPPED.equals(testContext.getAttribute(testCaseCompleteID))) {
            logger.trace("[{}][{}][{}] -- SKIPPED", testCaseCompleteID,
                    testContext.getAttribute(TestBaseRunner.SUITE_DESCRIPTION_CTX_ATTR).toString(),
                    testContext.getAttribute(TestBaseRunner.TC_DESCRIPTION_CTX_ATTR).toString());

            if (testContext.getAttribute("skippedTestCases") == null) {
                skippedTc = new ArrayList<>();
            } else {
                skippedTc = (List<ITestResult>) testContext.getAttribute("skippedTestCases");
            }
            skippedTc.add(tr);
            testContext.setAttribute("skippedTestCases", skippedTc);

        } else {
            logger.info("[{}][{}][{}] -- PASSED", testCaseCompleteID,
                    testContext.getAttribute(TestBaseRunner.SUITE_DESCRIPTION_CTX_ATTR).toString(),
                    testContext.getAttribute(TestBaseRunner.TC_DESCRIPTION_CTX_ATTR).toString());

            if (testContext.getAttribute("passedTestCases") == null) {
                passedTc = new ArrayList<>();
            } else {
                passedTc = (List<ITestResult>) testContext.getAttribute("passedTestCases");
            }
            passedTc.add(tr);
            testContext.setAttribute("passedTestCases", passedTc);

        }
    } else {
        super.onTestSuccess(tr);
    }
}
 
開發者ID:HotelsDotCom,項目名稱:heat,代碼行數:46,代碼來源:CustomTestNgListener.java

示例4: getParameters

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * 從測試結果上下文中獲取入參
 * @param testResult TestNG測試結果上下文
 * @return           入參
 */
@SuppressWarnings("unchecked")
public static Map<String, Object> getParameters(ITestResult testResult) {
    Object[] params = testResult.getParameters();
    Map<String,Object> param = null;
    if (params.length > 0) {
        param = (Map<String, Object>) params[0];
    }
    return param;
}
 
開發者ID:DreamYa0,項目名稱:zeratul,代碼行數:15,代碼來源:TestNGUtils.java

示例5: getArtifactBaseName

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * Get base name for artifact files for the specified test result.
 * <br><br>
 * <b>NOTE</b>: The base name is derived from the name of the current test.
 * If the method is parameterized, a hash code is computed from the parameter
 * values and appended to the base name as an 8-digit hexadecimal integer.
 * 
 * @param result TestNG test result object
 * @return artifact file base name
 */
private static String getArtifactBaseName(ITestResult result) {
    Object[] parameters = result.getParameters();
    if (parameters.length == 0) {
        return result.getName();
    } else {
        int hashcode = Arrays.deepHashCode(parameters);
        String hashStr = String.format("%08X", hashcode);
        return result.getName() + "-" + hashStr;
    }
}
 
開發者ID:Nordstrom,項目名稱:TestNG-Foundation,代碼行數:21,代碼來源:ArtifactCollector.java

示例6: getKey

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * Return a unique number based on the test method parameters.
 */
private int getKey(ITestResult result) {
	Object[] params = result.getParameters();
	if (params == null || params.length == 0) {
		return 0;
	} else {
		int key = result.getMethod().hashCode();
		for (Object param : params) {
			key += FileUtils.toJson(param).hashCode();
		}
		return key;
	}
}
 
開發者ID:21ca,項目名稱:selenium-testng-template,代碼行數:16,代碼來源:TestngRetry.java

示例7: printCaseError

import org.testng.ITestResult; //導入方法依賴的package包/類
@AfterMethod
public void printCaseError(ITestResult result) {
    if (result.getStatus() == ITestResult.FAILURE) {
        Hierarchy hs = (Hierarchy)result.getParameters()[0];
        System.out.println("Separate compilation case " + hs);
        printCaseDetails(hs);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:FDSeparateCompilationTest.java

示例8: generateForResult

import org.testng.ITestResult; //導入方法依賴的package包/類
private void generateForResult(ITestResult ans, ITestNGMethod method, int resultSetSize) {
	Object[] parameters = ans.getParameters();
	boolean hasParameters = parameters != null && parameters.length > 0;
	if (hasParameters) {
		tableStart("result", null);
		m_out.print("<tr class=\"param\">");
		for (int x = 1; x <= parameters.length; x++) {
			m_out.print("<th>Parameter #" + x + "</th>");
		}
		m_out.println("</tr>");
		m_out.print("<tr class=\"param stripe\">");
		for (Object p : parameters) {
			m_out.println("<td>" + Utils.escapeHtml(p.toString()) + "</td>");
		}
		m_out.println("</tr>");
	}
	List<String> msgs = Reporter.getOutput(ans);
	boolean hasReporterOutput = msgs.size() > 0;
	Throwable exception = ans.getThrowable();
	boolean hasThrowable = exception != null;
	if (hasReporterOutput || hasThrowable) {
		if (hasParameters) {
			m_out.print("<tr><td");
			if (parameters.length > 1) {
				m_out.print(" colspan=\"" + parameters.length + "\"");
			}
			m_out.println(">");
		} else {
			m_out.println("<div>");
		}
		if (hasReporterOutput) {
			if (hasThrowable) {
				m_out.println("<h3>Test Messages</h3>");
			}
			for (String line : msgs) {
				m_out.println(line + "<br/>");
			}
		}
		if (hasThrowable) {
			boolean wantsMinimalOutput = ans.getStatus() == ITestResult.SUCCESS;
			if (hasReporterOutput) {
				m_out.println("<h3>" + (wantsMinimalOutput ? "Expected Exception" : "Failure") + "</h3>");
			}
			generateExceptionReport(exception, method);
		}
		if (hasParameters) {
			m_out.println("</td></tr>");
		} else {
			m_out.println("</div>");
		}
	}
	if (hasParameters) {
		m_out.println("</table>");
	}
}
 
開發者ID:quanqinle,項目名稱:WebAndAppUITesting,代碼行數:56,代碼來源:PowerEmailableReporter.java

示例9: getId

import org.testng.ITestResult; //導入方法依賴的package包/類
private int getId(ITestResult result) {
	int id = result.getTestClass().getName().hashCode();
	id = id + result.getMethod().getMethodName().hashCode();
	id = id + (result.getParameters() != null ? Arrays.hashCode(result.getParameters()) : 0);
	return id;
}
 
開發者ID:quanqinle,項目名稱:WebAndAppUITesting,代碼行數:7,代碼來源:TestResultListener.java

示例10: getId

import org.testng.ITestResult; //導入方法依賴的package包/類
/**
 * Get ITestResult id by class + method + parameters hash code.
 * 
 * @param result
 * @return
 * @author kevinkong
 */
private int getId(ITestResult result) {
	int id = result.getTestClass().getName().hashCode();
	id = id + result.getMethod().getMethodName().hashCode();
	id = id + (result.getParameters() != null ? Arrays.hashCode(result.getParameters()) : 0);
	return id;
}
 
開發者ID:quanqinle,項目名稱:WebAndAppUITesting,代碼行數:14,代碼來源:PowerEmailableReporter.java


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