java - Maven 不运行 selenium 测试

标签 java maven selenium junit

您好,我正在尝试使用 Maven 运行 JUnit 测试。

public final class CreateAllObject {
    public static final String INIT_URL = new String("http://fpt2:8080/webTest/");

    @BeforeClass
    public static void initialisation() {
        Driver driver = new Driver(PROFILE_PATH);
        driver.getDriver().get(INIT_URL);
        driver.getDriver().findElement(By.xpath(ADMIN_ARM_XPATH)).click();
        BASE_URL = driver.getDriver().getCurrentUrl();
        driver.getDriver().close();
        try {
            new File("C://logfiles//").mkdirs();
            log_work = new BufferedWriter(new FileWriter(new File("C://logfiles//"
                    + new SimpleDateFormat("dd.MM.yyyy 'at' HH-mm-ss").format(new GregorianCalendar().getTime())
                    + ".log_work")));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test() {
        Driver driver = new Driver(PROFILE_PATH);
        // ...
    }

    @AfterClass
    public static void destruction() {
        try {
            log_work.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

在项目的基本目录中运行命令 mvn test 后,我得到了这个:

[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ uitests-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ uitests-core ---
[INFO] Surefire report directory:
       /var/opt/jenkins/workspace/platform-ui-tests/core/target/surefire-reports

-------------------------------------------------------  
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

我不知道为什么它不运行我的测试。 请帮助我。

最佳答案

默认情况下,Maven 查找名为 *TestTest**TestCase 的测试。您可以将其配置为运行具有其他名称的类,但如果您没有令人信服的理由不这样做,最好遵循约定。将您的类重命名为以 Test 开始或结束的名称,然后再试一次。

查看此答案:Maven does not find JUnit tests to run

关于java - Maven 不运行 selenium 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24551728/

相关文章:

eclipse - 无法从我的原型(prototype)创建 Maven 项目

java - Swagger : Multiple locations for API not being picked up

Selenium IDE : How to check if an element has a focus?

python - 可以设置接受语言 header 但不能设置连接 header 吗? PhantomJS(带有 Python 的 Selenium Webdriver)

java - 在 JDK 1.7 中连接到 https 站点时出现问题

java - 为什么少了回车符?

java - 在spring mvc maven项目中添加外部项目

selenium - JavaScript Protractor (Selenium) 验证输入是否聚焦

java - getStringArrayListExtra 给我一个空值,但我有值

java - Google Guava Eventbus 和 Swing 模态对话框