gpt4 book ai didi

java - 与 Maven 一起运行的 Jenkins Junit 案例问题

转载 作者:行者123 更新时间:2023-11-30 08:54:14 24 4
gpt4 key购买 nike

从上周开始,我遇到了一个关于 jenkins 中的 junit 测试用例的奇怪问题,如果我尝试从命令提示符运行并执行 junit 测试用例但在运行时我说奇怪的相同工作区对于 jenkin,由于不支持测试用例 UNC 路径,它会为 junit 抛出错误。默认为 Windows 目录。也找不到类。错误是:

 [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ projectdemo ---
[INFO] Surefire report directory: MBP\workspace\target\surefire-reports
MBP\workspace'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: 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.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
... 4 more
Caused by: java.lang.RuntimeException: Unable to create test class 'com.db.proj.demo.services.integration.impl.test.TestImpl'
at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:109)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:78)
at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:164)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:86)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.db.proj.demo.services.integration.impl.test.TestImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
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:105)
... 12 more
[ERROR] There are test failures.

Please refer to MBP\workspace\target\surefire-reports for the individual test results.

它在几天前工作正常,但如果需要为 junit 传递 jenkin 声明任何其他内容,我不会这样做。

注意:我已经在 jenkin 中声明了一个 maven 项目,使用 svn 作为源代码库。

最佳答案

依我拙见,错误很明显:java.lang.ClassNotFoundException: com.db.proj.demo.services.integration.impl.test.TestImpl

您应该在您的 svn 存储库中修改已提交的 TestImpl 类更改。如果问题仍然存在,请尝试将您的 Jenkins 项目配置为您确定它过去可以正常编译的旧版本。循序渐进,你很可能会发现引入了什么问题,但它必然与非提交类有关。

关于java - 与 Maven 一起运行的 Jenkins Junit 案例问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29485616/

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