【问题标题】:Unit testing framework for a Swing UI [closed]Swing UI的单元测试框架[关闭]
【发布时间】:2010-04-04 20:50:38
【问题描述】:

测试 UI 很困难。您认为 Swing 最好的单元测试框架是什么?

【问题讨论】:

    标签: java unit-testing swing


    【解决方案1】:

    目前我认为最好的是FEST

    【讨论】:

    • FEST 现在是 AssertJ-Swing
    【解决方案2】:

    你认为最好的单位是什么 Swing 的测试框架?

    好问题。我帮不了你。我可以向您指出我从 Misko Hevery's 站点阅读的有关 ui 测试的文章

    Misko Hevery 的提示

    • 我想指出你 Google 的测试大师 Misko Hevery 网站。他谈了很多关于如何 编写易于测试的代码。
    • 例如,在阅读他出色的幻灯片"How to Write Hard to Test Code" 时,他指出 幻灯片 45/288 的成本 修复渲染错误是相对的 低的。我认为他是对的 你不应该 关心拥有 100% 的代码 覆盖您的 UI。
    • 他还提供了一些关于如何测试您的UI 的好技巧。

      重要的是分开 来自控制逻辑的图形 UI 和数据。这可以通过 标准模型视图控制器 设计模式

    ObjectMentor

    这是一个关于测试的网站。我发现 Michael Featers 的这篇有趣的文章解释了UI Test Automation Tools are Snake Oil

    【讨论】:

      【解决方案3】:

      我一直在 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");
      

      【讨论】:

        猜你喜欢
        • 2011-02-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-16
        • 1970-01-01
        • 2012-10-18
        • 2011-09-10
        • 2010-09-17
        相关资源
        最近更新 更多