@Test public void testMethod() { String suite = "src/test/resources/parametertest/1417.xml"; TestNG testNG = new TestNG(); testNG.setTestSuites(Collections.singletonList(suite)); testNG.run(); Assert.assertFalse(testNG.hasFailure()); Assert.assertFalse(testNG.hasSkip()); Assert.assertEquals(AnotherTestClassSample.getInstance().getBrowsername(), "chrome"); List<String> actual = YetAnotherTestClassSample.getInstance().getBrowsers(); Assert.assertEquals(actual.size(), 2); Assert.assertEquals(actual, Arrays.asList("safari", "safari")); } }
public void start() { IReporter stdoutReporter = new StdOutReporter(); TestListenerAdapter tla = new TestListenerAdapter(); TestNG testNG = new TestNG(); testNG.setOutputDirectory(TEST_PATH); testNG.getReporters().add(stdoutReporter); testNG.setTestClasses(new Class[]{TestCollector.class}); testNG.addListener(tla); testNG.run(); if (testNG.hasFailure()) { log.error("Test(s) have failed see output above"); System.exit(2); } }
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); } }
testNG.run(); if(testNG.hasFailure()) { // Throw an exception to make mvn goal fail throw new Exception("Failed Tests");
@Override public boolean runUnitTests() { TestNG testNG = new TestNG(); setXmlSuitePath(testNG); if (configuration.getTestSuite().getOutputDirectory() != null) { testNG.setOutputDirectory(configuration.getTestSuite().getOutputDirectory()); } testNG.run(); return !(testNG.hasFailure() || testNG.hasSkip()); }