Mavenでテストを実行しようとしていますが、ビルドプロセス中にエラーが発生しています。私はこれを解決するために最後の2日間試しましたが、現在はアイデアが不足しています。私は自分のPOMが正しい依存関係を持っていること、そしてJenkinsの外でテストが動作していることを確認しました。Mavenテスト、Jenkins Test Suiteの失敗java.lang.NoClassDefFoundError -
OS - Windows Serverの2012 R2 ブラウザ - Firefoxの50.1.0 セレンドライバ - 3.0.1
ジェンキンスエラーログ
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
[[email protected]] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
09:48:46.025 [main] INFO - START com.Ceridian.tests.HB01.CD01
09:48:46.119 [main] WARN - SKIP com.Ceridian.tests.HB01.CD01
09:48:46.119 [main] ERROR - Unable to take screenshot - java.lang.NullPointerException
09:48:46.135 [main] INFO - START com.Ceridian.tests.HB01.CD02
09:48:46.150 [main] WARN - SKIP com.Ceridian.tests.HB01.CD02
09:48:46.150 [main] ERROR - Unable to take screenshot - java.lang.NullPointerException
Tests run: 4, Failures: 2, Errors: 0, Skipped: 2, Time elapsed: 2.688 sec <<< FAILURE! - in TestSuite
configureBrowserBeforeTest(com.Ceridian.tests.HB01) Time elapsed: 2 sec <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.SessionNotFoundException
configureBrowserBeforeTest(com.Ceridian.tests.HB01) Time elapsed: 0.093 sec <<< FAILURE!
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.SessionNotFoundException
Results :
Failed tests:
com.Ceridian.tests.HB01.configureBrowserBeforeTest(com.Ceridian.tests.HB01)
Run 1: HB01>BaseTest.configureBrowserBeforeTest:102 » NoClassDefFound org/openqa/sele...
Run 2: HB01>BaseTest.configureBrowserBeforeTest:102 » NoClassDefFound org/openqa/sele...
ジェンキンスが失敗
[JENKINS] Recording test results
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.354 s
[INFO] Finished at: 2017-01-06T09:48:52+00:00
[INFO] Final Memory: 34M/442M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project Frameworkium: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Program Files (x86)\Jenkins\jobs\FirstAttempt\workspace\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project Frameworkium: There are test failures.
POMファイルをビルドします
<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>com.frameworkium</groupId>
<artifactId>Frameworkium</artifactId>
<packaging>jar</packaging>
<version>2.0.5</version>
<name>Frameworkium</name>
<description>
A template designed to get up and running quickly with Selenium and Appium.
</description>
<url/>
<inceptionYear/>
<organization/>
<licenses/>
<developers/>
<contributors/>
<prerequisites>
<maven>3.1.1</maven>
</prerequisites>
<modules/>
<scm/>
<issueManagement/>
<ciManagement/>
<distributionManagement/>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<env.config>local</env.config>
<threads>1</threads>
<groups/>
<aspectj.version>1.8.9</aspectj.version>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>com.github.Frameworkium</groupId>
<artifactId>frameworkium-core</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<parallel>methods</parallel>
<threadCount>${threads}</threadCount>
<systemProperties>
<screenshotDirectory>
${project.build.directory}/screenshots
</screenshotDirectory>
<allure.issues.tracker.pattern>
/browse/%s
</allure.issues.tracker.pattern>
</systemProperties>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<includes>
<include>**/Test*.java</include>
<include>**/*Tests*.java</include>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
<include>**/*TestCase.java</include>
</includes>
<groups>${groups}</groups>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
ジェンキンスログは、私がここに
@BeforeMethod(
alwaysRun = true
)
public static void configureBrowserBeforeTest(Method testMethod) {
try {
((Driver)driver.get()).resetBrowser();
wait.set(newDefaultWait());
userAgent = determineUserAgent();
initialiseNewScreenshotCapture(testMethod);
} catch (Exception var2) {
logger.error("Failed to configure browser.", var2);
throw new RuntimeException("Failed to configure browser.", var2);
}
}
私はビルドの私の設定画面を用意しましたことだけ含まれますので、失敗の可能性のある理由として私@BeforeMethodに言及しているようです。
私が何かを見逃してしまった場合にお詫び申し上げます。
追加の依存関係
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
を更新しました
org.openqaのアーティファクトのように見えません。 Mavenの依存関係ツリーを調べて、あなたの依存関係の1つがあなたに届いていることを確認してください。私はテスト範囲としてすべてのそれらのセレンの依存関係をマークします。また、パッケージが存在していることを確認するためにパッケージをチェックしてください。 – duffymo
ご返信ありがとうございます。 CI環境を設定するのは初めてのことですが、基本的な質問をしていただきありがとうございます。 Maven DependencyツリーはMavenプラグインですか?ジェンキンスを通じてどうやって確認していますか?私のPOMがジェンキンスの外でOKの依存関係を引っ張っているのであれば、どうしてそれがジェンキンスと一緒に行方不明になることがありますか?あなたはパッケージが存在していることを確認するためにパッケージをチェックして、チェックする場所を詳しく説明できると言いますか?私はC:のJenkinsフォルダのどこかを意味すると思います助けを感謝する:) – OhAye
ジェンキンスの外のチェック物事はありません。パッケージを見てください。私はIntelliJを使用して依存関係のツリーを確認します – duffymo