public void testClass(Gson gson){
...
생성자(Environment env){}
}
@RunWith(MockitoJUnitRunner.class)
public class LocalTest{
TestClass testClass;
@Mock
Environment env;
@Before
public void setUp() {
testClass = new TestClass(env);
}
@Test
public void privateMethodCall_Test() {
Logger log = (Logger) LoggerFactory.getLogger(LocalTest.class);
try {
Class c = testclass.getClass();
Method method = c.getDeclaredMethod("ParseTest", Gson.class);
method.setAccessible(true);
Gson gson = new Gson();
String Result = (String) method.invoke(testClass, gson);
log.info(Result);
} catch (NoSuchMethodException e) {
log.info(e.toString());
}
}
}