????????????????????
???????????? ???????[ 2014/10/16 11:40:31 ] ??????????????? ???????
import static org.junit.Assert.assertEquals ;
import org.databene.benerator.anno.Source;
import org.databene.feed4junit.Feeder;
import org.junit.Test;
import org.junit.runner.RunWith;
import sample.junit.code.*;
@RunWith (Feeder.class )
public class Feed4junitSample {
@Test
@Source( "Data.csv" )//CSV source
public void testAccessCheck_CSV(String userName?? String pw?? boolean expected) {
assertEquals(expected?? UserAccess. accessCheck(userName?? pw));
}
@Test
@Source( "data.xls" )//Excel source
public void testAccessCheck_Excel(String userName?? String pw?? boolean expected) {
assertEquals(expected?? UserAccess. accessCheck(userName?? pw));
}
}
???????н?????£?
????3???????????????
?????????Feed4junit????????????????????????????????????????????????????????????????£?
????????????@Database??
import static org.junit.Assert.assertEquals;
import org.databene.benerator.anno.Database;
import org.databene.benerator.anno.Source;
import org.databene.feed4junit.Feeder;
import org.junit.Test;
import org.junit.runner.RunWith;
import sample.code.UserAccess;
/*
* Feed4JUnit - Get Data from Database?? all test methods can use the database data
*/
@RunWith(Feeder.class)
@Database(
id = "testdb"??
url = "jdbc:mysql://localhost:5000/SAMPLE"??
driver = "com.mysql.jdbc.Driver"??
user = "admin"??
password = "admin")
public class F4JfromDB {
@Test
@Source(id = "testdb"?? selector = "select * from TEST")
public void testAccessCheck(String userName?? String pw?? String expected) {
Boolean bSucess = UserAccess.accessCheck(userName.trim()?? pw.trim());
assertEquals(expected.trim()?? bSucess.toString());
}
}
?????????????????@Database
@RunWith(Feeder.class)
public class F4JfromDB_Method {
@Test
@Database(
id = "testdb"??
url = "jdbc:mysql://localhost:5000/SAMPLE"??
driver = "com.mysql.jdbc.Driver"??
user = "admin"??
password = "admin")
@Source(id = "testdb"?? selector = "select * from TEST")
public void testAccessCheck(String userName?? String pw?? String expected) {
Boolean bSucess = UserAccess.accessCheck(userName.trim()?? pw.trim());
assertEquals(expected.trim()?? bSucess.toString());
}
}
???????????й????У???? url??driver ????????????????????? selector ????????????????????????????????????????????????????????????????????е????????????????.
????4????
????Feed4JUnit ?????????????????????????????????????Feed4JUnit ?????????????????????????????????????????????JUnit ?????????????????????????????????
????Feed4JUnit ???????????????????????????????????????????????????????
??????
???·???
??????????????????
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