Dipak
Dipak

Reputation: 6960

GWT compositC component test cases?

i had a GWT composite component, with two textBox, want to write test cases for it. Each of them had change handler, i want to know how can i fire a change event to exact component in the composite component class.

EDITED: my test code looks like this,

    @Test
    public void testValueChangesToOutOfRange(){
        DvCountUI count = new DvCountUI(15, "place holder", true);
        count.specifyNormalRange(10, 30);
        TextBox magnitude =  GwtReflectionUtils.getPrivateFieldValue(count, "magnitude");
        assertTrue(true);

    }

and when i run it with GWT Junit Test am getting ERROR: in console

Validating units:
   Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[ERROR] Errors in 'file:/D:/TRANSFER/asclepian/workspace/UIBuilder/src/com/rubirules/uibuilder/client/DvCountUITest.java'
   [ERROR] Line 65: No source code is available for type com.googlecode.gwt.test.utils.GwtReflectionUtils; did you forget to inherit a required module?
[ERROR] Unable to find type 'com.rubirules.uibuilder.client.DvCountUITest'
   [ERROR] Hint: Previous compiler errors may have made this type unavailable
   [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly

and in junit

JUnitFatalLaunchException

my gwt.xml file looks like:

<module rename-to='uibuilder'>
    <inherits name='com.google.gwt.user.User' />
    <inherits name='com.google.gwt.user.theme.clean.Clean' />
    <entry-point class='com.rubirules.uibuilder.client.UIBuilder' />
    <source path='client' />
    <source path='shared' />
</module>

whats wrong here? also i added gwt-test-utils jar in project library.

Upvotes: 0

Views: 321

Answers (2)

Dipak
Dipak

Reputation: 6960

I got solved things by : extending GwtTest instead of GWTTestCases and adding a gwt-test-util.property file with a value "com.rubirules.uibuilder.UIBuilder = gwt-module", in the META-INF folder which is inside test package.

Upvotes: 0

appbootup
appbootup

Reputation: 9537

I am not sure whether your approach towards unit testing widget is correct.

In this scenario you should ideally be setting value (triggering the internal change event) and testing whether the code written in the change handler get executed.

Example - TextBoxBaseTestBase.java
public void testValueChangeEvent() {} in http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/user/client/ui/TextBoxBaseTestBase.java

If you insist on firing change event you can refer to GWT sample CreateEventTest.java

public void testTriggerChangeEvent() {} in http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/user/client/ui/CreateEventTest.java

Upvotes: 1

Related Questions