0

I have some private method. for access the method and do the test I create a new instance as follows in a test class.

Class c = Class.forName("com.leopard.spring.StartGame");
    StartGame testSG1 = (StartGame)c.newInstance();

    Method m = testSG1.getClass().getDeclaredMethod("setUpForm");
    m.setAccessible(true);
    m.invoke(testSG1,null);

After doing that I couldn't call for the setUpForm() method to test that. What should I do?

1 Answers1

1

Recommended practice is to test what will be consumed by the consumer. So public methods will be exposed to the consumer so should be tested.