Re: [TFUI] newbie wants to understand TFUI with jemmy
Phlip <phlipcpp-/[email protected]>
| Newsgroups | gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Message-ID | <[email protected]> |
maraflux wrote:
> So I am trying my first "hands on" experience with
> TFUI using jemmy and the (extended)
> example from Astels's "TDD: A Practical Guide,"
> chapter 10. So what I have now, as far as I
> can see is a GUI that gets built by jemmy! My GUI
> doesn't exist in that I don't have an app
> to run with it's own GUI. Yet I have tests that
> build and test a GUI. Seems quite strange to
> me.
Can you submit some sample code?
When I use TDD to create a small sample, I seems to be
an app I can use outside the test rig. If anyone wants
an app with a single button.
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;
import org.netbeans.jemmy.*;
import org.netbeans.jemmy.operators.*;
import org.netbeans.jemmy.operators.JButtonOperator;
public class JemmyScenario implements Scenario {
public static final class SampleApp extends
JFrame{
public JButton m_button;
public static void main(String[] argv) {
new SampleApp().show();
}
private SampleApp() {
super("Sample App");
m_button = new JButton();
JPanel rootPanel = (JPanel)
getContentPane();
rootPanel.setLayout(new BorderLayout());
rootPanel.add(m_button,
BorderLayout.CENTER);
}
}
public int runIt(Object param) {
try {
//start application
SampleApp app = new SampleApp();
new ClassReference(app).startApplication();
//wait frame
JFrameOperator mainFrame = new
JFrameOperator("Sample App");
app.m_button.action(null, null);
JButtonOperator opp = new
JButtonOperator(mainFrame, 0);
opp.clickMouse();
} catch(Exception e) {
e.printStackTrace();
return(1);
}
return(0);
}
public static void main(String[] argv) {
String[] params = {"JemmyScenario"};
org.netbeans.jemmy.Test.main(params);
}
}
Someone farther up the Swing learning curve might be
able to add an assertion that proves the button got
clicked.
However, because targets of Jemmy must be in-JVM with
it, what does Jemmy provide that making our button
public and calling its action() method itself not
provide?
> I have yet to work through the other chapters, but I
> am guessing that I will slowly build the
> same GUI for the app that I use jemmy to
> build/teardown. This seems like duplication. It
> seems like a lot of extra work and the GUI tests
> will only be valid if I build the app's GUI in
> the same way that I instruct jemmy to build it in
> the tests. I know there is the interface and
> the MVC separation by passing the Editor/Controller
> the "view" and the "model" objects.
> But somehow, this feels contrived as far as testing
> the GUI... I mean the app technically
> has no GUI yet... do I really need to build/teardown
> a GUI to test the interface... isn't there
> a way to build the app's actual GUI and test it !!!
My GUI is a private static class because I'm too lazy
to put it into another module. But if I weren't, we
could just use that GUI. I don't understand what you
have done with Jemmy to create a GUI that only Jemmy
can construct.
Recall the goal of TDD is adding tests, then adding
code, and I think I could do that here with or without
Jemmy. But the goal of Agility is to continuously grow
all features - including the model and controller of
your peri-GUI modules. So don't do whatever you did to
Jemmy for too long before ensuring that your
intermediate result can plug into the other two components.
=====
Phlip
http://www.xpsd.org/cgi-bin/wiki?TestFirstUserInterfaces
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
http://photos.yahoo.com/ph/print_splash
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/nhFolB/TM
---------------------------------------------------------------------~->
To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/TestFirstUserInterfaces/
<*> To unsubscribe from this group, send an email to:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/