Friday, December 2, 2016

Re: About running tests in a project built via tbroyer's maven multi-module archetype

Yes, you look like you're lost :-)
I'm afraid you can't develop in any given technology without learning the "basics" (between quotes, because it can mean a lot of things; learning curves are steep these days, and tending to become each year steeper than the preceding) : what is the classpath, a classloader, a JAR, a WAR, how to build a (simple) JAR (using the command-line, or some build tool), how to build a (simple) WAR. GWT adds a lot of things to those "basics", particularly when your build tool is as opinionated (and broken-by-design) as Maven.

I'm a bottom-up learner, first learning how things work (from documentation, not experimentation) before doing something with them, rather than a top-down learner, first doing things (possibly copy/pasting snippets here and there "until it works") then trying to understand how and why it all worked. That makes me a terrible teacher for top-down learners, who are better served with heavy full-stack frameworks and full scaffolding (ultimately leading to a huge amount of third-party code to do a simple hello world, if you ask me). Please note that I'm not judging "top-down learners", everybody is different and learns differently; I'm only acknowledging I'm generally unable to help them. I'm not sure what kind of learner you are, just letting you know that if you're a top-down one, then I'm probably not the right "teacher", and my gwt-maven-archetypes haven't been tailored for you (I am expecting average knowledge of Maven and GWT).

First of all, thank you for being responsive. As a learner I try to combine both approaches. I.e., when I recently required the funcionality of my snapshots being automatically stored in the hand-crafted remote maven repository and further have them as maven dependencies in other projects, I first tried to comprehend maven by learning pom reference, gwt-maven-plugin wiki and other resources, and then successfully applied the knowledge to introduce this feature. But of cause it gave me only the superficial understanding of the subject. And therefore I can understand some things erroneously.

With your help I can see now clearer how servlet path is being resolved for containers on different stages and it finally makes sense. But I still struggle to have the tests from single-module project created by webAppCreater running the same way in the multi-module one. To focus on this problem I once again started a new project named myartifact, and left all packages by default (everything is withing com.example.project). But there're still some unresolved dependencies on sandbox-shared.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.example.project.AppSuite
Starting Jetty on port 0
   
[WARN] ServletContainerInitializers: detected. Class hierarchy: empty
Compiling module com.example.project.AppJUnit.JUnit
   
Ignored 3 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   
Compiling 1 permutation
     
Compiling permutation 0...
   
Compile of permutations succeeded
   
Compilation succeeded -- 6,136s
Linking into E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\gwt-tests\www\com.example.project.AppJUnit.JUnit
   
Link succeeded
   
Linking succeeded -- 0,273s
Ignored 3 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Tracing compile failure path for type 'com.example.project.AppGwtTest'
   
[ERROR] Errors in 'file:/E:/Users/vitrums/workspace-neon/myartifact/myartifact-client/target/test-classes/com/example/project/AppGwtTest.java'
     
[ERROR] Line 24: No source code is available for type com.example.project.FieldVerifier; did you forget to inherit a required module?
     
[ERROR] Line 48: No source code is available for type com.example.project.GreetingResponse; did you forget to inherit a required module?
     
[ERROR] Line 38: No source code is available for type com.example.project.GreetingServiceAsync; did you forget to inherit a required module?
     
[ERROR] Line 38: No source code is available for type com.example.project.GreetingService; did you forget to inherit a required module?
[ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
Tracing compile failure path for type '
com.example.project.AppGwtTest'
   [ERROR] Errors in '
file:/E:/Users/vitrums/workspace-neon/myartifact/myartifact-client/target/test-classes/com/example/project/AppGwtTest.java'
      [ERROR] Line 24: No source code is available for type com.example.project.FieldVerifier; did you forget to inherit a required module?
      [ERROR] Line 48: No source code is available for type com.example.project.GreetingResponse; did you forget to inherit a required module?
      [ERROR] Line 38: No source code is available for type com.example.project.GreetingServiceAsync; did you forget to inherit a required module?
      [ERROR] Line 38: No source code is available for type com.example.project.GreetingService; did you forget to inherit a required module?
[ERROR] Hint: Your source appears not to live underneath a subpackage called '
client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 8.946 sec <<< FAILURE! - in com.example.project.AppSuite
testGreetingService
(com.example.project.AppGwtTest)  Time elapsed: 8.879 sec  <<< ERROR!
com
.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.example.project.AppGwtTest' had compile errors; check log for details
 at com
.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:732)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1325)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1281)
 at com
.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:670)
 at com
.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
 at junit
.framework.TestCase.runBare(TestCase.java:141)
 at junit
.framework.TestResult$1.protect(TestResult.java:122)
 at junit
.framework.TestResult.runProtected(TestResult.java:142)
 at junit
.framework.TestResult.run(TestResult.java:125)
 at junit
.framework.TestCase.run(TestCase.java:129)
 at com
.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at org
.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
 at org
.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
 at org
.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
 at org
.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)


testFieldVerifier
(com.example.project.AppGwtTest)  Time elapsed: 0.002 sec  <<< ERROR!
com
.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.example.project.AppGwtTest' had compile errors; check log for details
 at com
.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:732)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1325)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1281)
 at com
.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:670)
 at com
.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
 at junit
.framework.TestCase.runBare(TestCase.java:141)
 at junit
.framework.TestResult$1.protect(TestResult.java:122)
 at junit
.framework.TestResult.runProtected(TestResult.java:142)
 at junit
.framework.TestResult.run(TestResult.java:125)
 at junit
.framework.TestCase.run(TestCase.java:129)
 at com
.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at org
.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
 at org
.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
 at org
.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
 at org
.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)




Results :


Tests in error:
 
AppGwtTest>GWTTestCase.run:247->GWTTestCase.runTest:421 » JUnitFatalLaunch The...
 
AppGwtTest>GWTTestCase.run:247->GWTTestCase.runTest:421 » JUnitFatalLaunch The...


Tests run: 2, Failures: 0, Errors: 2, Skipped: 0


[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] myartifact ......................................... SUCCESS [  0.003 s]
[INFO] myartifact-shared .................................. SUCCESS [  0.490 s]
[INFO] myartifact-server-lib .............................. SUCCESS [  0.039 s]
[INFO] myartifact-client .................................. FAILURE [ 10.314 s]
[INFO] myartifact-server .................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.031 s
[INFO] Finished at: 2016-12-02T20:37:32+03:00
[INFO] Final Memory: 17M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:test (default-test) on project myartifact-client: There are test failures.
[ERROR]
[ERROR] Please refer to E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :myartifact-client


myartifact-client/pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
 
<modelVersion>4.0.0</modelVersion>


 
<parent>
   
<groupId>com.example.project</groupId>
   
<artifactId>myartifact</artifactId>
   
<version>0.0.1-SNAPSHOT</version>
 
</parent>


 
<artifactId>myartifact-client</artifactId>
 
<packaging>gwt-app</packaging>


 
<prerequisites>
   
<maven>${mavenVersion}</maven>
 
</prerequisites>


 
<dependencies>
   
<dependency>
     
<groupId>${project.groupId}</groupId>
     
<artifactId>myartifact-shared</artifactId>
     
<version>${project.version}</version>
   
</dependency>
   
<dependency>
     
<groupId>${project.groupId}</groupId>
     
<artifactId>myartifact-shared</artifactId>
     
<version>${project.version}</version>
     
<classifier>sources</classifier>
   
</dependency>
   
<dependency>
     
<groupId>${project.groupId}</groupId>
     
<artifactId>myartifact-server-lib</artifactId>
     
<version>${project.version}</version>
     
<scope>test</scope>
   
</dependency>
   
<dependency>
     
<groupId>com.google.gwt</groupId>
     
<artifactId>gwt-user</artifactId>
   
</dependency>
   
<dependency>
     
<groupId>com.google.gwt</groupId>
     
<artifactId>gwt-dev</artifactId>
   
</dependency>
 
</dependencies>


 
<build>
   
<plugins>
     
<plugin>
       
<groupId>net.ltgt.gwt.maven</groupId>
       
<artifactId>gwt-maven-plugin</artifactId>
       
<configuration>
         
<moduleName>com.example.project.App</moduleName>
         
<moduleShortName>app</moduleShortName>
       
</configuration>
     
</plugin>
     
     
<!-- Skip normal test execution, we use gwt:test instead -->
     
<plugin>
       
<artifactId>maven-surefire-plugin</artifactId>
       
<version>2.17</version>
       
<configuration>
         
<skip>true</skip>
       
</configuration>
     
</plugin>
   
</plugins>
 
</build>
</project>


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment