???Spring???е????????£?
???????????? ???????[ 2013/6/7 10:59:15 ] ????????
????@TransactionConfiguration ?? @Rollback
??????????£?Spring ????????????????е???? transactionManager ?? bean ??????????????????????????????????????? transactionManager ?????????????????? defaultRollback ???????? true???????е?????? rollback???????????? false???????????Щ??? rollback ??????????????? @Rollback??true?????ɡ?
?????? Junit4 ??????????
???????????? Spring ?????????????????????????Щ????????? Junit4 ????????? Spring ????????е???÷?????
????@Test(expected=…)
???????????????????????????????????????????????????????? xxx.class ????????磬??????? AccountService.Java ?? insertIfNotExist ????????????????????????????? IllegalArgumentException?????£?
public void insertIfNotExist(Account account) {
if(account==null)
throw new IllegalArgumentException("account is null");
Account acct = accountDao.getAccountById(account.getId());
if(acct==null) {
log.debug("No "+account+" found??would insert it.");
accountDao.saveAccount(account);
}
acct = null;
}
???????????????????????????????????????£?
@Test(expected=IllegalArgumentException.class)
public void testInsertException() {
service.insertIfNotExist(null);
}
???????н???? green bar??
????@Test(timeout=…)
???????????????????????????????????????????????????????????????
?????????? AccountService ?????????·?????
public void doSomeHugeJob() {
try {
Thread.sleep(2*1000);
} catch (InterruptedException e) {
}
}
????????????????????????? 2 ?????????????£?
@Test(timeout=3000)
public void testHugeJob() {
service.doSomeHugeJob();
}
?????????????????? service.doSomeHugeJob ???????? 3 ???????????в??????? green bar??
????@Repeat
??????? @Repeat?????????????????в??????????????????д for ???????÷?????
@Repeat(3)
@Test(expected=IllegalArgumentException.class)
public void testInsertException() {
service.insertIfNotExist(null);
}
??????????testInsertException ?????? 3 ?Ρ?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11