我一直在尝试设置 Jenkins 与我的 C# 项目一起进行自动化测试和代码覆盖。我有测试工作和代码覆盖文件生成和转换使用CoverageConverter.exe
(不使用任何插件 - 只是直接批处理文件和原始 EXE),但是当我添加 MSTest 构建后步骤以获取要在 Jenkins 中显示的数据时,我收到以下错误:
[MSTEST-PLUGIN] Processing test results in file(s) **/*.trx
MSTest: D:\Jenkins\jobs\Framework\workspace\TestResults\james_CD 2016-03-18 20_05_13.trx
ERROR: Step ‘Publish MSTest test result report’ aborted due to exception:
java.lang.NoClassDefFoundError: hudson/maven/MavenBuild
at hudson.plugins.emma.EmmaPublisher.perform(EmmaPublisher.java:103)
at hudson.plugins.mstest.MSTestPublisher.perform(MSTestPublisher.java:134)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
at hudson.model.Run.execute(Run.java:1763)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: java.lang.ClassNotFoundException: hudson.maven.MavenBuild
at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1376)
at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1326)
at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1079)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 11 more
尽管出现错误,但“测试结果趋势”图表显示在项目页面上并且似乎是正确的,并且有一个“代码覆盖率趋势”部分,但图像链接已损坏。
我正在使用以下批处理代码段运行测试和代码覆盖率:
@ECHO "`nRunning tests`n---------------------------"
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" TestFramework\bin\Release\TestFramework.dll /EnableCodeCoverage /Settings:TestFramework\Settings.testsettings /Logger:trx
@ECHO %ERRORLEVEL%
REM @IF %ERRORLEVEL% NEQ 0 EXIT 1
@ECHO "`n`nConverting code coverage results`n---------------------------"
@IF EXIST emma\. rd emma /s /q >nul
md emma
del emma\temp.coverage /Q >nul
for /R TestResults %%f in (*.coverage) do copy "%%f" emma\temp.coverage /B /Y
"C:\Program Files\JenkinsUtilities\CoverageConverter\CoverageConverter.exe" /in:emma\temp.coverage /out:emma\coverage.xml /xsl:"C:\Program Files\JenkinsUtilities\MSTestCoverageToEmma.xsl"
goto END
我从另一个正在运行类似项目的 Jenkins 系统复制了基本流程,但找不到系统之间的任何相关差异。
我已经尝试过: 1. 更新 Java 2. 更新 Jenkins 3. 卸载并重新安装 MSBuild、MSTest、MSTest Runner 和 VSTest Runner 以及 Maven 集成插件。
我觉得我在这一点上真的很接近,但我对 Java 的经验很少,所以我现在无法纠正这个错误。谁能帮我诊断ClassNotFoundException?