Apologies.  Doing a mvn package does work.  The tests run successfully.  
Doing a mvn test does not work (gives the "*No source code is available for 
type test.craig.FieldVerifier; did you forget to inherit a required 
module?"*" error).

On Saturday, 10 May 2025 at 4:51:35 pm UTC+10 Craig Mitchell wrote:

> Some extra (strange) behaviours:
>
> Creating a class in the client module:
> public class FieldVerifierOverride extends FieldVerifier { }
>
> And then calling the test with this class:
> assertTrue( FieldVerifierOverride.isValidName("hi") );
>
> Gives a different error:
> [ERROR] Could not find test.craig.FieldVerifier in types compiled from 
> source. Is the source glob too strict?
>
> Also, if I run mvn package (instead of mvn test), then the test actally 
> runs, but FieldVerifier.isValidName("hi") returns false (it should return 
> true):
>   [ERROR] test.craig.MyTests.testSimple -- Time elapsed: 8.016 s <<< 
> FAILURE!
>   junit.framework.AssertionFailedError: expected: <true>, actual: <false>
>
> On Saturday, 10 May 2025 at 12:01:52 pm UTC+10 Craig Mitchell wrote:
>
>> In the GWTTestCase client tests, if I want to test code that's in the 
>> shared module.  Eg:
>>
>> assertTrue( FieldVerifier.isValidName("hi") );
>>
>> I get the error:
>> [ERROR] Line 13: No source code is available for type 
>> test.craig.FieldVerifier; did you forget to inherit a required module?
>>
>> How can I inherit the shared module for the GWTTestCase tests?
>>
>> On Monday, 28 April 2025 at 9:26:13 am UTC+10 Craig Mitchell wrote:
>>
>>> Thanks Colin.  I wasn't aware of the "Suite" naming convention.
>>>
>>> So, to summarise.  Either:
>>> - Put "Suite" or "SuiteNoBrowser" at the end of the test class name, or
>>> - Add the test class directly as an include in the client pom.xml, in 
>>> the gwt-maven-plugin.
>>>
>>> Now working great!
>>>
>>> On Sunday, 27 April 2025 at 10:30:10 pm UTC+10 Colin Alworth wrote:
>>>
>>>> When using maven, running from the command line should be "mvn test". 
>>>> With the plugin you are using, it is assumed you are using a test suite - 
>>>> this is not required, but scales better. If you only need to run a single 
>>>> test, you can modify this includes.
>>>>
>>>> https://tbroyer.github.io/gwt-maven-plugin/test-mojo.html#includes
>>>>
>>>> For example in your project with MyTests (note: that wouldn't run even 
>>>> in a non-gwt project from maven, the default pattern is *Test), you could 
>>>> add this:
>>>>           <includes>
>>>>             <include>test/craig/MyTests.java</include>
>>>>           </includes>
>>>>
>>>> When I do that, having built the sample as you describe, the tests 
>>>> passes with mvn test:
>>>> [INFO] -------------------------------------------------------
>>>> [INFO]  T E S T S
>>>> [INFO] -------------------------------------------------------
>>>> [INFO] Running test.craig.MyTests
>>>> [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 
>>>> 13.96 s -- in test.craig.MyTests
>>>> [INFO] 
>>>> [INFO] Results:
>>>> [INFO] 
>>>> [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
>>>>
>>>> When running from IJ, it doesnt automatically add sources to the 
>>>> classpath as gwt:test does, so you may just want to call the maven goal 
>>>> directly instead. I recall that it is possible to configure Maven/IJ to 
>>>> run 
>>>> tests "normally", but can't quickly spot what that would be.
>>>>
>>>> On Sunday, April 27, 2025 at 12:18:17 AM UTC-5 ma...@craig-mitchell.com 
>>>> wrote:
>>>>
>>>>> When running from the command line, I forgot to add all the items to 
>>>>> the class path.  Once I did that, I got the same error IntelliJ did:
>>>>>
>>>>> There was 1 error:
>>>>> 1) 
>>>>> testSimple(test.craig.MyTests)com.google.gwt.junit.JUnitFatalLaunchException:
>>>>>  
>>>>> The test class 'test.craig.MyTests' was not found in module '
>>>>> test.craig.App'; no compilation unit for that type was seen
>>>>>         at 
>>>>> com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:741)
>>>>>         at 
>>>>> com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1360)
>>>>>         at 
>>>>> com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1316)
>>>>>         at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:679)
>>>>>         at 
>>>>> com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
>>>>>         at 
>>>>> com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
>>>>>
>>>>> FAILURES!!!
>>>>> Tests run: 1,  Failures: 0,  Errors: 1
>>>>>
>>>>> On Sunday, 27 April 2025 at 2:54:36 pm UTC+10 Craig Mitchell wrote:
>>>>>
>>>>>> I created a demo project with 
>>>>>> https://github.com/NaluKit/gwt-maven-springboot-archetype with the 
>>>>>> params:
>>>>>> - modular-springboot-webapp
>>>>>> - groupId: test.craig
>>>>>> - artifactId: testing
>>>>>> - module-short-name app: tc
>>>>>>
>>>>>> Added JUnit to the client pom:
>>>>>> <dependency>
>>>>>>   <groupId>junit</groupId>
>>>>>>   <artifactId>junit</artifactId>
>>>>>>   <version>4.13.2</version>
>>>>>>   <scope>test</scope>
>>>>>> </dependency>
>>>>>>
>>>>>> Created a simple test in the client module (in 
>>>>>> src/test/java/test/craig/MyTests.java):
>>>>>> public class MyTests extends GWTTestCase {
>>>>>>   @Override
>>>>>>   public String getModuleName() {
>>>>>>     return "test.craig.App";
>>>>>>   }
>>>>>>   public void testSimple() {
>>>>>>     assertTrue( true );
>>>>>>   }
>>>>>> }
>>>>>>
>>>>>> Tried to run it in IntelliJ, but got the error:
>>>>>> com.google.gwt.junit.JUnitFatalLaunchException: The test class 
>>>>>> 'test.craig.MyTests' was not found in module 'test.craig.App'; no 
>>>>>> compilation unit for that type was seen
>>>>>>
>>>>>> Tried to compile and run it from the command line:
>>>>>> java junit.textui.TestRunner test.craig.MyTests
>>>>>>
>>>>>> But that returned:
>>>>>> Error: Could not find or load main class junit.textui.TestRunner
>>>>>> Caused by: java.lang.ClassNotFoundException: junit.textui.TestRunner
>>>>>>
>>>>>> I thought I was following the instructions in 
>>>>>> https://www.gwtproject.org/doc/latest/DevGuideTesting.html but 
>>>>>> obviously doing something wrong.
>>>>>>
>>>>>> Any help is much appreciated.
>>>>>>
>>>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/google-web-toolkit/c4352589-3dd8-420c-aa32-acc88505973fn%40googlegroups.com.

Reply via email to