This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Testing and the fly likes JUnit: recognise that a MessageBox pops up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit: recognise that a MessageBox pops up" Watch "JUnit: recognise that a MessageBox pops up" New topic
Author

JUnit: recognise that a MessageBox pops up

Steffen Mezger
Greenhorn

Joined: May 11, 2006
Posts: 1
Hi,

i have to test a function which opens a Messagebox at the end of the code. And because that the Junit test will stop until anybody clicks "OK" on the messagebox. Thats not good, because nobody is near the PC during the test...

How can i solve this problem ? Are there any possibilities to close that box automaticly or terminate the new window ??

Thanks !

Best regards,
Steffen
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
There are at least two solutions:

- use an extension to JUnit, such as Jemmy, to actually check that the box is there, and to click the close button, or

- introduce an indirection, so that you can mock the method call that opens the message box


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit: recognise that a MessageBox pops up