【问题标题】:Maven doesn't run selenium testMaven 不运行硒测试
【发布时间】:2014-08-24 11:03:41
【问题描述】:

您好,我正在尝试使用 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

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

【问题讨论】:

标签: java maven selenium junit


【解决方案1】:

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

也请参阅此答案:Maven does not find JUnit tests to run

【讨论】:

    猜你喜欢
    • 2012-02-11
    • 2012-04-06
    • 2015-06-15
    • 1970-01-01
    • 1970-01-01
    • 2013-06-30
    • 1970-01-01
    • 2012-06-19
    • 2021-10-19
    相关资源
    最近更新 更多