I found the goal interresting, but as the example requires "user" validation (in the sake of simplicity) I think the examples are not realistic enough...
I changed the tests and did something like:
> public void testHelloWorld() {
> ByteArrayOutputStream stream = new
> ByteArrayOutputStream();
> PrintStream pStream =
> new PrintStream(stream);
> System.setOut(pStream);
>
> System.out.print("Hello, World!");
>
> assertEquals("Hello, World!",
> stream.toString());
> }
The threaded example:
> public void testHelloWorld() throws
> Throwable {
> ByteArrayOutputStream stream =
> new ByteArrayOutputStream();
> PrintStream pStream =
> new PrintStream(stream);
> System.setOut(pStream);
>
> TestRunnable[] tr = {
> new DelayedHello(5000)};
>
> MultiThreadedTestRunner mtRunner =
> new MultiThreadedTestRunner(tr);
>
> mtRunner.runTestRunnables();
>
> assertEquals("Hello, World!",
> stream.toString());
> }
The bad one is:
> public void testHelloWorld() {
> ByteArrayOutputStream stream =
> new ByteArrayOutputStream();
> PrintStream pStream =
> new PrintStream(stream);
> System.setOut(pStream);
>
> new DelayedHello(5000);
>
> assertEquals("Hello, World!",
> stream.toString());
> } |