I am writing some JUnit tests for my Java program. Some of these tests cause messages to pop up that stop the tests and require me to click ok for them to continue.
Is there a way I can programatically, from my test class, close the JDialog?
I am writing some JUnit tests for my Java program. Some of these tests cause messages to pop up that stop the tests and require me to click ok for them to continue.
Is there a way I can programatically, from my test class, close the JDialog?
It sounds like you need to adopt a better design pattern. You should be aiming to separate your testable business logic from your user interface.
In the long term, I'd recommend moving towards a design pattern such as model, view, presenter (MVP). All your business logic would exist in the presenter and this would be the layer to test.
As a short term solution, refactor your code so that any messages are handled by some kind of MessageHandler
interface. In your product code, this will create real dialogs for the user to interact with. In your tests, you can mock the interface and verify it has been invoked.