2014-05-12 4 views
0

J'ai créé un exemple de projet pour exécuter mes tests gwt avec gwt-test-utils (https://github.com/povilasb/gwt-test-utils-sample). J'utilise Ant (1.8.2) pour les builds, les paquets: gwt 2.6, juni 4.11 et gwt-test-utils 0.47.gwt-test-utils ne parvient pas à exécuter des tests avec Ant

Malheureusement, je ne parviennent pas à exécuter des tests:

html-test-utils-config: 

test: 


    [junit] Testsuite: com.example.gwtTestUtils.client.PersonTest 
     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.006 sec 
     [junit] 
     [junit] ------------- Standard Error ----------------- 
     [junit] SLF4J: Failed to load class org.slf4j.impl.StaticLoggerBinder. 
     [junit] SLF4J: Defaulting to no-operation (NOP) logger implementation 
     [junit] ------------- ---------------- --------------- 
     [junit] Testcase: initializationError(com.example.gwtTestUtils.client.PersonTest): Caused an ERROR 
     [junit] Error while scanning package 'com.googlecode.gwt.test.internal.patchers' 
     [junit] com.googlecode.gwt.test.exceptions.GwtTestPatchException: Error while scanning package 'com.googlecode.gwt.test.internal.patchers' 
     [junit]  at com.googlecode.gwt.test.internal.ClassesScanner.scanPackages(ClassesScanner.java:68) 
     [junit]  at com.googlecode.gwt.test.internal.ConfigurationLoader.visitPatchClasses(ConfigurationLoader.java:291) 
     [junit]  at com.googlecode.gwt.test.internal.ConfigurationLoader.<init>(ConfigurationLoader.java:65) 
     [junit]  at com.googlecode.gwt.test.internal.GwtFactory.<init>(GwtFactory.java:91) 
     [junit]  at com.googlecode.gwt.test.internal.GwtFactory.initializeIfNeeded(GwtFactory.java:46) 
     [junit]  at com.googlecode.gwt.test.internal.junit.AbstractGwtRunner.<init>(AbstractGwtRunner.java:30) 
     [junit]  at com.googlecode.gwt.test.GwtRunner.<init>(GwtRunner.java:19) 
     [junit]  at java.lang.reflect.Constructor.newInstance(Constructor.java:532) 
     [junit]  at java.lang.reflect.Constructor.newInstance(Constructor.java:532) 
     [junit] Caused by: com.googlecode.gwt.test.exceptions.GwtTestPatchException: Cannot find class in the classpath : 'com.googlecode.gwt.test.internal.patchers.AbstractHasDataPatcher' 
     [junit]  at com.googlecode.gwt.test.internal.GwtClassPool.getClass(GwtClassPool.java:27) 
     [junit]  at com.googlecode.gwt.test.internal.ClassesScanner.visitClass(ClassesScanner.java:107) 
     [junit]  at com.googlecode.gwt.test.internal.ClassesScanner.scanClassesFromJarFile(ClassesScanner.java:99) 
     [junit]  at com.googlecode.gwt.test.internal.ClassesScanner.scanPackages(ClassesScanner.java:62) 
     [junit] 
     [junit] 
     [junit] Test com.example.gwtTestUtils.client.PersonTest FAILED 

BUILD SUCCESSFUL   
Total time: 1 second 

Il semble que quelqu'un avait déjà cette question avant: https://code.google.com/p/gwt-test-utils/issues/detail?id=168. Impossible de trouver la solution là-bas.

Quelqu'un at-il eu de la chance avec gwt 2.6 et gwt-test-utils 4.7 et ant?

Répondre

1

J'ai réussi à résoudre mon problème. J'éliminé l'erreur

Error while scanning package 'com.googlecode.gwt.test.internal.patchers'

En utilisant le mode fourche Antjunit tâche:

<junit haltonfailure="false" includeantruntime="false" 
    fork="yes" forkmode="once" > 

C'est le recommended method pour exécuter junit essais:

In general, forking a new VM is recommended since it isolates your test from Ant's environment (which contains a lot of libraries on the classloader, in particular XML related classes) but it becomes really slow because of the big overhead associated with starting new Java VMs.

Après cela, j'eu une autre erreur:

test: 
    [junit] WARNING: multiple versions of ant detected in path for junit 
    [junit]   jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/Project.class 
    [junit]  and jar:file:/home/povilas/projects/gwt-test-utils-sample/lib/ant-1.8.2.jar!/org/apache/tools/ant/Project.class 
    [junit] Testsuite: com.example.gwtTestUtils.client.PersonTest 
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.005 sec 
    [junit] 
    [junit] ------------- Standard Error ----------------- 
    [junit] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
    [junit] SLF4J: Defaulting to no-operation (NOP) logger implementation 
    [junit] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
    [junit] ------------- ---------------- --------------- 
    [junit] Testcase: initializationError(com.example.gwtTestUtils.client.PersonTest): Caused an ERROR 
    [junit] Error while generating gwt-test-utils prerequisites 
    [junit] com.googlecode.gwt.test.exceptions.GwtTestException: Error while generating gwt-test-utils prerequisites 
    [junit]  at com.googlecode.gwt.test.internal.GwtFactory.<init>(GwtFactory.java:119) 
    [junit]  at com.googlecode.gwt.test.internal.GwtFactory.initializeIfNeeded(GwtFactory.java:46) 
    [junit]  at com.googlecode.gwt.test.internal.junit.AbstractGwtRunner.<init>(AbstractGwtRunner.java:30) 
    [junit]  at com.googlecode.gwt.test.GwtRunner.<init>(GwtRunner.java:19) 
    [junit]  at java.lang.reflect.Constructor.newInstance(Constructor.java:532) 
    [junit]  at java.lang.reflect.Constructor.newInstance(Constructor.java:532) 
    [junit] Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries) 
    [junit]  at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:315) 
    [junit]  at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:100) 
    [junit]  at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:197) 
    [junit]  at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:176) 
    [junit]  at com.google.gwt.dev.cfg.ModuleDefLoader.createSyntheticModule(ModuleDefLoader.java:105) 
    [junit]  at com.googlecode.gwt.test.internal.GwtFactory.createModuleDef(GwtFactory.java:164) 
    [junit]  at com.googlecode.gwt.test.internal.GwtFactory.<init>(GwtFactory.java:110) 
    [junit] 
    [junit] 
    [junit] Test com.example.gwtTestUtils.client.PersonTest FAILED 

BUILD SUCCESSFUL 
Total time: 1 second 

Et je résolu cette erreur en ajoutant répertoire de code source pour junit classpath:

<property name="src.dir" value="src" /> 
... 
<junit haltonfailure="false" includeantruntime="false" 
    fork="yes" forkmode="once" > 
    ... 
    <classpath> 
     <path refid="project.class.path" /> 
     <pathelement location="${test.build.dir}" /> 
     <pathelement location="${src.dir}" /> 
    </classpath> 

    ... 
</junit> 

je suppose que GWT-test-utils nécessaires sources du module GWT. Vous pouvez trouver un exemple de projet entièrement fonctionnel sur github.

Questions connexes