当前位置: 首页>>代码示例>>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;未经允许,请勿转载。