Hello Mark,
I
had a different approach here: I started to write tests with a lot of
pre-existing setNames in the code. At other places they were missing and
sometimes there were names which make it even harder to write tests as there
were different names for nearly the same component. Perhaps the last is the most
interesting one: There is a way to specify names which may even make it harder
to write tests. As workaround I wrote a ComponentNameResolver which maps the
different names to one unique name.
I
think best practice is to go the XP way, i. e. only add names if you need them.
If you add a name to every component you might end up with:
The one who writes the tests knows best what would be a
proper name and would immediately see if there are double names as the test will
fail.
I
don't think that dynamic names are a good solution. As you already mentioned
refactoring can easily break the tests. There is only one case where I used
dynamic names: When setting names for the dividers in JSplitPanes I implemented
a calculation of the name for these dividers based on the names of the panes
which belong to the JSplitPane. This was in the "before-qftest-phase". Nowadays
I would write a ComponentNameResolver for this.
I
hope I could give you some ideas how we handle it over here. It would be
interesting to know if there are other best-practices.
Kind Regards,
Mark
Mark
Spielman wrote:
Our organization is beginning to
use qftestJUI to test two of our GUI applications. However I am finding
it hard to understand when, where and how to appropriately use setname to make
our lives easier? We currently do not have extensive use of setname in
either of our two products. We have tried two approaches and both seem
to work but are not necessarily ideal. We are only in the early stages
of test development. What I was wondering is if there are general
guidelines we can use to determine how to properly use setname to make our
lives easier. I’ve read the manual and am searching for slightly more
detail, something along the lines of a best practices technical note or
something?
The two approaches we’ve tried
are:
- Using java reflection to
determine component names based on the coded variable names of the different
components. In this case all components have names. Here there’s a
potential for a component to change names if ever a developer refactors the
code.
- Manually adding names to
components as we discover difficulties in qftestJUI test
implementation. Components are named as needed but development of
tests seems very slow.
What I’m wondering is if you were
going to start a project from scratch, what is the ideal way to use setname to
make testing and test development most
efficient.
Thanks
Mark
-- Mark
Michaelis Software Engineer Quality Assurance
CoreMedia
AG Ludwig-Erhard-Str. 18 20459 Hamburg,
Germany www.coremedia.com
------------------------------------------------------- Any
Content, Anywhere, in a Trusted Universe: CoreMedia CMS and CoreMedia
DRM
|