wrote:
> Hi all,
>
> We started incorporating JUnit into our development. One issue we
> encountered is the data set up in the database. For example, if I
want to
> test adding a merchant account in our system, I can run a Junit
test to do
> so. However, in our system, a merchant account can be added but
not deleted
> (go to inactive). In Junit, we can specify the name of the
merchant to
> create, but it only works the first time. Once the merchant is
created, we
> can't create the same one again. There are other parts of the
system work
> the same way. Pretty much like bank transactions. They don't get
deleted in
> the database.
>
> One way to is cut a clean database image and restore it for
testing. This
> will work well in some cases. In other cases, we want to test the
changed
> code with existing data to make sure new code works with old data.
>
> Anyone has any experience in solving this?
>
> Hayward
We have a similar situation using C# and NUnit.
The approach we have taken is to script a test database, that get re-
created before tests are run. There is also a clean down procedure
that deletes any data that has been created by the tests. This
procedure uses the fact that we have createdDate and updatedDate
fields on most of out tables. It executes sql like
"DELETE from tableName WHERE CreatedDate > '2002-10-07'" on each of
the tables. We don't have any constraints problem in our database,
but it may be something that would affect other databases.
The clean-up procedure avoids having to re-create the test database
after every test (takes far too long when you are developing, but
may be ok for batch tests?).
If you are using a timestamp/updateDate/createdDate field you may be
able to use this to produce a cleanup procedure? This could work
with existing data, if you are able to change the date/time after
which data will be "cleaned up".
Some of our tests rely on some specific test data existing in the
database. If we were to use existing data, we would need to merge
this with the existing data. You may have a similar situation, or
do your tests use existing data anyway?
BTW we also have a function to extract a subset of the current
database state as an xml file, which we then use in the test cases
to verify that the database state has been updated as expected.
This seems to work quite well.
Hope this is of some help
Regards
Mark Smithson
2:59:15 PM
NetNewsWire is what PointCast could have been. I once read a statistic back in 1996, when I used PointCast that over 60% of the internet's traffic was accountable to PointCast :)~
2:50:23 PM
My question posed to the XP Yahoo Group:
Can some people share their experiences with testing tools for Swing.
Currently we do not automate acceptance tests as they pertain to UI. I want
to get this moving. We already use JUnit and are learning Cactus for our web
apps.
What are people using for Swing UI's?
Mike
The responses:
Alex Chaffee
I use test-package-accessible accessors and/or mock objects and/or
mock event handlers to test my Swing objects.
CalculatorPanel p = new CalculatorPanel()
p.getFirstOperandTextField().setText("2");
p.getSecondOperandTextField().setText("5");
p.getAddButton().doClick();
assertEquals("7", p.getResultTextField().getText());
There's also JFCUnit which reportedly does some AWT magic to intercept
events and grab all the components by name, which is good to test GUIs
that were not designed with accessors for the interesting bits. See
http://jfcunit.sourceforge.net/ and
http://jfcunit.sourceforge.net/loginscreenexample.html
Matthew Pekar
For acceptance tests, I use my own utility, Pounder, which is
available on SourceForge. There are two other similar projects,
Abbot and qftestJUI. qftestJUI is commercial. Rational I believe
has something also.
http://pounder.sourceforge.net/
http://abbot.sourceforge.net/
http://www.qfs.de/en/qftestJUI/
Pounder works by recording user input on a given test class and
saving it to a script. The user can add simple assertions (window
showing, text equals, etc.), or have the developer examine the
results of the test in source (was my data entered in the database,
was the file written, etc.)
Documentation of acceptance tests can be done with Pounder (depending
on what one considers documentation). For example, the user could
record a script, which he then comments: "After this script is
played, so and so should be present in the database". He gives it
to the developers, who then write the database check in Java. The
user has still constructed the test, but there is a portion that is
not very practical for him to implement. A comment describing the
test is also nice to have in case it needs to be rerecorded in the
future.
The downside of Pounder is that a test can't be constructed till a
GUI skeleton is in place. Given how easy it is to use, I don't
consider this much of a problem. The bottom line is the customer
gets their tests.
Dave Astels
JFCUnit is ok, but you have overhead code to add to your tests, and you
have to extend a special TestCase.
Have a look at Jemmy as well, much more powerful & cleaner:
http://jemmy.netbeans.org/
mlroyle
There is a SourceForge project called Marathon
(http://marathonman.sourceforge.net). It is based on JFCUnit and
handles a lot of issues that you raised. It will record user
activities and store them in an XML file that can either be run from
the commandline (or build script) or from the recording gui.
12:48:31 PM