Joh*_*nak 21 java testing selenium functional-testing maven
当我使用此命令在Maven中运行单个测试时:
mvn test -Dtest=InitiateTest
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
No tests were executed!
Run Code Online (Sandbox Code Playgroud)
它在几分钟前工作,但现在由于某种原因停止工作.我mvn clean在运行测试之前试过运行了几次,但没有用.
测试看起来像这样:
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class InitiateTest {
public static FirefoxDriver driver;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
}
@Test
public void initiateTest() throws Exception {
driver.get("http://localhost:8080/login.jsp");
...
}
@After
public void tearDown() throws Exception {
driver.close();
Run Code Online (Sandbox Code Playgroud)
}}
更新:
这是通过将此依赖项添加到POM引起的:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0b1</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我删除它,一切正常.即使我添加这两个依赖项而不是前一个依赖项,一切正常:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.0b1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.0b1</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这很奇怪.
小智 6
我有同样的问题.它是由junit3附带的testng依赖引起的.只需为它添加一个排除声明,测试应该有效.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0b1</version>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21823 次 |
| 最近记录: |