Reviewers: jlabanca, rdayal,
Description:
Add a warning in GWTTestCase to help users that accidentally run a GWT
JUnit Test as a JUnit Test.
This mistake is easy to make (especially in Eclipse.) Therefore, we
display a helpful error suggesting the user run as a GWTJUnitTest if an
exception is thrown and the devjar property is not set.
Please review this at http://gwt-code-reviews.appspot.com/1224801/show
Affected files:
M user/src/com/google/gwt/junit/client/GWTTestCase.java
Index: user/src/com/google/gwt/junit/client/GWTTestCase.java
===================================================================
--- user/src/com/google/gwt/junit/client/GWTTestCase.java (revision 9436)
+++ user/src/com/google/gwt/junit/client/GWTTestCase.java (working copy)
@@ -428,17 +428,26 @@
*/
@Override
protected void runTest() throws Throwable {
- if (this.getName() == null) {
- throw new IllegalArgumentException(
- "GWTTestCases require a name; \""
- + this.toString()
- + "\" has none. Perhaps you used TestSuite.addTest()
instead of addTestClass()?");
- }
-
- if (isPureJava()) {
- super.runTest();
- } else {
- JUnitShell.runTest(this, testResult);
+ try {
+ if (this.getName() == null) {
+ throw new IllegalArgumentException(
+ "GWTTestCases require a name; \""
+ + this.toString()
+ + "\" has none. Perhaps you used TestSuite.addTest()
instead of addTestClass()?");
+ }
+
+ if (isPureJava()) {
+ super.runTest();
+ } else {
+ JUnitShell.runTest(this, testResult);
+ }
+ } catch (Throwable thowable) {
+ // Check to see if gwt.devjar is null. If so, notify the
+ // user that they may have run as a JUnitTest instead of a
GWTJUnitTest.
+ if (System.getProperty("gwt.devjar") == null) {
+ testResult.addError(this, new Throwable("No GWT devjar property
found. Did you mean to run as a GWT JUnit Test instead of a JUnit Test?"));
+ }
+ throw thowable;
}
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors