1. 程式人生 > >spring junit4 測試

spring junit4 測試

pre pri prim ima cat except service mapper new

@Service
@ContextConfiguration(locations = {
        "classpath:config/applicationContext.xml"
})
@RunWith(SpringJUnit4ClassRunner.class)
@TransactionConfiguration(transactionManager="transactionManager", defaultRollback=false)
public class UnionCardServiceImpl implements UnionCardService {

    @Autowired
    
private UnionMemberMapper unionMemberMapper; @Test @Transactional(rollbackFor = Exception.class) public void updateDemo(){ UnionMember member = new UnionMember(); member.setId(39); member.setDelStatus(1); unionMemberMapper.updateByPrimaryKeySelective(member); updateForMaop(); }
public void updateForMaop(){ //System.out.println(1/0);//測試異常情況 UnionMember member = new UnionMember(); member.setId(27); member.setDelStatus(0); unionMemberMapper.updateByPrimaryKeySelective(member);   } }

spring junit4 測試