我有一些Selenium Webdriver测试,我想使用mvn -test从命令行运行。问题是我可以清理,构建和编译,没有问题,但没有运行测试。我没有得到任何与测试相关的消息,例如“没有测试可以运行。”
我的junit测试遵循*测试类命名约定。
我将我的POM与另一个运行测试没有问题的项目进行了比较,它是相同的,禁止项目名称和位置。有效的项目在我的用户目录下,但没有的项目直接在c:\
下面我不够精通能够用mn -x调试这个,所以任何帮助都非常感激。这是我的POM:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT; 4.0.0
<groupId>websiteRegression</groupId>
<artifactId>websiteRegression</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>websiteRegression</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Full access to hamcrest matchers
see https://github.com/hamcrest/JavaHamcrest
you can add hamcrest-core for the foundation matchers
and you can add hamcrest-library for more extensive libraries
or you can add hamcrest-all for everything if you don't want to think about it
-->
<!-- Junit 4.11 needs hamcrest 1.3 -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<!-- if we use junit-dep then we can bring in the full hamcrest -->
<!-- JUnit 4.10 depends on hamcrest 1.1 -->
<!--
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
</dependency>
-->
<!-- Use JUnit as our test framework -->
<!-- this gives us basic hamcrest -->
<!-- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency> -->
<!-- if I want to use a version of hamcrest above 1.1 with 4.10 then I need an exclusion -->
<!--
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
-->
<dependency>
<!-- bring in the full selenium deploy
we could be more selective and bring
only what we need -->
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.39.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<!-- I have added the build section to support importing into
IntelliJ automatically without throwing errors about wrong Java
Version. This basically says the source requires at least Java 1.7
and use a compiler that outputs Java 1.7 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>anyBrowserTests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>firefoxTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
<include>**/FireFoxOnlySuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ieTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>chromeTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>operaTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>failingOperaTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>failingIETests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>failingChromeTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</reporting>
编辑:好的,我发现配置文件存在问题 - 修复了!
答案 0 :(得分:0)