现实中经常会在类中拆分为一些小方法为private,这些方法是不在interface上暴露给外部的
现在想在细粒度上对这些private方法做单元测试,可是继承TestCase的类无法找到这些方法,除非把这些方法标记为public
[code="java"]
public class AlarmQueryDAOTest extends TestCase
{
private IAlarmQueryDAO dao;
protected void setUp() throws Exception
{
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
dao = (IAlarmQueryDAO)context.getBean("alarmQueryDao");
}
public void testGet()
{
ReporterStatus rs = dao.get(123L);
}
}
[/code]
请问有什么办法,既可以保持这些方法为private,又能在单元测试类中调用呢?