我还是JUnit测试的新手。我正在为这种方法编写junit测试:
public void LoadApplet(JPanel panel) {
AppletClass applet = new AppletClass();
applet.init();
panel.add(applet,BorderLayout.CENTER);
applet.start();
}
答案 0 :(得分:0)
我用这种方式编写单元测试并且它有效:
public void TestLoadApplet() {
AppletClass instance = new AppletClass();
JPanel panel = new JPanel(); // Creating a empty panel
instance.LoadApplet(panel);
assertEquals("java.awt.BorderLayout", panel.getLayout().getClass().getName());
assertEquals("Applets.AppletClassName", panel.getComponent().getClass().getName());
}