c# vstest.console.exe is taking too much time to run unit tests

631 views Asked by At

I have big project written in c# wpf, also I have continuous integration in jenkins that build the project and run unit test after each commit.

The build is incremental. I have problem that the CI is so slow because of the unit test

Time taken to build the whole solution: 7min

Time taken to run all the unit test( ~350 unit test): 10min I use this script:

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
        )
    )

is there a way to run the test dll only for projects that changed by commit? because my build is incremental I want to reduce the time of running those unit tests, how I can do that? Thanks

0

There are 0 answers