有些对象需要mock的对象是由工厂方法产生出来的,而工厂方法一般是静态方法,这时候就需要同时mock工厂方法及对象 被测方法: public class EmployeeServiceFactory { public void saveEmployee(Employee employee){ EmployeeDaoFactory dao = EmployeeDaoFactory.newInstance(); method("powermock"); dao.addEmployee(em
玩转单元测试之 Testing Spring MVC Controllers 转载注明出处:http://www.cnblogs.com/wade-xu/p/4311657.html The Spring MVC Test framework provides first class JUnit support for testing client and server-side Spring MVC code through a fluent API. Typically it loads t
前言 最近在项目中发现了一则报错:"org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only".根据报错信息来看是spring框架中的事务管理报错:事务回滚了,因为它被标记为回滚状态. 报错原因 多层嵌套事务中,如果使用了默认的事务传播方式,当内层事务抛出异常,外层事务捕捉并正常执行完毕时