本文整理匯總了Java中org.testng.xml.XmlSuite類的典型用法代碼示例。如果您正苦於以下問題:Java XmlSuite類的具體用法?Java XmlSuite怎麽用?Java XmlSuite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
XmlSuite類屬於org.testng.xml包,在下文中一共展示了XmlSuite類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tests
import org.testng.xml.XmlSuite; //導入依賴的package包/類
@Override
public File tests() throws SuiteException {
XmlSuite xmlSuite = new XmlSuite();
xmlSuite.setName(SUITE_NAME);
try {
for (SunshineTest sunshineTest : this.artifacts.tests()) {
XmlTest test = new TestNGTest(sunshineTest).object();
test.setSuite(xmlSuite);
xmlSuite.addTest(test);
}
this.suiteXml.write(xmlSuite.toXml());
return this.suiteXml;
} catch (TestException | IOException e) {
throw new SuiteException(e);
}
}
示例2: generateReport
import org.testng.xml.XmlSuite; //導入依賴的package包/類
/**
* Creates summary of the run
*/
public void generateReport(List<XmlSuite> xml, List<ISuite> suites, String outdir)
{
try
{
m_out = createWriter(outdir);
} catch (IOException e)
{
L.error("output file", e);
return;
}
startHtml(m_out);
generateSuiteSummaryReport(suites);
generateMethodSummaryReport(suites);
generateMethodDetailReport(suites);
endHtml(m_out);
m_out.flush();
m_out.close();
}
示例3: generateReport
import org.testng.xml.XmlSuite; //導入依賴的package包/類
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
StringBuilder sb = new StringBuilder();
for (ISuite suite : suites) {
Map<String, ISuiteResult> results = suite.getResults();
for (Map.Entry<String, ISuiteResult> result : results.entrySet()) {
String report = buildReport(result.getValue().getTestContext());
sb.append(report);
}
}
try {
FileUtils.writeToFile(new File(FAILED_REPORT_FILE), sb.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
示例4: alter
import org.testng.xml.XmlSuite; //導入依賴的package包/類
@Override
public void alter(List<XmlSuite> suites) {
List<XmlSuite> cloned = new ArrayList<>(suites);
suites.clear();
for (XmlSuite suite : cloned) {
String logLevels = suite.getParameter(LOG_LEVELS_PARAM_NAME);
if (StringUtils.isNotEmpty(logLevels)) {
List<XmlSuite> newSuites = createSuites(logLevels, suite);
if (!newSuites.isEmpty()) {
suites.addAll(newSuites);
}
} else {
suites.add(suite);
}
}
}
示例5: generateReport
import org.testng.xml.XmlSuite; //導入依賴的package包/類
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
List<ITestResult> list = new ArrayList<ITestResult>();
for (ISuite suite : suites) {
Map<String, ISuiteResult> suiteResults = suite.getResults();
for (ISuiteResult suiteResult : suiteResults.values()) {
ITestContext testContext = suiteResult.getTestContext();
IResultMap passedTests = testContext.getPassedTests();
IResultMap failedTests = testContext.getFailedTests();
IResultMap skippedTests = testContext.getSkippedTests();
IResultMap failedConfig = testContext.getFailedConfigurations();
list.addAll(this.listTestResult(passedTests));
list.addAll(this.listTestResult(failedTests));
list.addAll(this.listTestResult(skippedTests));
list.addAll(this.listTestResult(failedConfig));
}
}
this.sort(list);
this.outputResult(list, outputDirectory+"/test.txt");
}
示例6: prepareMock
import org.testng.xml.XmlSuite; //導入依賴的package包/類
protected ITestResult prepareMock(Class<?> tClass, Method method) {
ITestResult result = mock(ITestResult.class);
IClass clazz = mock(IClass.class);
ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
ConstructorOrMethod cm = mock(ConstructorOrMethod.class);
String methodName = method.getName();
when(result.getTestClass()).thenReturn(clazz);
when(result.getTestClass().getRealClass()).thenReturn(tClass);
when(clazz.getName()).thenReturn(this.getClass().getName());
when(result.getMethod()).thenReturn(testNGMethod);
when(cm.getMethod()).thenReturn(method);
when(result.getMethod().getConstructorOrMethod()).thenReturn(cm);
when(testNGMethod.getMethodName()).thenReturn(methodName);
ITestContext context = mock(ITestContext.class);
when(result.getTestContext()).thenReturn(context);
XmlTest xmlTest = new XmlTest();
XmlSuite suite = new XmlSuite();
xmlTest.setXmlSuite(suite);
suite.setListeners(Arrays.asList(VideoListener.class.getName()));
when(context.getCurrentXmlTest()).thenReturn(xmlTest);
return result;
}
示例7: testOneTestMethod
import org.testng.xml.XmlSuite; //導入依賴的package包/類
@Test
public void testOneTestMethod() throws Exception {
final XmlSuite suite = new XmlSuite();
final XmlTest test = new XmlTest();
final XmlClass xmlClass = new XmlClass("a.ATest", false);
xmlClass.getIncludedMethods().add(new XmlInclude("test1"));
test.getClasses().add(xmlClass);
suite.getTests().add(test);
doTest(suite,"##teamcity[enteredTheMatrix]\n" +
"\n" +
"##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[0|]']\n");
}
示例8: testOneTestMethodWithMultipleInvocationCount
import org.testng.xml.XmlSuite; //導入依賴的package包/類
@Test
public void testOneTestMethodWithMultipleInvocationCount() throws Exception {
final XmlSuite suite = new XmlSuite();
final XmlTest test = new XmlTest();
final XmlClass xmlClass = new XmlClass("a.ATest", false);
xmlClass.getIncludedMethods().add(new XmlInclude("test1", Arrays.asList(0, 1, 2), 0));
test.getClasses().add(xmlClass);
suite.getTests().add(test);
doTest(suite, "##teamcity[enteredTheMatrix]\n" +
"\n" +
"##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[0|]']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[1|] (1)' locationHint='java:test://a.ATest.test1|[1|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[1|] (1)']\n" +
"\n" +
"##teamcity[testStarted name='ATest.test1|[2|] (2)' locationHint='java:test://a.ATest.test1|[2|]']\n" +
"\n" +
"##teamcity[testFinished name='ATest.test1|[2|] (2)']\n");
}
示例9: doTest
import org.testng.xml.XmlSuite; //導入依賴的package包/類
private static void doTest(XmlSuite suite, String expected) {
final StringBuffer buf = new StringBuffer();
final IDEATestNGRemoteListener listener = createListener(buf);
for (XmlTest test : suite.getTests()) {
for (XmlClass aClass : test.getClasses()) {
final String classFQName = aClass.getName();
for (XmlInclude include : aClass.getIncludedMethods()) {
final String methodName = include.getName();
List<Integer> numbers = include.getInvocationNumbers();
if (numbers.isEmpty()) {
numbers = Collections.singletonList(0);
}
for (Integer integer : numbers) {
final MockTestNGResult result = new MockTestNGResult(classFQName, methodName, null, new Object[] {integer});
listener.onTestStart(result);
listener.onTestFinished(result);
}
}
}
}
Assert.assertEquals("output: " + buf, expected, StringUtil.convertLineSeparators(buf.toString()));
}
示例10: initLogging
import org.testng.xml.XmlSuite; //導入依賴的package包/類
/**
* Initialize logging to trace REST request/response input/ouput for tests
* Call in @BeforeClass method for tests
* @param testContext of current test/suite
*/
public static void initLogging(ITestContext testContext) {
XmlSuite currentSuite = testContext.getCurrentXmlTest().getSuite();
String suiteName = currentSuite.getName();
String service = currentSuite.getParameter("service");
PrintStream defaultLogStream = null;
Path outDirPath;
try {
if(service != null)
outDirPath = Files.createDirectories(Paths.get(System.getProperty("java.io.tmpdir"), "test-output", service));
else
outDirPath = Files.createDirectories(Paths.get(System.getProperty("java.io.tmpdir"), "test-output"));
Path logFilePath = Files.createTempFile(outDirPath, suiteName, ".out");
defaultLogStream = new PrintStream(logFilePath.toFile());
}
catch(IOException e) {
e.printStackTrace();
}
LogConfig testLogConfig = new LogConfig(defaultLogStream, true);
RestAssured.config = RestAssuredConfig.config().logConfig(testLogConfig);
}
示例11: run
import org.testng.xml.XmlSuite; //導入依賴的package包/類
private void run()
{
LOG.debug("running tempto with options: {}", options);
if (options.isHelpRequested()) {
parser.printHelpMessage();
return;
}
XmlSuite testSuite = getXmlSuite();
testSuite.setThreadCount(options.getThreadCount());
setupTestsConfiguration();
System.setProperty(CONVENTION_TESTS_DIR_KEY, options.getConventionTestsDirectory());
TestNG testNG = new TestNG();
testNG.setXmlSuites(singletonList(testSuite));
testNG.setOutputDirectory(options.getReportDir());
setupTestsFiltering(testNG);
options.getConventionResultsDumpPath()
.ifPresent(path -> System.setProperty(CONVENTION_TESTS_RESULTS_DUMP_PATH_KEY, path));
testNG.run();
if (testNG.hasFailure()) {
System.exit(1);
}
}
示例12: getXmlSuite
import org.testng.xml.XmlSuite; //導入依賴的package包/類
private XmlSuite getXmlSuite()
{
// we cannot use singletonLists here as testNG later
// modifies lists stored in XmlSuite ... zonk
XmlSuite testSuite = new XmlSuite();
testSuite.setName("tempto-tests");
testSuite.setFileName("tempto-tests");
XmlTest test = new XmlTest(testSuite);
test.setName("all");
XmlPackage testPackage = new XmlPackage(options.getTestsPackage());
List<XmlPackage> testPackages = newArrayList(testPackage);
test.setPackages(testPackages);
XmlClass conventionBasedTestsClass = new XmlClass("io.prestodb.tempto.internal.convention.ConventionBasedTestFactory");
List<XmlClass> classes = newArrayList(conventionBasedTestsClass);
test.setClasses(classes);
test.setParallel(XmlSuite.ParallelMode.METHODS);
return testSuite;
}
示例13: run
import org.testng.xml.XmlSuite; //導入依賴的package包/類
@Override
public void run() {
try {
initializeSuitesAndJarFile();
List<XmlSuite> suites = new ArrayList<>();
flatSuites(m_suites, suites);
if (suites.isEmpty()) {
TestingMessageHelper.reporterAttached(System.out);
System.err.print("No test found to run.");
} else {
addCheListeners();
super.run();
System.exit(0);
}
} catch (Throwable throwable) {
throwable.printStackTrace(System.err);
}
}
示例14: generateConsolidatedReportByOwner
import org.testng.xml.XmlSuite; //導入依賴的package包/類
public void generateConsolidatedReportByOwner(java.util.List<XmlSuite> xmlSuites,
java.util.List<ISuite> suites, java.lang.String outputDirectory) {
Map<String, List<ITestResult>> ownersOfFailedTests = new HashMap<String, List<ITestResult>>();
Map<String, List<ITestResult>> ownersOfPassedTests = new HashMap<String, List<ITestResult>>();
for (ISuite suite : suites) {
for (ISuiteResult result : suite.getResults().values()) {
ownersOfPassedTests = getTestByOwnerSiteBrowser(result.getTestContext().getPassedTests().getAllResults());
ownersOfFailedTests = getTestByOwnerSiteBrowser(result.getTestContext().getFailedTests().getAllResults());
}
}
// Send consolidated failures to the Team group email id.
TestNGEmailSender.sendConsolidatedFailureEmail(ownersOfPassedTests, ownersOfFailedTests);
}
示例15: executeInCurrentLoader
import org.testng.xml.XmlSuite; //導入依賴的package包/類
private void executeInCurrentLoader(final ResultCollector rc) {
final TestNGAdapter listener = new TestNGAdapter(this.clazz,
this.getDescription(), rc);
final XmlSuite suite = createSuite();
TESTNG.setDefaultSuiteName(suite.getName());
TESTNG.setXmlSuites(Collections.singletonList(suite));
LISTENER.setChild(listener);
try {
TESTNG.run();
} finally {
// yes this is hideous
LISTENER.setChild(null);
}
}