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].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.