Goktug Gokdogan has uploaded a new change for review.
https://gwt-review.googlesource.com/2590
Change subject: Removes dublicate method dispatchers generated by
GWTTestCase.
......................................................................
Removes dublicate method dispatchers generated by GWTTestCase.
This also adds test cases to verify GWTTestCase correctly handlers
inhertiance.
Change-Id: I52fe1d3ee60ec4c289e4055653125253c5639e76
---
M user/src/com/google/gwt/junit/rebind/GWTRunnerProxyGenerator.java
M user/test/com/google/gwt/junit/JUnitSuite.java
A user/test/com/google/gwt/junit/client/GWTTestCaseInheritanceTest.java
3 files changed, 73 insertions(+), 7 deletions(-)
diff --git
a/user/src/com/google/gwt/junit/rebind/GWTRunnerProxyGenerator.java
b/user/src/com/google/gwt/junit/rebind/GWTRunnerProxyGenerator.java
index dc174d4..1a6d6a0 100644
--- a/user/src/com/google/gwt/junit/rebind/GWTRunnerProxyGenerator.java
+++ b/user/src/com/google/gwt/junit/rebind/GWTRunnerProxyGenerator.java
@@ -246,13 +246,11 @@
return composerFactory.createSourceWriter(ctx, printWriter);
}
- private static List<JMethod> getTestMethods(JClassType requestedClass) {
+ private static List<JMethod> getTestMethods(JClassType cls) {
List<JMethod> list = new ArrayList<JMethod>();
- for (JClassType cls = requestedClass; cls != null; cls =
cls.getSuperclass()) {
- for (JMethod declMethod : cls.getMethods()) {
- if (isJUnitTestMethod(declMethod)) {
- list.add(declMethod);
- }
+ for (JMethod method : cls.getInheritableMethods()) {
+ if (isJUnitTestMethod(method)) {
+ list.add(method);
}
}
return list;
diff --git a/user/test/com/google/gwt/junit/JUnitSuite.java
b/user/test/com/google/gwt/junit/JUnitSuite.java
index 9d2a7b4..86c4098 100644
--- a/user/test/com/google/gwt/junit/JUnitSuite.java
+++ b/user/test/com/google/gwt/junit/JUnitSuite.java
@@ -17,6 +17,7 @@
import com.google.gwt.junit.client.DevModeOnCompiledScriptTest;
import com.google.gwt.junit.client.GWTTestCaseAsyncTest;
+import com.google.gwt.junit.client.GWTTestCaseInheritanceTest;
import com.google.gwt.junit.client.GWTTestCaseSetupTearDownTest;
import com.google.gwt.junit.client.GWTTestCaseStackTraceTest;
import com.google.gwt.junit.client.GWTTestCaseTest;
@@ -36,8 +37,9 @@
suite.addTestSuite(GWTTestCaseTest.class);
suite.addTestSuite(GWTTestCaseStackTraceTest.class);
suite.addTestSuite(GWTTestCaseUncaughtExceptionHandlerTest.class);
- suite.addTest(new TestSuiteWithOrder(GWTTestCaseAsyncTest.class));
suite.addTest(new
TestSuiteWithOrder(GWTTestCaseSetupTearDownTest.class));
+ suite.addTest(new
TestSuiteWithOrder(GWTTestCaseInheritanceTest.class));
+ suite.addTest(new TestSuiteWithOrder(GWTTestCaseAsyncTest.class));
suite.addTestSuite(DevModeOnCompiledScriptTest.class);
diff --git
a/user/test/com/google/gwt/junit/client/GWTTestCaseInheritanceTest.java
b/user/test/com/google/gwt/junit/client/GWTTestCaseInheritanceTest.java
new file mode 100644
index 0000000..7073305
--- /dev/null
+++ b/user/test/com/google/gwt/junit/client/GWTTestCaseInheritanceTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package com.google.gwt.junit.client;
+
+
+import static java.util.Arrays.asList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class tests inherited tests are properly executed.
+ *
+ * Note: This test requires some test methods to be executed in a specific
order.
+ */
+public class GWTTestCaseInheritanceTest extends InheritedTest {
+
+ private static List<String> executions = new ArrayList<String>();
+
+ @Override
+ protected void gwtTearDown() throws Exception {
+ executions.add(getName());
+ }
+
+ @Override
+ public void testOverridden() {
+ // Success!
+ }
+
+ @ExpectedFailure
+ public void testFail() {
+ fail("failed in purpose");
+ }
+
+ /**
+ * This is the last test to be executed (under_score forces that). Will
assert all test runs.
+ */
+ public void test_assertExecution() {
+ assertEquals(asList("testFail", "testOverridden", "testSuccess"),
executions);
+ }
+}
+
+// A test class to inherit
+class InheritedTest extends GWTTestCaseTestBase {
+
+ public void testSuccess() {
+ // Success!
+ }
+
+ public void testOverridden() {
+ fail("Should not have failed because of override");
+ }
+}
\ No newline at end of file
--
To view, visit https://gwt-review.googlesource.com/2590
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I52fe1d3ee60ec4c289e4055653125253c5639e76
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Goktug Gokdogan <gok...@google.com>
--
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "Google Web Toolkit Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.