我使用selenium webdriver 2.0 java api在我的公司运行一些测试。我自由意志地行事,对自动化没有深入的了解,所以请分清我的无知。从junit测试中获取结果
我想知道如何从“@test”方法检索结果以防万一我想将测试结果记录到文件中。
说我有这个测试用例,我将如何返回结果作为布尔值?
@Test
public void like(){
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.className("feed-item-ph")));
WebElement like = driver.findElement(By.cssSelector("a.action-block-a.action-like"));
like.click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("registration-book")));
driver.quit();
}
每个能够运行JUnit测试的工具都能够将测试结果保存在一个文件中。你在用什么? Ant,Maven?你有IDE吗? – toniedzwiedz
在Maven中使用Eclipse – Yosi199
然后,您可以使用surefire maven插件。这里有一个相关的[SO问题](http://stackoverflow.com/questions/2030266/junit-output-in-maven-reports) – toniedzwiedz