Mavenを使用していくつかのセレン自動テストを実行しています。私がEclipseでデバッグしているときは、通常はtesting.xmlとRun As> TestNG Suiteを右クリックするだけです。しかし、ジェンキンスで走ることはmvn test
を使って走らせる必要があります。私がいることを実行したときしかし、私はいくつかのエラーを取得:Maven: 'パッケージは存在しません'(その他のエラー)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project ecom: Compilation failure: Compilation failure:
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[15,43] package com.company.automation.ecom.pages does not exist
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[16,43] package com.company.automation.ecom.pages does not exist
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[110,13] cannot find symbol
[ERROR] symbol: class Header
[ERROR] location: class com.company.automation.ecom.HelperMethods
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[110,62] cannot find symbol
[ERROR] symbol: class Header
[ERROR] location: class com.company.automation.ecom.HelperMethods
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[113,9] cannot find symbol
[ERROR] symbol: class SignIn
[ERROR] location: class com.company.automation.ecom.HelperMethods
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[113,58] cannot find symbol
[ERROR] symbol: class SignIn
[ERROR] location: class com.company.automation.ecom.HelperMethods
は、私はファイルが存在している知っている、私はTestNGのスイートのすべてが問題なく動作しますとして実行したとき。また、私はこれを取得されjava -version
実行すると:
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
私はそれがどこかの構成の問題だけど、私はそれを把握するためのmaven/javaの構成について十分に知りません。 Mavenが私に言っているファイルは消えてしまいました。ファイルは絶対に存在します。
<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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value>com.kirklands.automation.ecom.retry.MyTestListenerAdapter</value>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<groupId>com.kirklands.automation</groupId>
<artifactId>ecom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ecom</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
プロジェクト構造:ここに私のpom.xmlファイルがある
src/main/java
{package com.company.automation.ecom}
CreditCard.java
HelperMethods.java
src/test/java
{package com.company.automation.ecom.pages}
Header.java
SignIn.Java
(etc...)
{package com.company.automation.ecom.tests}
HeaderTests.java
(etc...)
ローカル環境で 'mvn test'を実行するときに同じ問題がありますか? – alayor
うん。コマンドライン(pom.xmlファイルと同じフォルダ内)から 'mvn test'を実行した場合、またはEclipseとRun As> Maven Testでプロジェクトを右クリックすると、同じ出力が得られます。 – kroe761
javaのソース/ターゲット1.8を使用するようにmaven-compiler-pluginを切り替える必要があります。デフォルトは1.5です。 https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.htmlを参照してください –