use of org.testng.TestNG in project mockito by mockito.
the class TestNGShouldFailWhenMockitoListenerFailsTest method new_TestNG_with_failure_recorder_for.
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;
}
use of org.testng.TestNG in project jdk8u_jdk by JetBrains.
the class ReflectionFactoryTest method main.
// Main can be used to run the tests from the command line with only testng.jar.
@SuppressWarnings("raw_types")
@Test(enabled = false)
public static void main(String[] args) {
Class<?>[] testclass = { ReflectionFactoryTest.class };
TestNG testng = new TestNG();
testng.setTestClasses(testclass);
testng.run();
}
use of org.testng.TestNG in project spring-framework by spring-projects.
the class ClassLevelDirtiesContextTestNGTests method runTestClassAndAssertStats.
private void runTestClassAndAssertStats(Class<?> testClass, int expectedTestCount) {
final int expectedTestFailureCount = 0;
final int expectedTestStartedCount = expectedTestCount;
final int expectedTestFinishedCount = expectedTestCount;
final TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
final TestNG testNG = new TestNG();
testNG.addListener((ITestNGListener) listener);
testNG.setTestClasses(new Class<?>[] { testClass });
testNG.setVerbose(0);
testNG.run();
assertEquals("Failures for test class [" + testClass + "].", expectedTestFailureCount, listener.testFailureCount);
assertEquals("Tests started for test class [" + testClass + "].", expectedTestStartedCount, listener.testStartCount);
assertEquals("Successful tests for test class [" + testClass + "].", expectedTestFinishedCount, listener.testSuccessCount);
}
use of org.testng.TestNG in project gradle by gradle.
the class TestNGTestClassProcessor method runTests.
private void runTests() {
TestNG testNg = new TestNG();
testNg.setOutputDirectory(testReportDir.getAbsolutePath());
testNg.setDefaultSuiteName(options.getDefaultSuiteName());
testNg.setDefaultTestName(options.getDefaultTestName());
if (options.getParallel() != null) {
testNg.setParallel(options.getParallel());
}
if (options.getThreadCount() > 0) {
testNg.setThreadCount(options.getThreadCount());
}
invokeVerifiedMethod(testNg, "setConfigFailurePolicy", String.class, options.getConfigFailurePolicy(), 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()));
// 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() || !options.getIncludedTestsCommandLine().isEmpty()) {
testNg.addListener(new SelectedTestsFilter(options.getIncludedTests(), options.getIncludedTestsCommandLine()));
}
if (!suiteFiles.isEmpty()) {
testNg.setTestSuites(GFileUtils.toPaths(suiteFiles));
} else {
testNg.setTestClasses(testClasses.toArray(new Class[0]));
}
testNg.addListener((Object) adaptListener(new TestNGTestResultProcessorAdapter(resultProcessor, idGenerator, clock)));
testNg.run();
}
use of org.testng.TestNG in project pinot by linkedin.
the class HybridScanBasedCommandLineTestRunner method main.
public static void main(String[] args) throws Exception {
if (args.length == 0) {
usage();
}
int expectedArgsLen = 5;
int ix = 0;
// Parse optional arguments first.
while (args[ix].startsWith("-")) {
if (args[ix].equals("--record")) {
CustomHybridClusterScanComparisonIntegrationTest._recordScanResponses = true;
} else if (args[ix].equals("--llc")) {
CustomHybridClusterScanComparisonIntegrationTest._useLlc = true;
} else {
usage();
}
ix++;
expectedArgsLen++;
}
if (args.length != expectedArgsLen) {
usage();
}
final String tableName = args[ix++];
final String schemaFilePath = args[ix++];
// we expect a dir called 'avro-files' and files called 'queries.txt' and 'scan-responses.txt' in here
final String segQueryDirPath = args[ix++];
final String invIndexCols = args[ix++];
final String sortedCol = args[ix++];
CustomHybridClusterScanComparisonIntegrationTest.setParams(tableName, schemaFilePath, segQueryDirPath, invIndexCols, sortedCol);
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { CustomHybridClusterScanComparisonIntegrationTest.class });
testng.addListener(tla);
testng.run();
System.out.println("Passed tests: " + tla.getPassedTests());
if (!tla.getSkippedTests().isEmpty()) {
System.out.println("Skipped tests: " + tla.getSkippedTests());
}
System.out.println(tla.toString());
if (!tla.getFailedTests().isEmpty()) {
System.err.println("Failed tests:" + tla.getFailedTests());
System.exit(1);
}
System.exit(0);
}
Aggregations