Reviewers: amitmanjhi,
Description:
This patch allow a test case or test class to be annotated as follows:
@DoNotRunWith(Platform.Devel)
Is there any alternate plan for accomplishing this? I want to add some
GWTTestCase tests for the cross-site linker, but since the cross-site
linker doesn't support development mode, I can't do the usual trick of
having the test case check GWT.isScript() at the beginning.
Please review this at http://gwt-code-reviews.appspot.com/171801
Affected files:
user/src/com/google/gwt/junit/JUnitShell.java
user/src/com/google/gwt/junit/Platform.java
user/test/com/google/gwt/junit/client/GWTTestCaseTest.java
Index: user/src/com/google/gwt/junit/JUnitShell.java
===================================================================
--- user/src/com/google/gwt/junit/JUnitShell.java (revision 7697)
+++ user/src/com/google/gwt/junit/JUnitShell.java (working copy)
@@ -1116,9 +1116,23 @@
private boolean mustNotExecuteTest(Set<Platform> bannedPlatforms) {
// TODO (amitmanjhi): Remove this hard-coding. A RunStyle somehow
needs to
// specify how it interacts with the platforms.
- return runStyle instanceof RunStyleHtmlUnit
- && (bannedPlatforms.contains(Platform.HtmlUnitBug)
- || bannedPlatforms.contains(Platform.HtmlUnit));
+ if (runStyle instanceof RunStyleHtmlUnit
+ && (bannedPlatforms.contains(Platform.HtmlUnitBug) ||
bannedPlatforms.contains(Platform.HtmlUnit))) {
+ return true;
+ }
+
+ if (developmentMode) {
+ if (bannedPlatforms.contains(Platform.Devel)) {
+ return true;
+ }
+ } else {
+ // Prod mode
+ if (bannedPlatforms.contains(Platform.Prod)) {
+ return true;
+ }
+ }
+
+ return false;
}
private boolean mustRetry(int numTries) {
Index: user/src/com/google/gwt/junit/Platform.java
===================================================================
--- user/src/com/google/gwt/junit/Platform.java (revision 7697)
+++ user/src/com/google/gwt/junit/Platform.java (working copy)
@@ -22,6 +22,8 @@
* between HtmlUnit and non-HtmlUnit platforms.
*/
public enum Platform {
+ Devel,
HtmlUnitBug,
- HtmlUnit
+ HtmlUnit,
+ Prod,
}
Index: user/test/com/google/gwt/junit/client/GWTTestCaseTest.java
===================================================================
--- user/test/com/google/gwt/junit/client/GWTTestCaseTest.java (revision
7697)
+++ user/test/com/google/gwt/junit/client/GWTTestCaseTest.java (working
copy)
@@ -24,6 +24,7 @@
import static
com.google.gwt.junit.client.GWTTestCaseTest.SetUpTearDownState.IS_SETUP;
import static
com.google.gwt.junit.client.GWTTestCaseTest.SetUpTearDownState.IS_TORNDOWN;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.DoNotRunWith;
import com.google.gwt.junit.Platform;
import com.google.gwt.user.client.Timer;
@@ -366,12 +367,28 @@
fail("Unexpected exception during assertTrue(String, boolean)
testing");
}
- /*
+ /**
* Just setting the htmlunit mode.
*/
@DoNotRunWith(Platform.HtmlUnitBug)
public void testSetRetry() {
htmlunitMode = false;
+ }
+
+ /**
+ * Test skipping a test for dev mode.
+ */
+ @DoNotRunWith(Platform.Devel)
+ public void testPlatformDevel() {
+ assertTrue("Should not run in devel mode", GWT.isScript());
+ }
+
+ /**
+ * Test skipping a test for prod mode.
+ */
+ @DoNotRunWith(Platform.Prod)
+ public void testPlatformProd() {
+ assertTrue("Should not run in prod mode", !GWT.isScript());
}
/*
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors