use of junit.textui.TestRunner in project junit4 by junit-team.
the class TextRunnerSingleMethodTest method testSingle.
public void testSingle() throws Exception {
TestRunner t = new TestRunner();
t.setPrinter(new ResultPrinter(new PrintStream(new ByteArrayOutputStream())));
String[] args = { "-m", "junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest.testWasInvoked" };
fgWasInvoked = false;
t.start(args);
assertTrue(fgWasInvoked);
}
use of junit.textui.TestRunner in project junit4 by junit-team.
the class ForwardCompatibilityPrintingTest method testErrorAdapted.
public void testErrorAdapted() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));
String expected = expected(new String[] { ".E", "Time: 0", "Errors here", "", "FAILURES!!!", "Tests run: 1, Failures: 0, Errors: 1", "" });
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
@Override
public void printErrors(TestResult result) {
getWriter().println("Errors here");
}
};
runner.setPrinter(printer);
runner.doRun(new JUnit4TestAdapter(ATest.class));
assertEquals(expected, output.toString());
}
use of junit.textui.TestRunner in project junit4 by junit-team.
the class ForwardCompatibilityPrintingTest method testError.
public void testError() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));
String expected = expected(new String[] { ".E", "Time: 0", "Errors here", "", "FAILURES!!!", "Tests run: 1, Failures: 0, Errors: 1", "" });
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
@Override
public void printErrors(TestResult result) {
getWriter().println("Errors here");
}
};
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() {
@Override
public void runTest() throws Exception {
throw new Exception();
}
});
runner.doRun(suite);
assertEquals(expected, output.toString());
}
use of junit.textui.TestRunner in project kotlin by JetBrains.
the class StdlibTest method testStdlib.
public void testStdlib() throws ClassNotFoundException {
GenerationState state = KotlinToJVMBytecodeCompiler.INSTANCE.analyzeAndGenerate(getEnvironment());
if (state == null) {
fail("There were compilation errors");
}
classLoader = new GeneratedClassLoader(state.getFactory(), ForTestCompileRuntime.runtimeAndReflectJarClassLoader()) {
@Override
public Class<?> loadClass(@NotNull String name) throws ClassNotFoundException {
if (name.startsWith("junit.") || name.startsWith("org.junit.")) {
return StdlibTest.class.getClassLoader().loadClass(name);
}
return super.loadClass(name);
}
};
TestSuite tests = new TestSuite("Standard Library Tests");
for (KtFile file : getEnvironment().getSourceFiles()) {
// Skip JS tests
if (file.getVirtualFile().getPath().contains("/js/"))
continue;
for (KtDeclaration declaration : file.getDeclarations()) {
if (!(declaration instanceof KtClass))
continue;
ClassDescriptor descriptor = (ClassDescriptor) BindingContextUtils.getNotNull(state.getBindingContext(), BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
Test test = createTest(classLoader, state.getTypeMapper().mapClass(descriptor).getClassName());
if (test != null) {
tests.addTest(test);
}
}
}
TestResult result = new TestRunner(System.err).doRun(tests);
if (!result.wasSuccessful()) {
fail("Some stdlib tests failed, see stderr for details");
}
}
use of junit.textui.TestRunner in project junit4 by junit-team.
the class TextFeedbackTest method setUp.
@Override
public void setUp() {
output = new ByteArrayOutputStream();
runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));
}
Aggregations