Usage of a own testTunner

View: New views
3 Messages — Rating Filter:   Alert me  

Usage of a own testTunner

by eclipse.beginner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I want to write my own junit4 runner, to add my testListener.

I want to extend the TestclassRunner, because this class contains a lot of functionality, which I want to have. And so I must only override the run(RunNotifier)methode to add my own testListener.

But the problem is, that this class is in the org.junit.internal.runners package, which is be discouraged.

When I now use this I get a classDefNotFoundException.

Which not internal  runner has a similar functionality?
Or how can I also use my own listener (extends RunListener).



Re: Usage of a own testTunner

by brettddaniel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

org.junit.runners.BlockJUnit4ClassRunner seems to be the best choice.  From the documentation:

  "BlockJUnit4ClassRunner has advantages for writers of custom JUnit
   runners that are slight changes to the default behavior"

Brett

--- In junit@..., "eclipse.beginner" <eclipse.beginner@...> wrote:

>
> Hello,
>
> I want to write my own junit4 runner, to add my testListener.
>
> I want to extend the TestclassRunner, because this class contains a lot of functionality, which I want to have. And so I must only override the run(RunNotifier)methode to add my own testListener.
>
> But the problem is, that this class is in the org.junit.internal.runners package, which is be discouraged.
>
> When I now use this I get a classDefNotFoundException.
>
> Which not internal  runner has a similar functionality?
> Or how can I also use my own listener (extends RunListener).
>



Re: Usage of a own testTunner

by Alistair Israel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 26, 2009 at 6:56 PM, eclipse.beginner
<eclipse.beginner@...> wrote:

> I want to write my own junit4 runner, to add my testListener.
>
> Which not internal  runner has a similar functionality?
> Or how can I also use my own listener (extends RunListener).

Hi. Have you looked at the new TestWatchman rule released in JUnit 4.7
to see if this'll fit your needs? Or a custom rule entirely?

- alistair
--
http://alistairisrael.wordpress.com