I doubt whether there's a solution to this but thought I'd ask anyway.
java.awt.Robot is very useful for unit testing, to simulate user input/action. The trouble is you can't then do anything else on your comp for the duration of the test, because the Robot keyPresses, etc., will then start happening in the application which has focus at the time, not in the app which you are subjecting to testing...
Even if you precede every such Robot command with requestFocus or some such this is not a solution for the simple reason that between such commands, which must be run in the EDT, and the Robot's command, which must be run in a non-EDT thread, you may happen to do sthg (keyboard or mouse action) which will transfer focus outside the test app.
I think therefore that a Robot which knows it must interact only with the test app is kind of essential. Without that you "lose" your machine for the duration of the tests.
Running the tests in a VM might be one solution - does anyone know of any other?
Aucun commentaire:
Enregistrer un commentaire