> Hi,
>
[quoted text clipped - 31 lines]
> Ciao,
> Ingo
Hi,
Thanks for your reply. I am facing still a problem. Suppose if i
have a method i.e.
class Menu_Bar
{
JMenuBar menubar = new JMenuBar();
JMenuItem File;
JFrame frame = new JFrame();
public Menu_Bar()
{
this.CreateMenu();
...
frame.setJMenuBar(menubar);
}
void CreateMenu()
{
JMenu menuFile = new JMenu("File");
......
}
}
Now could you suggest me how do i test this method i.e. CreateMenu()
which has some local components.
Thanks & Regards
Mohit
Ingo R. Homann - 19 Apr 2007 12:37 GMT
Hi,
> Hi,
>
[quoted text clipped - 25 lines]
> Now could you suggest me how do i test this method i.e. CreateMenu()
> which has some local components.
Sorry, but I think it is nearly impossible to write unit tests that
tests a GUI! (Well, indeed it is possible, but it is quite difficult and
never covers what a manual test covers.)
Ciao,
Ingo
Daniel Pitts - 19 Apr 2007 17:04 GMT
> Hi,
>
[quoted text clipped - 37 lines]
>
> - Show quoted text -
Like Patricia has stated, JUnit tests don't work well for GUI's.
JUnit is best for testing functionality use cases, rather than
usability.
Write tests for each of the user actions, not for the gui :-)
Hope this helps,
Daniel.
Patricia Shanahan - 19 Apr 2007 17:10 GMT
> Hi,
>
[quoted text clipped - 31 lines]
> tests a GUI! (Well, indeed it is possible, but it is quite difficult and
> never covers what a manual test covers.)
I completely agree about testing a GUI, but I don't see any reason not
to unit test methods that contribute to a GUI.
Patricia
Patricia Shanahan - 19 Apr 2007 13:31 GMT
>> Hi,
>>
[quoted text clipped - 56 lines]
> Now could you suggest me how do i test this method i.e. CreateMenu()
> which has some local components.
The first thing I would do is to add Javadoc comments or equivalent to
CreateMenu(). The really serious problem with unit testing it is that
the program contains no statements about its preconditions and
postconditions.
You then have to ensure two things, that CreateMenu's unit test has the
power to make the preconditions true, and has access to enough data to
check the postconditions. For example, if there are postconditions
related to menubar you will need a getMenuBar method returning its
current value.
The form of the unit test is:
Make the method's preconditions true.
Call the method.
Get the values of variables involved in its postconditions.
Test the postcondition assertions.
Patricia
news.rcn.com - 19 Apr 2007 21:31 GMT
What 'side effects' does this method have that you are interested in? If
there are none, then it just runs some code and quits and no-one would care
if it did that correctly or not.
There's no return code, so that's not a side-effect?
Does it set any class or global (hopfully not) variables? check those.
Do you want to check the menu for validity? have the method return it and
test it.
From what you've shown us of your method, there's really not much
interesting going on.
Sorry if this sounds cynical,
jim
p.s. As others have said, JUnit's not really up to Gui testing - (though you
could create GUI objects and exercise them with through code if you want to
bother to program the user actions (clicks, text input, etc.).
void CreateMenu()
> {
> JMenu menuFile = new JMenu("File");
> ......
> }
>> Hi,
>>
[quoted text clipped - 64 lines]
> Thanks & Regards
> Mohit
mohit.khatri28@gmail.com - 23 Apr 2007 05:08 GMT
Hi,
First of all Thanks to all for suggesting me valuable solution.
Now i would like to ask that my application has been integrated. I
want to test unit testing of my application. Is it possible to test
unit testing after integration of code. If i use JFCUnit i.e. an
extension of JUnit then it is possible to test my methods which
neither returns any value nor contains any argument. Or manual testing
is better solution for testing my GUI application. Please suggest me a
solution.
Thanks & Regards
Mohit
Patricia Shanahan - 24 Apr 2007 11:40 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> is better solution for testing my GUI application. Please suggest me a
> solution.
I find this question confusing, because it seems to me to suggest as
alternatives two forms of testing I consider complementary:
1. Unit testing individual classes, and methods within classes. Tests
whether a unit conforms to its contract with the rest of the application.
2. System test a complete application. Tests the external behavior of
the whole application.
I don't see how they can be alternatives, to be compared. Each has its
own purpose. It is often difficult, or even impossible, to test the
entire contract for a unit by manipulating only external inputs and
outputs. On the other hand, testing that each unit conforms to its
contract does not necessarily ensure the application behaves sensibly.
Patricia