Mam aplikacji GWT zbudowany w Maven, teraz próbowałem uruchomić prosty test GWT jak poniżej:Jak używać testów maven i jUnit?
public class GwtTestLaughter extends GWTTestCase {
/**
* Specifies a module to use when running this test case. The returned
* module must include the source for this class.
*
* @see com.google.gwt.junit.client.GWTTestCase#getModuleName()
*/
@Override
public String getModuleName() {
return "com.sample.services.joker.laughter.Laughter";
}
/**
* Add as many tests as you like
*/
public void testSimple() {
assertTrue(true);
}
}
iw pliku pom.xml, skonfigurowany GWT-maven-plugin i Maven-surefire- wtyczka jak poniżej:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.1.0-1</version>
<configuration>
<!-- Use the 'war' directory for GWT hosted mode -->
<output>${basedir}/war</output>
<webXml>${basedir}/war/WEB-INF/web.xml</webXml>
<runTarget>index.html</runTarget>
<!-- Make sure the GWT compiler uses Xerces -->
<extraJvmArgs>
-Dgwt.style=DETAILED -Xmx512M -Xss1024k -XX:MaxPermSize=128m -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dlogback.configurationFile=./src/test/resources/logback-test.xml
</extraJvmArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useFile>false</useFile>
<forkMode>once</forkMode>
<argLine>-Xmx128m</argLine>
<systemPropertyVariable>
<property>
<name>log4j.configuration</name>
<value>log4j.properties</value>
</property>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>unit-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/*Test.java</include>
<includes>
<excludes>
<exclude>**/GwtTest*.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>true</skip>
<includes>
<include>**/GwtTest*.java</include>
<includes>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</execution>
<executions>
</plugin>
Kiedy wpadłem 'test mvn' w linii poleceń, widzę tylko normalne testy JUnit prowadził (jeden z nazwa pliku test.java), gdy uruchomiłem "test integracji mvn", nadal widzę wszystkie testy, w tym normalny test Junit i test Gwt (te z GwtTest. Nazwa pliku .java).
Pytanie 1:
Jak mogę całkowicie wykluczają prowadzenie normalnego testu Junit czasie do badania integracji? czy to niemożliwe? Ponieważ w domyślnym cyklu życia mafii, faza testowa jest zdefiniowana przed testem integracyjnym, nie ma sposobu na pominięcie fazy testowej w celu przeprowadzenia czystego testu integracji?
Odkąd mieszały cały kod testy pod/src/test folderu/Jawa, kiedy wpadłem „mvn integracji test” i obserwowane dane wyjściowe w oknie wiersza poleceń, widziałem, co następuje:
[INFO] running com.sample.services.joker.laughter.client.GwtTestLaughter
..
[INFO] Validating newly compiled units
[INFO] [ERROR] Errors in 'file:...src/test/java/com/sample/joker/laughter/client/file1Test.java'..
[INFO] [ERROR] Line 42: No source code is available for type...; did you forget to inherit a required module?
...
Pytanie 2:
Nie rozumiem tego, test gwt jest bardzo prosty, dlaczego sprawdziłby niepowiązany * Test.java i szukał jego kodu źródłowego. chociaż ostatecznie udało się pomyślnie przejść test, jak mogę się pozbyć tego nieprzyjemnego komunikatu o błędzie?
Może powinienem zapomnieć o gwt-mavin-plugin i trzymać się klasycznych testów Juint?