【发布时间】:2010-04-04 20:50:38
【问题描述】:
测试 UI 很困难。您认为 Swing 最好的单元测试框架是什么?
【问题讨论】:
标签: java unit-testing swing
测试 UI 很困难。您认为 Swing 最好的单元测试框架是什么?
【问题讨论】:
标签: java unit-testing swing
目前我认为最好的是FEST。
【讨论】:
你认为最好的单位是什么 Swing 的测试框架?
好问题。我帮不了你。我可以向您指出我从 Misko Hevery's 站点阅读的有关 ui 测试的文章
重要的是分开 来自控制逻辑的图形 UI 和数据。这可以通过 标准模型视图控制器 设计模式
这是一个关于测试的网站。我发现 Michael Featers 的这篇有趣的文章解释了UI Test Automation Tools are Snake Oil
【讨论】:
我一直在 JUnit 之上使用Jemmy。您可以在此处查看他们的示例test-case actions 的 sn-p:
new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser")
.startApplication();
JFrameOperator mainFrame = new JFrameOperator("GUI Browser");
new JButtonOperator(mainFrame, "Reload In").push();
new JLabelOperator(mainFrame, "Reloaded");
JTreeOperator tree = new JTreeOperator(mainFrame);
//click in the middle of the tree
tree.clickMouse();
//collapse node
tree.collapsePath(tree.findPath("", "|"));
//expand node
tree.expandPath(tree.findPath("", "|"));
//select node
tree.selectPath(tree.findPath("GUI Browser", "|"));
JTextFieldOperator testField = new JTextFieldOperator(mainFrame);
//type new value in the text field
testField.clearText();
testField.typeText("3");
【讨论】: