Search the web
Sign In
New User? Sign Up
uispec4j
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
FW: Building UISpec4J   Message List  
Reply | Forward Message #95 of 633 |
Re: FW: Building UISpec4J

Problem solved - and I tracked it down to how I defined my testcase
constructor, which lead to a bad interaction with JUnit. My code was
like this:

public MyTestCase(String testName) {
super(new MyUISpecAdapter());
}

I did this because I was already using the "named" constructor in my
original testcase (it was coded for an older version of JUnit which
required the String arg) and because the "named" ctor in
UISpecTestCase does not set the adapter - and there is no way to set
it later. And I didn't want to use the system property method as I
will have different adapters for different testcases.

The problem with my code is that, if a named constructor (with a
String argument) is available, the JUnit framework will call it
instead of calling the anonymous (no argument) one (see
TestSuite.createTest). And since in the implementation above I do
*not* propagate testName, I ended up triggering an assertion deep
inside JUnit (which IMHO should have a reason string associated with
to make it easier on us users).

So the solution was to change the constructor to:

public MyTestCase(String testName) {
super(new MyUISpecAdapter());
setName(testName);
}

From this exercise, I would like to suggest a small change in the
UISpecTestCase implementation. Currently there are only two ways to
set the adapter: 1) through a constructor and 2) through a property.

The second one forces you to have one adapter for the entire JUnit
execution, which too limiting if you have a large suite of tests that
exercise different components (unless I am missing something too
obvious, that is).

So I believe in practical terms users will use the constructor-based
approach. But it can lead to problems like the one above (different
constructors leave the object in different states) and it also imposes
an execution flow that may not be a good match for some applications.

In my particular scenario the UI classes are implemented on top of a
threading framework that requires some initialization; to be able to
pass the adapter in the testcase constructor I had to move a lot of
logic around, from the testcase to the adapter.

Instead of the constructor-based initialization, I would add a simple
protected setter to the UISpecTestCase class to allow the user to set
the adapter later in the constructor, or even in the setUp() method.
This would support more flexible execution flows. In this case the
constructor would become:

public MyTestCase(String testName) {
super(testName);
//... initialization here if necessary
setAdapter(new MyUISpecAdapter());
}

or even better:

public MyTestCase(String testName) {
super(testName);
}

public void setUp() {
super.setUp();
//... initialization here if necessary
setAdapter(new MyUISpecAdapter());
}

Other then that, I am quite happy :-) I ported a few testcases from
Abbot to UISpec and they not only were cleaner (less code) and faster
(calls to Thread.sleep() removed) but also more powerful - for example
ListBox supports the selection of multiple indexes, while in Abbot I
had to "fake" multiple selection using shift-clicks. Everything worked
just fine!

Many thanks,
Nascif











Thu Aug 4, 2005 6:04 pm

nascif2
Offline Offline
Send Email Send Email

Forward
Message #95 of 633 |
Expand Messages Author Sort by Date

Hi all, I started playing with UISpec4J - tired of the problems with Abbot, and curious about the different approach. My first experience has not been very...
Nascif Abousalh-Neto
nascif2
Offline Send Email
Aug 3, 2005
5:46 pm

Hi Nascif, Thanks for taking the time to tell us about these issues. ... What problems did you have with Abbot ? I never used it myself, but I thought it was...
Regis Medina
regis_medina
Offline Send Email
Aug 3, 2005
9:01 pm

... Abbot, and ... I have way too many problems with having reliable "reproducable" unit tests. I run my tests through many different paths - directly from ...
nascif2
Offline Send Email
Aug 3, 2005
10:21 pm

Problem solved - and I tracked it down to how I defined my testcase constructor, which lead to a bad interaction with JUnit. My code was like this: public...
nascif2
Offline Send Email
Aug 4, 2005
6:04 pm

Hi Nascif, ... That was tricky, the JUnit message could have been more explicit. Maybe we should tell them about this issue, or suggest a patch? Do you know...
Regis Medina
regis_medina
Offline Send Email
Aug 6, 2005
12:17 pm

... Maybe we ... were in ... Sure. The code that creates the problem is this one, from TestSuite.java: static public Test createTest(Class theClass, String...
nascif2
Offline Send Email
Aug 8, 2005
3:25 pm

Hi Nascif, ... It would surely be great to propose this change on a JUnit mailing list, so that it gets integrated into their next release. Will you do it, or...
Regis Medina
regis_medina
Offline Send Email
Aug 8, 2005
9:28 pm

Hi Regis, ... If you could do it it would be great, thanks. ... Yes. You would give up the compile-time checking for some run-time flexibility. Basically you...
Nascif Abousalh-Neto
nascif2
Offline Send Email
Aug 8, 2005
11:09 pm

Hi Nascif, On Tue, 09 Aug 2005 01:08:55 +0200, Nascif Abousalh-Neto ... As of release 0.11, there is a "UIComponent findComponent(Class uiComponentClass)"...
Regis Medina
regis_medina
Offline Send Email
Aug 9, 2005
8:19 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help