Wizard for GWTTestCase test? [wish]

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Wizard for GWTTestCase test? [wish]

Postby peterblazejewicz » Mon Jan 14, 2008 2:30 pm

hi Eric & team,

I'm really enjoying GWT unit tests run wizard,
What do you think about either integrating GWT designer with toolkit jUnitCreator tool or providing new JUnitTest creator wizard which do the same thing as jUnitCreator (test case stub file creation and class-path setup)?
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JUnitIntegration.html
(more here in non-yet released docs: http://code.google.com/p/bunsenandbeaker/wiki/DevGuideJUnitCreation)
Currently in GWT Designer I quickly setup GWTTestCases that way (following GWT Toolkit contributor test cases guideline):
- add "test" source folder in project (optionally setup required package structer by hand, e.g. com.google.gwt.user.client.ui)
- use JUnit wizard to create test class based on existing class in "src" package (e.g. com.google.gwt.user.client.ui.RootPanelTest)
- change inheritance to GWTTestCase
- fix errors
- move created class to correct package (e.g. com.google.gwt.user.client.ui);
- fill required getModuleName() by hand (could rise error)

that's hard part, fun part is to run GWT Designer run test wizard after all that,

regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: Wizard for GWTTestCase test? [wish]

Postby Eric Clayberg » Wed Jan 16, 2008 2:59 pm

Would you want the test case in the same project or a separate project?

It is generally better to keep tests in a separate project since they need the junit.jar available.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Wizard for GWTTestCase test? [wish]

Postby peterblazejewicz » Wed Jan 16, 2008 6:15 pm

hi Eric,

I would go with "test" source folder created within project configuration (I think that is how gwt jUnitCreator behaves when creating eclipse project configuration for JUnit tests and e.g. how ohter IDEs create new projects (src/test by default),

To let you better see how things can be improved here is a quick list of what should be done (step-by-step) to create new project for sample widget library (I'll use Yahoo YUI as sample) say imaginary YUIButton project:

#1
start GWT project wizard and choose project name:
step01.jpg
step01.jpg (60 KiB) Viewed 1276 times

#2
click "Next" and configure GWT Designer related settings for .gwt.xml module:
step02.jpg
step02
step02.jpg (51.32 KiB) Viewed 1276 times

#3 & #4
click "Next" and add "test" source path:
step04.jpg
step04.jpg (67.22 KiB) Viewed 1272 times


TBC
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: Wizard for GWTTestCase test? [wish]

Postby peterblazejewicz » Wed Jan 16, 2008 6:20 pm

continued:

#6
add JUnit library during project configuration:
step06.jpg
step06.jpg (43.4 KiB) Viewed 1264 times


#7
click finish, fix any possible issues.
Create new Widget subclass, e.g. yui.yahoo.widget.Button (as Yahoo.widget.Button):

step07.jpg
step07.jpg (55.92 KiB) Viewed 1263 times


write quick implementation:

Code: Select all
package yui.yahoo.widget;

import yui.yahoo.Dom;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;

public class Button extends Widget {
   public Button() {
      setElement(DOM.createSpan());
      // insert random YAHOO.util.DOM.generateId()
      Dom.generateId(getElement());
   }
}


#8
right click on created class and choose "New>JUnit test case", configure it (change source to "test", use GWTTestCase as superclass):

step08.jpg
step08.jpg (60.76 KiB) Viewed 1261 times


TBC
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: Wizard for GWTTestCase test? [wish]

Postby peterblazejewicz » Wed Jan 16, 2008 6:25 pm

CONITUNED

#9
select what tests are to be created (here only constructor is already implemented):

step09.jpg
step09.jpg (36.21 KiB) Viewed 1257 times


finish and fix GWTTestCase missing getModuleName() by hand and write impmlementation:

Code: Select all
package yui.yahoo.widget;

import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.ui.RootPanel;

public class ButtonTest extends GWTTestCase {

   public final void testButton() {
      Button button = new Button();
      assertNotNull(button);
      RootPanel.get().add(button);
      assertEquals(1, RootPanel.get().getWidgetCount());
   }

   /* @Override */
   public String getModuleName() {
      return "yui.yahoo.YUIButton";
   }

}

save class

#10
right-click on ButtonTest class and choose new GWT Unit test wizard run configuration:

step10.jpg
step10.jpg (30.14 KiB) Viewed 1261 times


#11
JUnit tests are launched (everything should be configured by run configuration plugin) in hidden hosted mode:

step11.jpg
step11.jpg (20.88 KiB) Viewed 1260 times



TBC
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: Wizard for GWTTestCase test? [wish]

Postby peterblazejewicz » Wed Jan 16, 2008 6:30 pm

CONTINUED

#12

open and configure (if required) generated ButtonTest run configuration:

step12.jpg
step12.jpg (86.95 KiB) Viewed 1254 times



@Eric
I've posted that for you so you can review that steps and eventually make some changes.
Personally I'm fine with that however I"m missing that feature from jUnitCreator command which creates "test" source folder by default and use GWTTestCase class:
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.html#junitCreator

Because GWT Designer Plugin already knows module name it would be nice if somehow getModuleName could be generated with correct value (just similiar to like you done that for RPC remote services)

Also if you like you could use image I posted to write quick HowTo for other users on how to quickly create and run new project from scratch,

regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: Wizard for GWTTestCase test? [wish]

Postby Eric Clayberg » Mon Jan 21, 2008 5:51 am

Thanks for the detail.

We have added this to our list of features to implement.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Wizard for GWTTestCase test? [wish]

Postby Eric Clayberg » Tue Jan 22, 2008 11:37 am

Give the new GWT > JUnit Test Case wizard a try...

Image Image

Note that there is a new preference available to set the default source folder to use for test cases...

Image
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Wizard for GWTTestCase test? [wish]

Postby peterblazejewicz » Wed Jan 23, 2008 6:09 pm

Hello,
thx Eric, that's working,

regards
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: Wizard for GWTTestCase test? [wish]

Postby Eric Clayberg » Thu Jan 24, 2008 4:07 am

Very good.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 3 guests