There you go! ANT will take care of that problem. I remember running into
that problem the first time I was trying to
get our application to run using ANT.
Tell me more about this recorder. Is it
another java.awt thing? Or, do you just record the events like you described in
the link below? Are you capturing all events or just a subset? How do you
specify? Can you edit those events to add or remove
recorder identifies the components uniquely by text,
parent text, sibling text, etc. During
playback, it searches
component tree for the correct
component and gets its coordinates.
can run the tests from ANT, and it starts each test in
own JVM. I suppose you wouldn't have to restart for
test, but it certainly keeps them independent.
saw your post on how to record the AWTEvents by registering with the
DefaultToolkit. How do you record using Robot? I guess a larger concern is
how to you get coordinates? What if your UI components move around some? Do
you have to go through all of your tests and tweak coordinates? I guess that
isn't a big deal anyway. You want to run all of your tests anyway, and you
have to figure out if each failed test fails because of the test (bad
coordinates or something like that) or because of the app.
Robot looked really promising, but it seemed pretty low level. I was
wondering if it would be easier just to create my own AWTEvents and then
post them. The problem with that is that I should give a valid source, which
means I would have to go through the component hierarchy to get the source.
Hmmn. It sure would be nice if I could get the source to generate that event
itself, since it is supposed to do that anyway. You know, after thinking
about it, maybe Robot is the easiest way of doing that.
So, how do you figure out the coordinates to do a button click or a
text entry? Let me guess... java.awt.Container.getLocationOnScreen() ?
Oh, before I forget, one last question: How do you take care of the
System.exit problem? If you are running jython and Robot in the same jvm and
you exit and your windowClosing callback calls System.exit(),
then everything closes, including your test harness. Is there a
different way of closing the app, or do you control this externally by
having a script/program which runs your suite of tests?
We use jython and Robot to record and playback GUI tests. It
better when jython and Robot are running in the same jvm as the
being tested. Then jython can examine the awt component
and can do higher level operations than moving the mouse and
clicks and keystrokes.
I know I am
resurrecting an old thread, but I didn't see any more info about
Summary: Is there a way to use jython to do automated unit tests?
Answer: 2 different options, both can be done in either Java or jython.
1) Recording AWT events using a listener, and then playing the events
back, or 2) using java.awt.Robot
anybody tried either of these? How was the experience? Are there things
I should look out for with either of these? Can anyone point me to some
examples I could look at? Are there other options not mentioned here? I
would love to have a way to code up my box test cases and run them
automatically, and I don't want to reinvent the wheel.
Software Engineer |