【发布时间】:2012-09-27 11:08:20
【问题描述】:
我有一组用 Java 编写的 Selenium WebDriver 测试。
是否有可以运行它们的带有 Web 界面的框架?
此 Web 界面应显示所有测试的列表、运行一项或所有测试的能力并显示其运行结果。
【问题讨论】:
标签: java testing selenium webdriver automated-tests
我有一组用 Java 编写的 Selenium WebDriver 测试。
是否有可以运行它们的带有 Web 界面的框架?
此 Web 界面应显示所有测试的列表、运行一项或所有测试的能力并显示其运行结果。
【问题讨论】:
标签: java testing selenium webdriver automated-tests
简化:
您可以使用 Jenkins(CI 工具)> 使用 ANT (BUILD.xml) > 运行与 TestNG 框架 > 结合您的 WebDriver 脚本。
【讨论】:
没有现成的“Web 界面”,但 CI(持续集成)服务器和软件在这方面做得很好。
例如,TeamCity 可以完全满足您的需求,但仅靠 Selenium 和您的测试框架(NUnit、Junit 等)就无法满足您的需求。
【讨论】:
嗯。不能肯定地说网络界面,但在我看来,你应该深入研究@Category 注释方向。
对于我的项目,我使用 Maven 构建管理器。并且使用@Category 表示法,您可以向 Maven 显示构建中应该包含哪些类别的测试以及应该排除哪些类别。
这是我在项目中使用的结构示例:
rms-web pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
<configuration>
<!--<includes>-->
<!--<include>**/*.class</include>-->
<!--</includes>-->
<excludedGroups>com.exadel.rms.selenium.SeleniumTests</excludedGroups>
</configuration>
</plugin>
PassTest.java
package com.exadel.rms.selenium;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertTrue;
/**
* Created with IntelliJ IDEA.
* User: ypolshchykau
* Date: 8/28/12
* Time: 8:38 PM
* To change this template use File | Settings | File Templates.
*/
public class PassTest {
@Test
public void pass() throws IOException, InterruptedException {
assertTrue(true);
}
}
SeleniumTests.java
package com.exadel.rms.selenium;
/**
* Created with IntelliJ IDEA.
* User: ypolshchykau
* Date: 8/27/12
* Time: 6:49 PM
* To change this template use File | Settings | File Templates.
*/
public class SeleniumTests {
}
LoginPageTestSuite.java
package com.exadel.rms.selenium;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openqa.selenium.By;
import java.io.IOException;
@Category(SeleniumTests.class)
public class LoginPageTestSuite extends BaseSeleniumTest {
@Test
public void pressLoginButton() throws IOException, InterruptedException {
doLogout();
fluentWait(By.cssSelector(propertyKeysLoader("login.loginbutton"))).click();
Assert.assertTrue(fluentWait(By.cssSelector(propertyKeysLoader("login.validator.invalidautentication"))).getText().trim().equals("Invalid authentication"));
}
…..........
}
我用 Maven 检查了我的测试类别,内容如下:
mvn -Dmaven.buildNumber.docheck=false -Dmaven.buildNumber.doUpdate=false clean test
假设您可以获得更多信息here here 还有关于 maven surefire plugin 希望对你有帮助)
【讨论】:
您可以通过使用带有 TestNG 框架的 Ant (build.xml) 来制作测试套件。 build.xml 由 Ant 以两种方式运行: 1.有IDE(如Eclipse) 2. 从命令提示符
【讨论】: