0
我做使用JUnit 4 Java的一些自动化,现在我想添加使用JFrame的某些图形模式,我在这@Test代码(GUI是JFrame的对象):的JFrame在@Test消失的JUnit
@Test
public void initData() {
try{
setLayout(new FlowLayout());
gui.setTitle("Linkedin Candidates Search Tool");
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setSize(400, 200);
gui.getContentPane().setLayout(null);
gui.add(ScreenTools.createLabel("Enter password: ", 5, 80, 110, 15));
textopassword = ScreenTools.createTextField(120, 80, 150, 20,"");
gui.add(textopassword);
boton = ScreenTools.createButton("Generate",5,120,60,15);
gui.add(boton);
gui.setVisible(true);
accion e = new accion();
boton.addActionListener(e);
}catch (Exception e){
System.out.println("Error M001. " + e);
}
然后在听者“BOTON”(这是一个按钮),我有一些自动化操作:
public class accion implements ActionListener {
public void actionPerformed (ActionEvent e){
try{
openingTabs();
}catch (Exception f){
System.out.println("Error M001. " + f);
}
}
}
我的问题是,被关闭的JFrame窗口,并没有让我执行按钮的动作,任何想法?