我有用 c# wpf 编写的大项目,我也在 jenkins 中持续集成,构建项目并在每次提交后运行单元测试。
构建是增量的。由于单元测试,我有一个问题,CI 太慢了
构建整个解决方案所需的时间:7 分钟
运行所有单元测试所需的时间(~350 个单元测试):10 分钟我使用这个脚本:
for /D %%f in (*.Tests) do call :run_mstest %%f
echo exit flag is %EXIT_FLAG%
echo ----------------------------------------------------------------------
if "%EXIT_FLAG%" == "0" (
echo Unit Test ended OK.
) else (
set ERROR_CODE= 1
echo Unit Test ended NOT OK!
)
goto :end
:run_mstest
Echo Running %1
set current_test=%1
set current_test_result_name=%current_test:.=%Result
set dll_name=%1\bin\%Configuration%\%1.dll
if not exist "%dll_name%" (
set dll_name=%1\bin\%1.dll
)
if not exist "%dll_name%" (
goto :error1
) else (
echo call vstest.console.exe" /PLATFORM:X64 %dll_name%
call vstest.console.exe" /PLATFORM:X64 %dll_name%
if ERRORLEVEL 1 (
echo FAILED
) else (
echo PASSED
)
)
有没有办法只为提交更改的项目运行测试 dll?因为我的构建是增量的,所以我想减少运行这些单元测试的时间,我该怎么做?谢谢