use of org.junit.internal.TextListener in project junit4 by junit-team.
the class TextListenerTest method setUp.
@Override
public void setUp() {
runner = new JUnitCore();
TestSystem system = new TestSystem();
results = system.outContents();
runner.addListener(new TextListener(system));
}
use of org.junit.internal.TextListener in project mockito by mockito.
the class MockitoRunnerBreaksWhenNoTestMethodsTest method ensure_the_test_runner_breaks.
@Test
public void ensure_the_test_runner_breaks() throws Exception {
JUnitCore runner = new JUnitCore();
// runner.addListener(new TextListener(System.out));
runner.addListener(new TextListener(DevNull.out));
Result result = runner.run(TestClassWithoutTestMethod.class);
assertEquals(1, result.getFailureCount());
assertTrue(result.getFailures().get(0).getException() instanceof MockitoException);
assertFalse(result.wasSuccessful());
}
use of org.junit.internal.TextListener in project ACS by ACS-Community.
the class TATJUnitRunner method runMain.
/**
* Modified version of {@link JUnitCore#runMain(JUnitSystem, String...)}.
* We restrict ourselves to running only one test class (or suite) at a time.
* This method is not thread-safe!
* @param testClass
* @return the result
* @throws IOException
*/
public Result runMain(Class<?> testClass) throws IOException {
Result result = null;
try {
keepTestOutput = testClass.isAnnotationPresent(KeepTestOutput.class);
createStreams(testClass);
redirectSysStreams();
JUnitSystem system = new JUnitSystem() {
public void exit(int code) {
System.exit(code);
}
public PrintStream out() {
return resultOut;
}
};
system.out().println("JUnit version " + Version.id());
RunListener listener = new TextListener(system);
// or should we listen directly?
delegate.addListener(listener);
result = delegate.run(testClass);
} finally {
restoreSysStreams();
closeStreams();
}
// in either case print a summary which automated tools can analyze (SPR ALMASW2005121)
int total = result.getRunCount();
int success = total - result.getFailureCount();
String runnerReport = "TEST_RUNNER_REPORT success/total: " + success + "/" + total;
System.out.println(runnerReport);
if (result.wasSuccessful()) {
System.out.println("JUnit test run succeeded");
if (!keepTestOutput) {
sysOutFile.delete();
sysErrFile.delete();
resultFile.delete();
}
} else {
System.err.println("JUnitRunner: Errors and/or failures during test execution!\n");
// Dump the JUnit test runner output, the captured stdout, and the captured stderr of the text execution to System.err.
dumpAndDeleteCapturedFile(resultFile, "Test execution trace:");
dumpAndDeleteCapturedFile(sysOutFile, "System.out during test execution:");
dumpAndDeleteCapturedFile(sysErrFile, "System.err during test execution:");
}
return result;
}
use of org.junit.internal.TextListener in project android by JetBrains.
the class PlainJUnitRunnable method run.
@Override
public void run() {
JUnitCore junit = new JUnitCore();
junit.addListener(new TextListener(System.out));
if (!junit.run(Request.aClass(mSuiteClass)).wasSuccessful()) {
System.exit(1);
}
}
use of org.junit.internal.TextListener in project poi by apache.
the class OOXMLLite method build.
void build() throws IOException, ClassNotFoundException {
List<Class<?>> lst = new ArrayList<Class<?>>();
//collect unit tests
String exclude = StringUtil.join("|", "BaseTestXWorkbook", "BaseTestXSheet", "BaseTestXRow", "BaseTestXCell", "BaseTestXSSFPivotTable", "TestSXSSFWorkbook\\$\\d", "TestUnfixedBugs", "MemoryUsage", "TestDataProvider", "TestDataSamples", "All.+Tests", "ZipFileAssert", "AesZipFileZipEntrySource", "TempFileRecordingSXSSFWorkbookWithCustomZipEntrySource", "PkiTestUtils", "TestCellFormatPart\\$\\d", "TestSignatureInfo\\$\\d", "TestCertificateEncryption\\$CertData", "TestPOIXMLDocument\\$OPCParser", "TestPOIXMLDocument\\$TestFactory", "TestXSLFTextParagraph\\$DrawTextParagraphProxy", "TestXSSFExportToXML\\$\\d", "TestXSSFExportToXML\\$DummyEntityResolver", "TestFormulaEvaluatorOnXSSF\\$Result", "TestFormulaEvaluatorOnXSSF\\$SS", "TestMultiSheetFormulaEvaluatorOnXSSF\\$Result", "TestMultiSheetFormulaEvaluatorOnXSSF\\$SS", "TestXSSFBugs\\$\\d");
System.out.println("Collecting unit tests from " + _testDir);
collectTests(_testDir, _testDir, lst, ".+.class$", ".+(" + exclude + ").class");
System.out.println("Found " + lst.size() + " classes");
//run tests
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.addListener(new TextListener(System.out));
Result result = jUnitCore.run(lst.toArray(new Class<?>[lst.size()]));
if (!result.wasSuccessful()) {
throw new RuntimeException("Tests did not succeed, cannot build ooxml-lite jar");
}
//see what classes from the ooxml-schemas.jar are loaded
System.out.println("Copying classes to " + _destDest);
Map<String, Class<?>> classes = getLoadedClasses(_ooxmlJar.getName());
for (Class<?> cls : classes.values()) {
String className = cls.getName();
String classRef = className.replace('.', '/') + ".class";
File destFile = new File(_destDest, classRef);
copyFile(cls.getResourceAsStream('/' + classRef), destFile);
if (cls.isInterface()) {
/**
* Copy classes and interfaces declared as members of this class
*/
for (Class<?> fc : cls.getDeclaredClasses()) {
className = fc.getName();
classRef = className.replace('.', '/') + ".class";
destFile = new File(_destDest, classRef);
copyFile(fc.getResourceAsStream('/' + classRef), destFile);
}
}
}
//finally copy the compiled .xsb files
System.out.println("Copying .xsb resources");
JarFile jar = new JarFile(_ooxmlJar);
Pattern p = Pattern.compile("schemaorg_apache_xmlbeans/(system|element)/.*\\.xsb");
try {
for (Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements(); ) {
JarEntry je = e.nextElement();
if (p.matcher(je.getName()).matches()) {
File destFile = new File(_destDest, je.getName());
copyFile(jar.getInputStream(je), destFile);
}
}
} finally {
jar.close();
}
}
Aggregations