Здравствуйте.
В автотестировании новичок совсем.
Возник такой вопрос.
Написал несколько тестов на Java.
Использую Eclipse + Selenium + PageFactory + TestNg + Maven
Тесты запускаются как надо, никаких проблем.
Стало необходимо собирать их в TeamCity.
Для этого в свой файл pom.xml добавил вот такое:
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
Теперь при запуске Maven проекта пишет ошибку:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running payture.tests.BasicTestCase
Configuring TestNG with: TestNG652Configurator
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.539 sec <<< FAILURE! - in payture.tests.BasicTestCase
tearDown(payture.tests.BasicTestCase) Time elapsed: 0.366 sec <<< FAILURE!
java.lang.NullPointerException: null
at payture.tests.BasicTestCase.tearDown(BasicTestCase.java:37)
Results :
Failed tests:
BasicTestCase.tearDown:37 NullPointer
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.768s
[INFO] Finished at: Mon Jun 02 17:41:07 MSK 2014
[INFO] Final Memory: 8M/117M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project Payture: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\starostin\workspace\Payture\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Почему он вдруг открывает файл BasicTestCase? В testng.xml указаны совсем другие package:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
<test name="Test">
<packages>
<package name="payture.LoginPage.tests"/>
<!--package name="payture.HomePage.tests"/-->
</packages>
</test>
</suite>
Вот сам pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Payture</groupId>
<artifactId>Payture</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.41.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
</project>
На всякий случай код базового класса для тестов (BasicTestCase):
public class BasicTestCase {
protected static WebDriver driver;
public UserData admin = new UserData("test", "123");
protected WebDriver getWebDriver() {
if (driver == null) {
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(Long.parseLong(ConfigProperties.getProperty("imp.wait")), TimeUnit.SECONDS);
}
return driver;
}
@AfterTest
public void tearDown() throws Exception {
driver.quit();
}
}