本文整理汇总了Java中junit.textui.ResultPrinter类的典型用法代码示例。如果您正苦于以下问题:Java ResultPrinter类的具体用法?Java ResultPrinter怎么用?Java ResultPrinter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResultPrinter类属于junit.textui包,在下文中一共展示了ResultPrinter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFailure
import junit.textui.ResultPrinter; //导入依赖的package包/类
public void testFailure() {
String expected = expected(new String[]{".F", "Time: 0", "Failures here", "", "FAILURES!!!", "Tests run: 1, Failures: 1, Errors: 0", ""});
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
@Override
public void printFailures(TestResult result) {
getWriter().println("Failures here");
}
};
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() {
@Override
public void runTest() {
throw new AssertionFailedError();
}
});
runner.doRun(suite);
assertEquals(expected, output.toString());
}
示例2: testError
import junit.textui.ResultPrinter; //导入依赖的package包/类
public void testError() {
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());
}
示例3: testError
import junit.textui.ResultPrinter; //导入依赖的package包/类
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());
}
示例4: testErrorAdapted
import junit.textui.ResultPrinter; //导入依赖的package包/类
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());
}
示例5: testFailure
import junit.textui.ResultPrinter; //导入依赖的package包/类
public void testFailure() {
String expected= expected(new String[]{".F", "Time: 0", "Failures here", "", "FAILURES!!!", "Tests run: 1, Failures: 1, Errors: 0", ""});
ResultPrinter printer= new TestResultPrinter(new PrintStream(output)) {
public void printFailures(TestResult result) {
getWriter().println("Failures here");
}
};
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() { public void runTest() {throw new AssertionFailedError();}});
runner.doRun(suite);
assertEquals(expected, output.toString());
}
示例6: testError
import junit.textui.ResultPrinter; //导入依赖的package包/类
public void testError() {
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)) {
public void printErrors(TestResult result) {
getWriter().println("Errors here");
}
};
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() { public void runTest() throws Exception {throw new Exception();}});
runner.doRun(suite);
assertEquals(expected, output.toString());
}
示例7: testSingle
import junit.textui.ResultPrinter; //导入依赖的package包/类
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);
}
示例8: TestRunner
import junit.textui.ResultPrinter; //导入依赖的package包/类
/**
* Constructs a TestRunner using the given ResultPrinter all the output
*/
public TestRunner(ResultPrinter printer) {
super(printer);
}
示例9: createPrinter
import junit.textui.ResultPrinter; //导入依赖的package包/类
protected ResultPrinter createPrinter() {
return new CoreTestPrinter(System.out, fFlags);
}
示例10: TestRunner
import junit.textui.ResultPrinter; //导入依赖的package包/类
/**
* Constructs a TestRunner using the given stream for all the output
*/
public TestRunner(PrintStream writer) {
this(new ResultPrinter(writer));
}
示例11: setPrinter
import junit.textui.ResultPrinter; //导入依赖的package包/类
public void setPrinter(ResultPrinter printer) {
fPrinter= printer;
}
示例12: TestRunnerImprovedErrorHandling
import junit.textui.ResultPrinter; //导入依赖的package包/类
/**
* Delegates to the super constructor.
*
* @param resultPrinter The location to write test results to.
*/
public TestRunnerImprovedErrorHandling(ResultPrinter resultPrinter)
{
super(resultPrinter);
}