I have found the following solution:

I write the client side test first, extending GWTTestCase. This one
gets executed in a client test suite (GWTTestSuite).

I extend this test to create the server side, standard JUnit 3 (not 4)
compatible test. You only have to override the runTest() method a copy/
paste (no other way) the standard runTest() code with no call to super
() to prevent the JUnit GWT shell from executing the test.

eg:

public class EntityBeanServerTest extends EntityBeanTest {
    @Override
    protected void runTest() throws Throwable {
        assertNotNull("TestCase.fName cannot be null", getName());
        Method runMethod = null;
        try {
            runMethod = getClass().getMethod(getName(), (Class[])
null);
        } catch (NoSuchMethodException e) {
            fail((new StringBuilder()).append("Method \"").append
(getName()).append("\" not found").toString());
        }
        if (!Modifier.isPublic(runMethod.getModifiers()))
            fail((new StringBuilder()).append("Method \"").append
(getName()).append("\" should be public").toString());
        try {
            runMethod.invoke(this, new Object[0]);
        } catch (InvocationTargetException e) {
            e.fillInStackTrace();
            throw e.getTargetException();
        } catch (IllegalAccessException e) {
            e.fillInStackTrace();
            throw e;
        }
    }
}

Best thing I found.

Remy



On 12 nov, 11:58, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have these tests for model entities and other supporting classes
> that are Javascript and/or serialization compatible.
>
> I want to run these tests in my server side only JUnit tests, outside
> of the container. (Spring based server so it's easy to do container-
> less testing). These tests are run all days long by developers and
> must run super fast (they use an embedded hsqldb database with test
> data sourced at the beginning of each test class).
>
> However, for these hybrid classes, I also want to run the same tests
> in GWT hosted and web modes.
>
> Question is:
>
> How can I write these tests only once and be able to run them in pure
> server-side JUnit tests and also in a GWT (Javascript) environment?
>
> The best scenario would be:
>
> * Write the server-side only test (compatible with JUnit 4 if
> possible).
> * Extends this test to make it run in JRE emulation and web modes by
> implementing an interface thru aggregation of GWT helper classes?
>
> Thank you for your help,
>
> Remy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to