本文整理匯總了Java中org.junit.internal.TextListener類的典型用法代碼示例。如果您正苦於以下問題:Java TextListener類的具體用法?Java TextListener怎麽用?Java TextListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TextListener類屬於org.junit.internal包,在下文中一共展示了TextListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doRun
import org.junit.internal.TextListener; //導入依賴的package包/類
public Result doRun(Test suite, boolean wait) {
MarathonTestRunner runner = new MarathonTestRunner();
runReportDir = argProcessor.getReportDir();
String resultsDir = new File(runReportDir, "results").getAbsolutePath();
if (runReportDir != null) {
System.setProperty(Constants.PROP_REPORT_DIR, runReportDir);
System.setProperty(Constants.PROP_IMAGE_CAPTURE_DIR, runReportDir);
System.setProperty("allure.results.directory", resultsDir);
runner.addListener(new AllureMarathonRunListener());
}
runner.addListener(new TextListener(System.out));
Result result = runSuite(suite, runner);
MarathonTestCase.reset();
if (runReportDir != null && !argProcessor.isSkipreports()) {
AllureUtils.launchAllure(false, resultsDir, new File(runReportDir, "reports").getAbsolutePath());
}
return result;
}
示例2: runTests
import org.junit.internal.TextListener; //導入依賴的package包/類
public void runTests(String outputDir) {
JUnitCore junit = new JUnitCore();
if (outputDir == null) {
junit.addListener(new TextListener(System.out));
} else {
junit.addListener(new JUnitResultFormatterAsRunListener(new XMLJUnitResultFormatter()) {
@Override
public void testStarted(Description description) throws Exception {
formatter.setOutput(new FileOutputStream(
new File(outputDir, "TEST-" + description.getDisplayName() + ".xml")));
super.testStarted(description);
}
});
}
junit.run(TestContainer.class);
}
示例3: testSystem
import org.junit.internal.TextListener; //導入依賴的package包/類
@Test
public void testSystem() throws Throwable {
Computer computer = new Computer();
JUnitCore jUnitCore = new JUnitCore();
ByteArrayOutputStream capture = new ByteArrayOutputStream();
final PrintStream printStream = new PrintStream(capture);
TextListener listener = new TextListener(printStream);
jUnitCore.addListener(listener);
PrintStream systemOut = System.out;
System.setOut(printStream);
try {
jUnitCore.run(computer, ExampleTest.class);
} finally {
System.setOut(systemOut);
}
String output = capture.toString("UTF-8");
output = normalizeOutput(output);
String expectedOutput = getResource("/CompositeTest.testSystem.expected.txt");
Assert.assertEquals(expectedOutput, output);
}
示例4: addListeners
import org.junit.internal.TextListener; //導入依賴的package包/類
private void addListeners(List<RunListener> listeners, JUnitCore testRunner,
PrintStream writer) {
if (getBooleanArgument(ARGUMENT_SUITE_ASSIGNMENT)) {
listeners.add(new SuiteAssignmentPrinter());
} else {
listeners.add(new TextListener(writer));
listeners.add(new LogRunListener());
mInstrumentationResultPrinter = new InstrumentationResultPrinter();
listeners.add(mInstrumentationResultPrinter);
listeners.add(new ActivityFinisherRunListener(this,
new ActivityFinisher()));
addDelayListener(listeners);
addCoverageListener(listeners);
}
addListenersFromArg(listeners, writer);
addListenersFromManifest(listeners, writer);
for (RunListener listener : listeners) {
testRunner.addListener(listener);
if (listener instanceof InstrumentationRunListener) {
((InstrumentationRunListener) listener).setInstrumentation(this);
}
}
}
示例5: main
import org.junit.internal.TextListener; //導入依賴的package包/類
/**
* @param args
*/
public static void main(String[] args) {
JUnitCore junit = new JUnitCore();
junit.addListener(new TextListener(System.out));
junit.run(
// LearnerTest.class,
AtomTest.class,
ClauseTest.class,
ConfigTest.class,
GAtomTest.class,
GClauseTest.class,
GroundingTest.class,
InferenceTest.class,
LiteralTest.class,
ParsingLoadingTest.class,
PredicateTest.class,
TermTest.class,
TupleTest.class,
TypeTest.class
);
}
示例6: getExpectedOutput
import org.junit.internal.TextListener; //導入依賴的package包/類
private ByteArrayOutputStream getExpectedOutput(Class<?> testClass) {
JUnitCore core = new JUnitCore();
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(byteStream);
printStream.println("JUnit4 Test Runner");
RunListener listener = new TextListener(printStream);
core.addListener(listener);
Request request = Request.classWithoutSuiteMethod(testClass);
core.run(request);
printStream.close();
return byteStream;
}
示例7: run
import org.junit.internal.TextListener; //導入依賴的package包/類
/**
* A method to allow tests to be run from simple scripts without all the JUnit infrastructure
*
* @return The number of failed tests
*/
public int run() {
JoranConfigurator configurator = new JoranConfigurator();
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
configurator.setContext(context);
context.reset();
configurator.doConfigure(classpath("/logback-morc.xml"));
} catch (JoranException e) {
throw new RuntimeException(e);
}
JUnitCore core = new JUnitCore();
core.addListener(new TextListener(System.out));
try {
Result r = core.run(new MorcParameterized(this));
return r.getFailureCount();
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
示例8: doWork
import org.junit.internal.TextListener; //導入依賴的package包/類
@Override
protected int doWork() throws Exception {
//this is called from the command line, so we should set to use the distributed cluster
IntegrationTestingUtility.setUseDistributedCluster(conf);
Class<?>[] classes = findIntegrationTestClasses();
LOG.info("Found " + classes.length + " integration tests to run:");
for (Class<?> aClass : classes) {
LOG.info(" " + aClass);
}
JUnitCore junit = new JUnitCore();
junit.addListener(new TextListener(System.out));
Result result = junit.run(classes);
return result.wasSuccessful() ? 0 : 1;
}
示例9: newRunListener
import org.junit.internal.TextListener; //導入依賴的package包/類
/**
* Returns a new {@link RunListener} instance for the given {@param outputFormat}.
*/
public RunListener newRunListener(OutputFormat outputFormat) {
switch (outputFormat) {
case JUNIT:
out.println("JUnit version " + Version.id());
return new TextListener(out);
case GTM_UNIT_TESTING:
return new GtmUnitTestingTextListener();
default:
throw new IllegalArgumentException("outputFormat");
}
}
示例10: doWork
import org.junit.internal.TextListener; //導入依賴的package包/類
@Override
protected int doWork() throws Exception {
//this is called from the command line, so we should set to use the distributed cluster
IntegrationTestingUtility.setUseDistributedCluster(conf);
Class<?>[] classes = findIntegrationTestClasses();
LOG.info("Found " + classes.length + " integration tests to run");
JUnitCore junit = new JUnitCore();
junit.addListener(new TextListener(System.out));
Result result = junit.run(classes);
return result.wasSuccessful() ? 0 : 1;
}
示例11: runTest
import org.junit.internal.TextListener; //導入依賴的package包/類
private static void runTest(String test) {
try {
String[] classAndMethod = test.split("#");
System.out.println(test);
Request request = Request.method(Class.forName(classAndMethod[0]), classAndMethod[1]);
JUnitCore junit = new JUnitCore();
junit.addListener(new TextListener(System.out));
junit.run(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
示例12: didBecomeActive
import org.junit.internal.TextListener; //導入依賴的package包/類
@Override
public void didBecomeActive(UIApplication application) {
super.didBecomeActive(application);
NSException.registerDefaultJavaUncaughtExceptionHandler();
Computer computer = new Computer();
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.addListener(new TextListener(System.out));
jUnitCore.run(computer, getTestClasses());
}
示例13: newRunListener
import org.junit.internal.TextListener; //導入依賴的package包/類
/**
* Returns a new {@link RunListener} instance for the given {@param outputFormat}.
*/
public RunListener newRunListener(OutputFormat outputFormat) {
switch (outputFormat) {
case JUNIT:
out.println("JUnit version " + Version.id());
return new TextListener(out);
case GTM_UNIT_TESTING:
return new GtmUnitTestingTextListener();
default:
throw new IllegalArgumentException("outputFormat");
}
}
示例14: run
import org.junit.internal.TextListener; //導入依賴的package包/類
public Result run(String[] args) throws Exception {
// List all classes - adapted from JUnitCore code
List<Class<?>> classes = new ArrayList<Class<?>>();
List<Failure> missingClasses = new ArrayList<Failure>();
for (String arg : args) {
try {
classes.add(Class.forName(arg));
} catch (ClassNotFoundException e) {
Description description = Description.createSuiteDescription(arg);
Failure failure = new Failure(description, e);
missingClasses.add(failure);
}
}
// Create standard JUnitCore
JUnitCore jcore = new JUnitCore();
// Create default "system"
JUnitSystem jsystem = new RealSystem();
// Setup default listener
jcore.addListener(new TextListener(jsystem));
// Add XML generator listener
jcore.addListener(new XMLTestReporter());
Result result = jcore.run(classes.toArray(new Class[0]));
for (Failure each : missingClasses) {
result.getFailures().add(each);
}
return result;
}
示例15: runMain
import org.junit.internal.TextListener; //導入依賴的package包/類
/**
* @param system
* @param args from main()
*/
Result runMain(JUnitSystem system, String... args) {
system.out().println("JUnit version " + Version.id());
JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args);
RunListener listener = new TextListener(system);
addListener(listener);
return run(jUnitCommandLineParseResult.createRequest(defaultComputer()));
}