use of org.junit.runner.Description in project junit-dataprovider by TNG.
the class DataProviderFilterTest method testShouldRunShouldReturnTrueForMultipleChildDescriptionWithLastMatching.
@Test
public void testShouldRunShouldReturnTrueForMultipleChildDescriptionWithLastMatching() {
// Given:
doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe();
// @formatter:off
Description description = setupDescription(false, "", setupDescription(true, "testOther[1: ](com.tngtech.ClazzOther)"), setupDescription(false, "testOther[1: ](com.tngtech.ClazzOther)"), setupDescription(true, "testMain[1: ](com.tngtech.Clazz)"));
// @formatter:on
// When:
boolean result = underTest.shouldRun(description);
// Then:
assertThat(result).isTrue();
}
use of org.junit.runner.Description in project junit-dataprovider by TNG.
the class DataProviderFilterTest method testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedPackageName.
@Test
public void testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedPackageName() {
// Given:
doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe();
Description description = setupDescription(true, "testMain[1: ](com.tngtech.other.Clazz)");
// When:
boolean result = underTest.shouldRun(description);
// Then:
assertThat(result).isFalse();
}
use of org.junit.runner.Description in project statecharts by Yakindu.
the class GTestRunner method getDescription.
/*
* (non-Javadoc)
*
* @see org.junit.runner.Runner#getDescription()
*/
@Override
public Description getDescription() {
Description description = Description.createSuiteDescription(testClass);
for (Entry<String, List<String>> entry : testCases.entrySet()) {
for (String test : entry.getValue()) {
String testCase = entry.getKey();
Description childDescription = createDescription(testCase, test);
description.addChild(childDescription);
}
}
return description;
}
use of org.junit.runner.Description in project statecharts by Yakindu.
the class GTestRunner method runGTests.
private void runGTests(RunNotifier notifier) throws IOException, InterruptedException {
String program = testClass.getAnnotation(GTest.class).program();
if (Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32)) {
program += ".exe";
}
String targetProject = testClass.getAnnotation(GTest.class).testBundle();
IPath programPath = new Path(targetProject).append(program);
IResource programFile = ResourcesPlugin.getWorkspace().getRoot().findMember(programPath);
IContainer programContainer = programFile.getParent();
if (!programContainer.isAccessible()) {
throw new RuntimeException("Test program container " + programContainer.getLocation().toOSString() + " inaccessible");
}
File directory = programContainer.getLocation().toFile();
Process process = new ProcessBuilder(programFile.getLocation().toOSString()).redirectErrorStream(true).directory(directory).start();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
boolean started = false;
boolean running = false;
StringBuilder message = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("[====")) {
if (started) {
started = false;
// Eat remaining input
char[] buffer = new char[4096];
while (reader.read(buffer) != -1) ;
break;
}
started = true;
} else {
TestOutput testOutput = parseTestOutput(line);
if (testOutput != null) {
Description description = testOutput.toDescription();
switch(testOutput.getStatus()) {
case TestOutput.RUN:
running = true;
message.setLength(0);
notifier.fireTestStarted(description);
break;
case TestOutput.OK:
running = false;
notifier.fireTestFinished(description);
break;
default:
running = false;
notifier.fireTestFailure(new Failure(description, new AssertionFailedError(message.toString())));
notifier.fireTestFinished(description);
break;
}
} else if (running) {
message.append(line);
message.append("\n");
}
}
}
process.waitFor();
if (started) {
throw new RuntimeException("Test quit unexpectedly (exit status " + process.exitValue() + "):\n" + message);
}
}
use of org.junit.runner.Description in project tests by datanucleus.
the class DataNucleusTestWatcher method filterDatastores.
private void filterDatastores(Class<?> testClass) {
List<DatastoreKey> filterDatastores = findAnnotationAtMethodOrClass(Datastore.class, description, testClass).map(annotation -> asList(annotation.value())).orElse(emptyList());
if (!filterDatastores.isEmpty()) {
String datastoreKey = JDOPersistenceTestCase.storeMgr.getStoreManagerKey();
DatastoreKey currentDatastore = DatastoreKey.valueOf(datastoreKey.toUpperCase());
DatastoreKey vendorIdDatastore = JDOPersistenceTestCase.vendorID == null ? null : DatastoreKey.valueOf(JDOPersistenceTestCase.vendorID.toUpperCase());
Assume.assumeTrue(filterDatastores.stream().anyMatch(filter -> filter.equals(currentDatastore) || filter.equals(vendorIdDatastore)));
}
}
Aggregations