Reputation: 2311
I read that junit can run without a main() method, but I want to create a jar file for my test. How can I invoke my tests from Main() method? Is there any other way to create jar file for testcases? My code is as follows:
public class LoginClass {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://erp.company.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testERPLogin() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.name("login")).clear();
driver.findElement(By.name("login")).sendKeys("manju.r");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.name("submit")).click();
driver.findElement(By.cssSelector("div.oe_attendance_signout")).click();
}
public static void main(String[] args) {
}
}
Upvotes: 1
Views: 893
Reputation: 1510
Use JUnitCore.main();
how to export (JUnit) test suite as executable jar
Is a very similar question with the following answer:
public static void main(String[] args) throws Exception {
JUnitCore.main(
"com.stackoverflow.MyTestSuite");
}
Upvotes: 1