--- /dev/null
+
+
+This module is thought to run tests in development mode in
+order to speed up TDD.
+
+- Put your tests in the DevTestRunner class.
+- Call gwtSetup() and your test in the entryPoint.
+- If you need any assertion method provided by the junit
+ library put it in the class MyTestCase.
+ There are already a bunch of them.
+- Run the module in development mode: mvn gwt:run
+ or lauch it from eclipse
+- See the output of the tests. If there is a failure
+ a stacktrace should be shown in the output.
+- Modify your test code and reload the application in your browser.
+- When your test was ready put it in your test class extending
+ GWTTestCase.
+
+
+
+
+
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwtquery-project</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>devtest</artifactId>
+ <packaging>jar</packaging>
+ <name>dev-mode for testing</name>
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>gwtquery</artifactId>
+ <version>${version}</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>gwtquery-plugins</artifactId>
+ <version>${version}</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <outputDirectory>./target/www/WEB-INF/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/java</directory>
+ </resource>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>${basedir}/src/test/java</directory>
+ </testResource>
+ <testResource>
+ <directory>${basedir}/src/test/resources</directory>
+ </testResource>
+ </testResources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>gwt-maven-plugin</artifactId>
+ <configuration>
+ <style>PRETTY</style>
+ <gwtVersion>${gwtversion}</gwtVersion>
+ <modules>
+ <module>com.google.gwt.query.DevTestRunner</module>
+ </modules>
+ <runTarget>test/test.html</runTarget>
+ <hostedWebapp>target/www</hostedWebapp>
+ <soyc>true</soyc>
+ </configuration>
+<!--
+ <executions>
+ <execution>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+-->
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<module rename-to="test">
+ <inherits name='com.google.gwt.query.Query'/>
+ <entry-point class='com.google.gwt.query.client.DevTestRunner'/>
+</module>
+
--- /dev/null
+/*\r
+ * Copyright 2009 Google Inc.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy of\r
+ * the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+package com.google.gwt.query.client;\r
+\r
+import static com.google.gwt.query.client.GQuery.$;\r
+\r
+import com.google.gwt.core.client.EntryPoint;\r
+\r
+/**\r
+ * This module is thought to emulate a test environment similar to\r
+ * GWTTestCase, but running it in development mode.\r
+ * \r
+ * The main goal of it is to execute tests in a faster way, because you only need\r
+ * to push reload in your browser.\r
+ * \r
+ * @author manolo\r
+ * \r
+ */\r
+public class DevTestRunner extends MyTestCase implements EntryPoint {\r
+\r
+ public void onModuleLoad() {\r
+ gwtSetUp();\r
+ testDomManip();\r
+ }\r
+\r
+ public void testDomManip() {\r
+ String content = "<span class='branchA'><span class='target'>branchA target</span></span>"\r
+ + "<span class='branchB'><span class='target'>branchB target</span></span>";\r
+ \r
+ $(e).html("");\r
+ $(e).append(content);\r
+ assertEquals(4, $("span", e).size());\r
+ assertEquals(2, $("span.target", e).size());\r
+ assertHtmlEquals(content, $(e).html());\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2009 Google Inc.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy of\r
+ * the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+package com.google.gwt.query.client;\r
+\r
+import com.google.gwt.dom.client.Element;\r
+import com.google.gwt.user.client.ui.HTML;\r
+import com.google.gwt.user.client.ui.RootPanel;\r
+\r
+/**\r
+ * Just a simple class to emulate JUnit TestCase\r
+ */\r
+public class MyTestCase {\r
+\r
+ static Element e = null;\r
+ static HTML testPanel = null;\r
+\r
+ public void gwtSetUp() {\r
+ if (e == null) {\r
+ testPanel = new HTML();\r
+ RootPanel.get().add(testPanel);\r
+ e = testPanel.getElement();\r
+ e.setId("core-tst");\r
+ } else {\r
+ e.setInnerHTML("");\r
+ }\r
+ }\r
+ \r
+ public static void assertNotNull(Object a) {\r
+ check(a != null, "assertNotNull: actual object is null");\r
+ }\r
+\r
+ public static void assertEquals(Object a, Object b) {\r
+ check(a.equals(b), "assertEquals: expected=" + a + " actual=" + b);\r
+ }\r
+ \r
+ public static void check(boolean condition, String message) {\r
+ if (!condition) {\r
+ RuntimeException e = new RuntimeException(message);\r
+ e.printStackTrace();\r
+ throw e;\r
+ }\r
+ }\r
+ \r
+ protected static void assertHtmlEquals(Object expected, Object actual) {\r
+ assertEquals(iExplorerFixHtml(expected), iExplorerFixHtml(actual));\r
+ }\r
+\r
+ protected static String iExplorerFixHtml(Object s) {\r
+ return s.toString().trim().toLowerCase().\r
+ replaceAll("[\r\n]", "").\r
+ replaceAll(" ([\\w]+)=[\"']([^\"']+)[\"']", " $1=$2").\r
+ replaceAll("\\s+\\$h=\"[^\"]+\"", "").\r
+ replaceAll(" added=[^ >]+", "");\r
+ }\r
+ \r
+}\r
--- /dev/null
+<html>\r
+ <head>\r
+ <script language="javascript" src="test.nocache.js"></script>\r
+ </head>\r
+ <body>\r
+ </body>\r
+</html>\r
+
\ No newline at end of file
<module>gwtquery-core</module>
<module>plugins</module>
<module>samples</module>
+ <module>devtest</module>
</modules>
<distributionManagement>