Unit teting using GWTTestCase

76 views
Skip to first unread message

Vish

unread,
Nov 1, 2011, 12:22:57 AM11/1/11
to Google Web Toolkit
I am getting following error when I tried to test using GWTTestCases.

com.google.gwt.junit.JUnitFatalLaunchException: The test class
'com.abc.myapp.client.MyAppTestCase' was not found in module
'com.abc.myapp.Myapp'; no compilation unit for that type was seen
at
com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:
743)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1346)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:
441)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:
91)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
49)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
197)

Here is the test class source code.

package com.abc.myapp.client;

import org.junit.Assert;
import com.google.gwt.junit.client.GWTTestCase;

public class MyAppTestCase extends GWTTestCase {
@Override
public String getModuleName() {
return "com.abc.myapp.Myapp";
}

public void testX(){
Assert.assertTrue(true);
}
}

In eclispe I am using following set up, it is as per maven standard.
src/main/java for which output folder is target/classes
src/main/resources for which output folder is target/classes
src/main/webapp
src/test/java for which output folder is target/test-
classes
src/test/resources for which output folder is target/test-
classes

Let me know if I am missing anything else.

FYI!, I am using GWT 2.3.

Thanks,

Vish

Thomas Broyer

unread,
Nov 1, 2011, 6:29:06 AM11/1/11
to google-we...@googlegroups.com
Is src/test/java (and src/test/resources) part of the buildpath/classpath for your JUnit launch? Not only the *.class has to be in the classpath, the *.java too.

Vish

unread,
Nov 1, 2011, 9:05:51 AM11/1/11
to Google Web Toolkit
I think it is already in place. refer here.

<classpathentry kind="src" output="target/test-classes" path="src/test/
resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/
java"/>
<classpathentry kind="src" output="target/classes" path="src/main/
resources"/>
<classpathentry kind="src" output="target/classes" path="src/main/
java"/>

Does eclispe need GWT plug-in to run this?

Thomas Broyer

unread,
Nov 1, 2011, 10:50:42 AM11/1/11
to google-we...@googlegroups.com
Are you launching your unit test using Run As… → GWT JUnit Test ? Otherwise, Eclipse does not automatically add source folders to classpath of your launchers (aka "Run/Debug configurations").
Reply all
Reply to author
Forward
0 new messages