How to detect that JUnit test is run by (Groovy) Eclipse

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to detect that JUnit test is run by (Groovy) Eclipse

Peter Niederwieser
Administrator
What's the best way to detect that a JUnit (in my case Spock) test is run by (Groovy) Eclipse?

Cheers,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: How to detect that JUnit test is run by (Groovy) Eclipse

Andrew Eisenberg
> What's the best way to detect that a JUnit (in my case Spock) test is run by
> (Groovy) Eclipse?

I don't understand your question.  Who's doing the detecting?  Perhaps
a bit more background would be helpful.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: How to detect that JUnit test is run by (Groovy) Eclipse

Peter Niederwieser
Administrator
The test itself is doing the detection, or more precisely Spock's @RunWith runner. The idea is to make Spock adapt to the environment in which it is run (Eclipse, IDEA, Grails, command line, etc.).
Reply | Threaded
Open this post in threaded view
|

Re: How to detect that JUnit test is run by (Groovy) Eclipse

Andrew Eisenberg
Thanks for the clarification.  I can't think of any sexy way of doing
this, only a bit of a kludge.

All JUnit tests inside of Eclipse are launched by a RemoteTestRunner
instance.  So, you can try something like this (pardon the
pseudo-code):

    public boolean someMethod() {
        try {
            throw new Exception();
        } catch (Exception e) {
            return containsStackFrame(e,
"org.eclipse.jdt.internal.junit.runner.RemoteTestRunner");
        }
        return false;
    }

As I said, a bit ugly, but should work.

On Sun, Aug 22, 2010 at 9:05 PM, Peter Niederwieser <[hidden email]> wrote:

>
> The test itself is doing the detection, or more precisely Spock's @RunWith
> runner. The idea is to make Spock adapt to the environment in which it is
> run (Eclipse, IDEA, Grails, command line, etc.).
> --
> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/How-to-detect-that-JUnit-test-is-run-by-Groovy-Eclipse-tp1282775p1283969.html
> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email