I have problem with passing a bean class like mvc concept to implement to jUnit class. I don't want change the structure jUnit class, because i have need it.
Class DataBean
public class DataBean {
private String browserName;
private String userName;
public String getBrowserName() {
return browserName;
}
public void setBrowserName(String browserName) {
this.browserName = browserName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
Class Main
public class Main {
public static void main(String[] args) {
String[] arrBrowserName = {"chrome", "firefox"};
String[] arrUserName = {"user1", "user2"};
for(int i=0; i<2; i++) {
DataBean dataBean = new DataBean();
String browserName = arrBrowserName[i];
String userName = arrUserName[i];
dataBean.setBrowserName(browserName);
dataBean.setUserName(userName);
//How to call "TestCase1", include passing the "databean"
JUnitCore junit = new JUnitCore();
junit.run(TestCase1.class);
}
}
}
Class TestCase1
public class TestCase1 {
DataBean dataBean = new DataBean();
//Here, how to do ? i want to get "databean" from "Main" class, without change this is class as jUnit
@Before
public void setUp(){
//set up based on data from "Main class"
}
@Test
public void scenario(){
//
}
@After
public void tearDown(){
//
}
}
Based on the above code, let's say i have 2 data as data testing, i want setup the before
based on the data from Main class. Where is i placement the parameter in TestCase1
so that I can get databean
? and is this possible?