本文整理匯總了Java中org.testng.ITestContext.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java ITestContext.getName方法的具體用法?Java ITestContext.getName怎麽用?Java ITestContext.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.testng.ITestContext
的用法示例。
在下文中一共展示了ITestContext.getName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateMethodSummaryReport
import org.testng.ITestContext; //導入方法依賴的package包/類
/**
* Creates a table showing the highlights of each test method with links to the method details
*/
protected void generateMethodSummaryReport(List<ISuite> suites)
{
m_methodIndex = 0;
m_out.println("<a id=\"summary\"></a>");
startResultSummaryTable("passed");
for (ISuite suite : suites)
{
if (suites.size() > 1)
{
titleRow(suite.getName(), 4);
}
Map<String, ISuiteResult> r = suite.getResults();
for (ISuiteResult r2 : r.values())
{
ITestContext testContext = r2.getTestContext();
String testName = testContext.getName();
resultSummary(testContext.getFailedConfigurations(), testName, "failed", " (configuration methods)");
resultSummary(testContext.getFailedTests(), testName, "failed", "");
resultSummary(testContext.getSkippedConfigurations(), testName, "skipped", " (configuration methods)");
resultSummary(testContext.getSkippedTests(), testName, "skipped", "");
resultSummary(testContext.getPassedTests(), testName, "passed", "");
}
}
m_out.println("</table>");
}
示例2: onTestFailure
import org.testng.ITestContext; //導入方法依賴的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);
}
}
示例3: onTestSuccess
import org.testng.ITestContext; //導入方法依賴的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);
}
}
示例4: generateMethodSummaryReport
import org.testng.ITestContext; //導入方法依賴的package包/類
/**
* Creates a table showing the highlights of each test method with links to
* the method details
*/
protected void generateMethodSummaryReport(List<ISuite> suites) {
startResultSummaryTable("methodOverview");
int testIndex = 1;
for (ISuite suite : suites) {
if (suites.size() > 1) {
titleRow(suite.getName(), 5);
}
Map<String, ISuiteResult> r = suite.getResults();
for (ISuiteResult r2 : r.values()) {
ITestContext testContext = r2.getTestContext();
String testName = testContext.getName();
m_testIndex = testIndex;
// resultSummary(suite, testContext.getSkippedConfigurations(),
// testName, "skipped",
// " (configuration methods)");
resultSummary(suite, testContext.getSkippedTests(), testName, "skipped", "");
// resultSummary(suite, testContext.getFailedConfigurations(),
// testName, "failed",
// " (configuration methods)");
resultSummary(suite, testContext.getFailedTests(), testName, "failed", "");
resultSummary(suite, testContext.getPassedTests(), testName, "passed", "");
testIndex++;
}
}
m_out.println("</table>");
}