I am still new to JUnit testing. I am writing junit tests for this method:
public void LoadApplet(JPanel panel) {
AppletClass applet = new AppletClass();
applet.init();
panel.add(applet,BorderLayout.CENTER);
applet.start();
}
I wrote the unit test this way and it worked:
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());
}