gpt4 book ai didi

java - 构建 testng 项目时的 Jenkins InspirationTargetException

转载 作者:行者123 更新时间:2023-12-02 03:49:18 25 4
gpt4 key购买 nike

我有一台 jenkins 机器,我想用它来构建 testng 的测试,他将通过我的存储库获取该测试。这一切都有效,但是当他开始运行我的测试时我收到此错误。

-------------------------------------------------------
T E S T S
-------------------------------------------------------
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.UnsupportedClassVersionError: be/contribute/automation/AbstractTest : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:98)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:78)
at org.apache.maven.surefire.testng.TestNGProvider.scanClassPath(TestNGProvider.java:165)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:108)
... 9 more

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

这是我的 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.contribute.automation</groupId>
<artifactId>automationFramework</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>automationFramework</name>

<properties>
<testng.version>6.9.4</testng.version>
<selenium.version>2.46.0</selenium.version>
</properties>

<build>
<defaultGoal>integration-test</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<!-- <configuration>
<suitXmlFiles>
<suiteXmlFile>TestRun.xml</suiteXmlFile>
</suitXmlFiles>
</configuration>-->
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
</project>

任何人都可以说我做错了什么或者我需要编辑什么才能让这一切顺利进行吗?

最佳答案

您收到的异常 (java.lang.UnsupportedClassVersionError) 是由于用于编译代码的 Java 版本与用于执行代码的 Java 版本之间不兼容而发生的.

显然您的代码是使用 Java 8(版本 52.0)编译的,现在您尝试使用 Java 7 运行它。

检查您的 Jenkins Java 版本是否与编译代码的机器的 Java 版本相同。

关于java - 构建 testng 项目时的 Jenkins InspirationTargetException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36013394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com