lundi 24 août 2015

JUnit-Test for main() without saved objects

I want to test the entry point of my Swing-Application, which is designed in MVP-pattern. public static void main (String[] args) does nothing more then launching a MainPresenter with its view and model.

public class JMasapp {
    public static void main(String[] args) {
        new MainPresenter(new MainView(), new DataModel());            
    }
}

I want to test if the presenter, view and model is null. (assertNotNull(...)). Because of the design, i don't want to save the presenter or implement setters / getters for static objects. So

JMasapp jm = new JMasapp();
jm.main(new String[] {"someArg","someOtherArg"});

wouldn't give a reference to the objects to test. Which way is the best to solve this problem?

Aucun commentaire:

Enregistrer un commentaire