当前位置: 首页>>代码示例>>Java>>正文


Java TestNG.setUseDefaultListeners方法代码示例

本文整理汇总了Java中org.testng.TestNG.setUseDefaultListeners方法的典型用法代码示例。如果您正苦于以下问题:Java TestNG.setUseDefaultListeners方法的具体用法?Java TestNG.setUseDefaultListeners怎么用?Java TestNG.setUseDefaultListeners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.testng.TestNG的用法示例。


在下文中一共展示了TestNG.setUseDefaultListeners方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.testng.TestNG; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
    resultsDir = folder.newFolder();
    AllureResultsUtils.setResultsDirectory(resultsDir);

    List<String> suites = new ArrayList<>();
    URL resource = getClass().getClassLoader().getResource("suite3.xml");
    assertNotNull("could not find suite3.xml", resource);

    //noinspection ConstantConditions
    suites.add(resource.getFile());

    TestNG testNG = new TestNG();
    testNG.setTestSuites(suites);
    testNG.setUseDefaultListeners(false);
    testNG.run();
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:18,代码来源:AllureTestListenerSuiteNameTest.java

示例2: runTests

import org.testng.TestNG; //导入方法依赖的package包/类
private void runTests() {
    TestNG testNg = new TestNG();
    testNg.setOutputDirectory(testReportDir.getAbsolutePath());
    testNg.setDefaultSuiteName(options.getDefaultSuiteName());
    testNg.setDefaultTestName(options.getDefaultTestName());
    testNg.setParallel(options.getParallel());
    testNg.setThreadCount(options.getThreadCount());
    invokeVerifiedMethod(testNg, "setConfigFailurePolicy", String.class, options.getConfigFailurePolicy(), TestNGOptions.DEFAULT_CONFIG_FAILURE_POLICY);
    invokeVerifiedMethod(testNg, "setPreserveOrder", boolean.class, options.getPreserveOrder(), false);
    invokeVerifiedMethod(testNg, "setGroupByInstances", boolean.class, options.getGroupByInstances(), false);
    testNg.setUseDefaultListeners(options.getUseDefaultListeners());
    testNg.setVerbose(0);
    testNg.setGroups(CollectionUtils.join(",", options.getIncludeGroups()));
    testNg.setExcludedGroups(CollectionUtils.join(",", options.getExcludeGroups()));

    //adding custom test listeners before Gradle's listeners.
    //this way, custom listeners are more powerful and, for example, they can change test status.
    for (String listenerClass : options.getListeners()) {
        try {
            testNg.addListener(applicationClassLoader.loadClass(listenerClass).newInstance());
        } catch (Throwable e) {
            throw new GradleException(String.format("Could not add a test listener with class '%s'.", listenerClass), e);
        }
    }

    if (!options.getIncludedTests().isEmpty()) {
        testNg.addListener(new SelectedTestsFilter(options.getIncludedTests()));
    }

    if (!suiteFiles.isEmpty()) {
        testNg.setTestSuites(GFileUtils.toPaths(suiteFiles));
    } else {
        testNg.setTestClasses(testClasses.toArray(new Class[0]));
    }
    testNg.addListener((Object) adaptListener(new TestNGTestResultProcessorAdapter(resultProcessor, idGenerator, timeProvider)));
    testNg.run();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:38,代码来源:TestNGTestClassProcessor.java

示例3: autoRunXml

import org.testng.TestNG; //导入方法依赖的package包/类
/**
 * This method runs the XML suite file dynamically
 **/

public static void autoRunXml() {
	List<String> files = new ArrayList<String>();
	if (Driver.getRunOn().equalsIgnoreCase("standalone")) {
		if (Driver.getType().equalsIgnoreCase("desktop")) {
			files.add("./src/test/resources/suites/desktop.xml");
		} else if (Driver.getType().equalsIgnoreCase("device")) {
			files.add("./src/test/resources/suites/device.xml");
		} else if (Driver.getType().equalsIgnoreCase("app")) {
			files.add("./src/test/resources/suites/app.xml");
		}
	} else if (Driver.getRunOn().equalsIgnoreCase("grid")) {
		if (Driver.getType().equalsIgnoreCase("desktop")) {
			files.add("./src/test/resources/suites/desktop-grid.xml");
		} else if (Driver.getType().equalsIgnoreCase("device")) {
			files.add("./src/test/resources/suites/device-grid.xml");
		} else if (Driver.getType().equalsIgnoreCase("app")) {
			files.add("./src/test/resources/suites/app.xml");
		}
	}
	TestNG tng = new TestNG();
	TestNG tng1 = new TestNG();
	tng.setOutputDirectory(ReportNGReport.makDir());
	tng1.setOutputDirectory(ExtentReport.makDir());
	tng.setUseDefaultListeners(false);
	tng.setTestSuites(files);
	tng.run();

}
 
开发者ID:AnujDasari,项目名称:Actitime-Framework,代码行数:33,代码来源:XMLUtilityManager.java

示例4: new_TestNG_with_failure_recorder_for

import org.testng.TestNG; //导入方法依赖的package包/类
private TestNG new_TestNG_with_failure_recorder_for(Class<?>... testNGClasses) {
    TestNG testNG = new TestNG();
    testNG.setVerbose(0);
    testNG.setUseDefaultListeners(false);
    testNG.addListener(failureRecorder);

    testNG.setTestClasses(testNGClasses);
    return testNG;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:TestNGShouldFailWhenMockitoListenerFailsTest.java

示例5: setUp

import org.testng.TestNG; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws IOException {
    resultsDir = Files.createTempDirectory(ALLURE_RESULTS);
    AllureResultsUtils.setResultsDirectory(resultsDir.toFile());

    List<XmlSuite> suites = new ArrayList<>();
    for (ConfigMethodType type : ConfigMethodType.values()) {
        suites.add(createSuite(type.getTitle()));
    }

    TestNG testNG = new TestNG();
    testNG.setXmlSuites(suites);
    testNG.setUseDefaultListeners(false);
    testNG.run();
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:16,代码来源:AllureTestListenerConfigMethodsTest.java

示例6: setUp

import org.testng.TestNG; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
    resultsDir = Files.createTempDirectory(ALLURE_RESULTS);
    AllureResultsUtils.setResultsDirectory(resultsDir.toFile());

    TestNG testNG = new TestNG();
    testNG.setDefaultSuiteName(DEFAULT_SUITE_NAME);
    testNG.setTestClasses(new Class[]{TestDataClass.class});
    testNG.setUseDefaultListeners(false);

    testNG.run();
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:13,代码来源:AllureTestListenerXmlValidationTest.java

示例7: setUp

import org.testng.TestNG; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
    resultsDir = Files.createTempDirectory(ALLURE_RESULTS);
    AllureResultsUtils.setResultsDirectory(resultsDir.toFile());
    List<String> suites = Lists.newArrayList();
    suites.add(getClass().getResource(SUITE1).getFile());
    suites.add(getClass().getResource(SUITE2).getFile());
    TestNG testNG = new TestNG();
    testNG.setTestSuites(suites);
    testNG.setSuiteThreadPoolSize(2);
    testNG.setUseDefaultListeners(false);
    testNG.run();
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:14,代码来源:AllureTestListenerMultipleSuitesTest.java

示例8: run

import org.testng.TestNG; //导入方法依赖的package包/类
@Override
public void run() throws Throwable {
  for (String className : testClassNames) {
    if (!shouldIncludeTest(className)) {
      continue;
    }

    final Class<?> testClass = Class.forName(className);

    List<TestResult> results;
    if (!mightBeATestClass(testClass)) {
      results = Collections.emptyList();
    } else {
      results = new ArrayList<>();
      TestNG testng = new TestNG();
      testng.setUseDefaultListeners(false);
      testng.setAnnotationTransformer(new FilteringAnnotationTransformer(results));
      testng.setTestClasses(new Class<?>[] {testClass});
      testng.addListener(new TestListener(results));
      // use default TestNG reporters ...
      testng.addListener(new SuiteHTMLReporter());
      testng.addListener((IReporter) new FailedReporter());
      testng.addListener(new XMLReporter());
      testng.addListener(new EmailableReporter());
      // ... except this replaces JUnitReportReporter ...
      testng.addListener(new JUnitReportReporterWithMethodParameters());
      // ... and we can't access TestNG verbosity, so we remove VerboseReporter
      testng.run();
    }

    writeResult(className, results);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:34,代码来源:TestNGRunner.java

示例9: execute

import org.testng.TestNG; //导入方法依赖的package包/类
/**
 * Executes a test suite using the supplied test run arguments. The test run
 * arguments are expected to be contained in an XML properties document
 * structured as shown in the following example.
 * 
 * <pre>
 * {@code
 * <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 * <properties version="1.0">
 *   <comment>Test run arguments</comment>
 *   <entry key="arg1">atom-feed.xml</entry>
 *   <entry key="arg2">L2</entry>
 * </properties>
 * }
 * </pre>
 * 
 * <p>
 * <strong>Note:</strong>The actual arguments (key-value pairs) are
 * suite-specific.
 * </p>
 * 
 * @param testRunArgs
 *            A DOM Document node that contains a set of XML properties.
 * @return A Source object that provides an XML representation of the test
 *         results.
 */
@Override
public Source execute(Document testRunArgs) {
    if (null == testRunArgs) {
        throw new IllegalArgumentException("No test run arguments were supplied.");
    }
    TestNG driver = new TestNG();
    setTestSuites(driver, this.testngConfig);
    driver.setVerbose(0);
    driver.setUseDefaultListeners(this.useDefaultListeners);
    UUID runId = UUID.randomUUID();
    File runDir = new File(this.outputDir, runId.toString());
    if (!runDir.mkdir()) {
        runDir = this.outputDir;
        LOGR.config("Created test run directory at " + runDir.getAbsolutePath());
    }
    driver.setOutputDirectory(runDir.getAbsolutePath());
    AlterSuiteParametersListener listener = new AlterSuiteParametersListener();
    listener.setTestRunArgs(testRunArgs);
    listener.setTestRunId(runId);
    driver.addAlterSuiteListener(listener);
    driver.run();
    Source source = null;
    try {
        File resultsFile = getResultsFile(getPreferredMediaType(testRunArgs), driver.getOutputDirectory());
        InputStream inStream = new FileInputStream(resultsFile);
        InputSource inSource = new InputSource(new InputStreamReader(inStream, StandardCharsets.UTF_8));
        source = new SAXSource(inSource);
        source.setSystemId(resultsFile.toURI().toString());
    } catch (IOException e) {
        LOGR.log(Level.SEVERE, "Error reading test results: " + e.getMessage());
    }
    return source;
}
 
开发者ID:opengeospatial,项目名称:teamengine,代码行数:60,代码来源:TestNGExecutor.java

示例10: create

import org.testng.TestNG; //导入方法依赖的package包/类
private TestNG create() {
    final TestNG result = new TestNG();
    result.setUseDefaultListeners(false);
    result.setVerbose(0);
    return result;
}
 
开发者ID:sskorol,项目名称:webdriver-supplier,代码行数:7,代码来源:ListenerTests.java

示例11: create

import org.testng.TestNG; //导入方法依赖的package包/类
private static TestNG create() {
    final TestNG result = new TestNG();
    result.setUseDefaultListeners(false);
    result.setVerbose(0);
    return result;
}
 
开发者ID:sskorol,项目名称:test-data-supplier,代码行数:7,代码来源:BaseTest.java

示例12: create

import org.testng.TestNG; //导入方法依赖的package包/类
public static TestNG create() {
  TestNG result = new TestNG();
  result.setUseDefaultListeners(false);
  result.setVerbose(0);
  return result;
}
 
开发者ID:testng-team,项目名称:testng-remote,代码行数:7,代码来源:SimpleBaseTest.java


注:本文中的org.testng.TestNG.setUseDefaultListeners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。