Ich benutze mehrere automatisierte Selen-Tests mit Maven. Beim Debuggen in Eclipse klicke ich normalerweise einfach mit der rechten Maustaste auf testing.xml und Ausführen als> TestNG Suite. Aber das Laufen in Jenkins muss mit mvn test
ausgeführt werden. Aber wenn ich laufe, dass, erhalte ich mehrere Fehler:Maven: 'Paket existiert nicht' (und andere Fehler)
[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
weiß, dass ich die Dateien vorhanden sind, wenn ich als TestNG Suite alles ohne Probleme funktioniert laufen. Außerdem, wenn ich laufe, welche java -version
ich diese:
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)
Ich weiß, es ist ein Konfigurationsproblem irgendwo, aber ich weiß nicht genug über Maven/java-Konfiguration, um es herauszufinden. Die Dateien, die Maven mir erzählt, sind meine Dateien, und sie sind absolut präsent. Hier ist meine pom.xml-Datei:
<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>
Projektstruktur:
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...)
Haben Sie das gleiche Problem, wenn Sie 'mvn test' in Ihrer lokalen Umgebung ausführen? – alayor
Ja. Wenn ich 'mvn test' von der Kommandozeile (im selben Ordner wie meine pom.xml-Datei) ODER wenn ich mit der rechten Maustaste auf das Projekt in Eclipse und Run As> Maven Test gehe, bekomme ich die gleiche Ausgabe. – kroe761
Sie müssen Ihr Maven-Compiler-Plugin wechseln, um Source/Target 1.8 für Java zu verwenden. Standard ist 1,5. Siehe https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html –