问题描述
我有一个使用java.awt.Robot练习自定义Swing组件的测试。我想在我们的构建服务器中运行测试,但构建服务器在锁定的Windows机器上运行,并且Robot.keyPress(char)在屏幕锁定时不起作用。我发送的按键有时候是向下箭头和退格键,所以将它们直接发送到文档是没有用的。
I have a test that exercises a custom Swing component using java.awt.Robot. I'd like to run the test in our build server, but the build servers run on locked windows machines, and Robot.keyPress(char) doesn't work with the screen locked. The keystrokes I'm sending are sometimes things like down arrow and backspace, so sending them directly to the document isn't helpful.
目前我只是使用junit的Assume跳过测试,如果键盘输入在第一次尝试时不起作用,但我想让这些测试保持启用状态。我会假设有人正在对Swing gui进行这些测试。任何想法?
Currently I'm just using junit's Assume to skip the tests if keyboard entry doesn't work on the first try, but I'd like to leave these test enabled. I would assume someone out there is running these kinds of tests against a Swing gui. Any ideas?
推荐答案
在黑暗中刺伤:也许虚拟机(如VirtualBox)可以在后台运行,但是所有意图和目的都是机器人知道的清醒和解锁。虚拟框将运行您的单元测试。
A stab in the dark: perhaps a VM (like VirtualBox) could be running in the background, but would for all intents and purposes be "awake and unlocked" as far as the robot knows. The virtual box would run your unit tests.
这篇关于使用java.awt.Robot测试键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!