How to access GUI Component?

View: New views
3 Messages — Rating Filter:   Alert me  

How to access GUI Component?

by mohitkk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am new to JUnit and i am using the JFCUnit for the swing
application. I have an application in which i have various gui
components but these controls are defined as local in the method
related to the control. How do i access these local components for
writing the test case. Please suggest me.

Thanks
Mohit


Parent Message unknown RE: How to access GUI Component?

by Colin Vipurs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mohit,

 

It's been a while since I've done any gui testing with JFCUnit but there
should be a way to access each component by it's name property (you have
set the name properties right?).  I'd like, if I may, to suggest an
alternative approach which I found to work really well on the last Swing
project I developed.

 

First of all, have a read of "The Humble Dialog Box" here:
http://www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf

 

Following on from this, treat your view purely as a presentation layer
(have a look at the Model-View-Presentation pattern) which acts as a
proxy to the real graphical components.  If you store next to no logic
within your view layer there's little need to bother testing this layer
as it should just be:

 

a)       passing values onto graphical components, e.g. text into text
fields, values onto spinners etc.

b)       passing events back to the controller, e.g. button presses into
use case actions

 

As stated in the above article, if your view layer is thin enough, you
can avoid testing it altogether and avoid the pain of doing GUI unit
testing.

 

Shout if you need anymore help with this.

 

________________________________

From: java-gui-testing@...
[mailto:java-gui-testing@...] On Behalf Of mohitkk
Sent: 13 March 2007 09:10
To: java-gui-testing@...
Subject: [java-gui-testing] How to access GUI Component?

 

Hi,

I am new to JUnit and i am using the JFCUnit for the swing
application. I have an application in which i have various gui
components but these controls are defined as local in the method
related to the control. How do i access these local components for
writing the test case. Please suggest me.

Thanks
Mohit

 


Re: How to access GUI Component?

by David Herron-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I don't know JFCUnit .. but the general way to do what you're saying  
is a combination of

        a) a method in java.awt.Frame that gives you a list of all the  
active Frame's
        b) a method in Container that gives you the child components

I don't remember either method name right now .. but between them you  
can traverse the tree of all current Component objects.

- David



On Mar 13, 2007, at 2:09 AM, mohitkk wrote:

> Hi,
>
> I am new to JUnit and i am using the JFCUnit for the swing
> application. I have an application in which i have various gui
> components but these controls are defined as local in the method
> related to the control. How do i access these local components for
> writing the test case. Please suggest me.
>
> Thanks
> Mohit
>
>
>
>