I have an application which I'm testing using Selenium WebDriver and TestNG. I have 15 methods which are marked with @Test annotations. When i'm starting tests clicking on tests with mouse right button all 15 tests completing successfully, but when I'm starting tests using command-line with "mvn test" Maven output is:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.company.tests:Selenium:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 43, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Selenium 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Selenium ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\ai\mysel\alexander-aut-webdriver-selenium\fwk\java\trunk\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Selenium ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Selenium ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Selenium ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 5 source files to C:\Users\ai\mysel\alexander-aut-webdriver-selenium\fwk\java\trunk\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.5:test (default-test) @ Selenium ---
[INFO] Surefire report directory: C:\Users\ai\mysel\alexander-aut-webdriver-selenium\fwk\java\trunk\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Starting ChromeDriver (v2.9.248315) on port 21287
Tests run: 22, Failures: 2, Errors: 0, Skipped: 12, Time elapsed: 26.223 sec <<< FAILURE!
Results :
Failed tests:
openLoginPage(com.company.selenium.tests.LoginTest)
openRegistrationPage(com.company.selenium.tests.RegistrationTest)
Tests run: 22, Failures: 2, Errors: 0, Skipped: 12
openLoginPage() and openRegistration even not marked as @Test, they marked with @BeforeMethod annotation
why there are 22 tests when i running in maven? how can i fix this so maven will run all 15 tests
I'd recommend you the following: 1) take a look at your project POM.xml : http://gyazo.com/7a9015de5e0f9801848e9ecba62a18e9 and make sure you've got following dependencies in your POM.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.41.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.41.0</version>
</dependency>
......
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
..........
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
2) 2nd step is to navigate to your project folder (exact one where POM.xml file is located) . Open command window and run there
mvn clean test
http://gyazo.com/9526e807be8a6fc4ad6211d4aab19b5c
3) also pay attention to build/plugins section in POM.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Probably the root cause is in <version>2.3.2</version>
this one as far as I can understand from you log provided:
ests:Selenium:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 43, column 21
Hope this helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.