I'm trying a very JUnit Testing for GWT put it is failing
public class CheckTest extends TestCase
{
private ServiceAsync RPC;
private HandlerManager EventBus;
private CreateTopicPresenter.Display CTV;
private CreateTopicPresenter CTP;
protected void setUp()
{
RPC= createStrictMock(ServiceAsync.class);
EventBus = new HandlerManager(null);
CTV= createStrictMock(CreateTopicView.class);
CTP= new CreateTopicPresenter(CTV,RPC,EventBus);
}
public void testCheck()
{
CTP.View.getFirstMessage().setValue("MessageTest");
assertTrue(CTP.View.getFirstMessage().getValue().equals("MessageTest"));
}
Stack Trace:
java.lang.ExceptionInInitializerError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:619)
at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:612)
at net.sf.cglib.proxy.Enhancer.registerCallbacks(Enhancer.java:581)
at org.easymock.internal.ClassProxyFactory.createProxy(ClassProxyFactory.java:194)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:60)
at org.easymock.EasyMock.createStrictMock(EasyMock.java:70)
at com.BiddingSystem.client.CheckTest.setUp(CheckTest.java:26)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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)
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:91)
at com.google.gwt.user.client.ui.UIObject.<clinit>(UIObject.java:188)
... 24 more
You need to extend the GWTTestCase base type in order to test code that depends on the GWT runtime (e.g. calls to GWT.create() or JSNI methods). Note that the GWTTestCase must be GWT-compatible as well, so this will limit your choice of testing libraries.
Ideally, most of your app code is testable with "pure" TestCases, with only client-specific code being tested by GWTTestCases, since the latter have a higher overhead.
http://www.gwtproject.org/articles/testing_methodologies_using_gwt.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With