GWTTestCase tests do run in DevMode normally. The reason they take so long to run (I believe) is because at least some of the code for the GWT module being tested is dynamically generated at test runtime. At the present the best one can do for GWTTestCase tests is to use a GWTTestSuite to allow GWT to group tests that share a module together so the same module doesn't have to be compiled multiple times. See here<http://code.google.com/webtoolkit/doc/1.6/DevGuideTesting.html#DevGuideJUnitSuites>for instructions on doing that.
The reason running your app in DevMode is able to refresh so quickly is because most of the code was compiled on the first page load. On refreshes DevMode only recompiles the things that have changed. Two consecutive runs of a GWTTestCase test, however, are run in separate processes so later runs can't take advantage of the work done by earlier runs. In general I think it's best to test as much as possible using pure Java unit tests that don't run through GWT at all, as they'll run much faster. You can use GWTMockUtilities<http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/junit/GWTMockUtilities.java> to stub out calls to GWT.create(), allowing you to create mocks of most GWT objects. See here <http://blog.danielwellman.com/2009/02/index.html> for a blog post on the subject. Jamie On Mon, Dec 7, 2009 at 10:02 AM, Robert Zaleski <[email protected]> wrote: > Hey Guys, > I've been trying to do some more TDD in places where I haven't > been able to. With GWT, I was looking and for some of the small > samples, a GWT Test Case takes 30 seconds. I timed doing a refresh of > Dev mode on 2.0-rc2 and that's taking like 6 seconds for our app. > > So my thought is, is there any framework for running Tests either > in Dev mode, or running them in GWT Test Case. I think the dual mode > is key, so in dev I can quickly rerun tests, to make sure things work, > and then cruise can automatically rerun them for me on every commit. > > I know another practice is to do MVP so we can just do straight up > JUnits, but I've been working on a lot of widget level work which we > don't have any coverage on right now due to the GWTTestCase slowness. > > Let me know if there's anything on this. For now I mocked out > something like so in a test main which I use for debugging the widget > by itself, which is cruder than I like, but it works. > > public interface Test { > public void doTest(); > public String getName(); > } > > ArrayList<Test> tests = new ArrayList<Test>(); > > public void makeTests() { > // Make other tests > tests.add(new Test() { public void doTest() { > } > public String getName() { return "No-Op Test"; } > }); > } > > public void runTests() { > Document d = Document.get(); > int failed = 0; > for ( Test t : tests ) { > try { > t.doTest(); > } catch ( Throwable e) { > failed++; > ParagraphElement p = d.createPElement(); > StringBuilder sb = new StringBuilder(); > sb.append("ERROR during > \"").append(t.getName()).append("\": > ").append(e.getMessage()).append("<br>"); > > StackTraceElement[] stack = > e.getStackTrace(); > for ( int i = 0; i < stack.length; i++ ) { > StackTraceElement el = stack[i]; > > sb.append(el.getFileName()).append('.').append(el.getMethodName > ()) > .append("() : > ").append(el.getLineNumber()).append("<br>"); > } > > p.setInnerHTML(sb.toString()); > d.getBody().appendChild(p); > } > } > ParagraphElement p = d.createPElement(); > p.setInnerHTML("Passed " + ( tests.size() - failed ) + " / " > + > tests.size() ); > d.getBody().appendChild(p); > } > > Longer term, I'd like to do something generator based, but I was > curious what other thoughts there were on doing development like > this. Dev Mode seems to be optimized to refresh/re-run faster > > -- > > 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]<google-web-toolkit%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > > -- 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.
