我是JUnit和Swing的新手,可以为Swing应用程序编写JUnit测试用例,尤其是对于ActionListeners而言,如下所示...

public class sampleFile extends JFrame{
    JTextField userText = new JTextField(15);
    JLabel lable;
        JTextField name;
        JPanel panel;
    JButton submit;
        JFrame frame;
     sampFile(){
        lable.setBounds(60, 200, 200, 30);
        text.setBounds(130, 200, 165, 25);
        panel.add(text);
        panel.add(text);
        frame.add(panel);
        submit.addActionListener(e -> sendActionPerfrm())
     }
     private void sendActionPerfrm(){
      -------------
        All validations for the text from textfield goes here
      -----------
    }


提前致谢

最佳答案

注意:我为维护马拉松的Jalian Systems工作

您可以使用marathon java driver提供WebDriver绑定来测试Swing和FX应用程序。此blog article提供逐步说明。

09-28 09:05
查看更多