Skip to content

Instantly share code, notes, and snippets.

@frantic
Last active January 26, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frantic/4642454 to your computer and use it in GitHub Desktop.
Save frantic/4642454 to your computer and use it in GitHub Desktop.
How to run DUnit tests as a part of your continuous integration process?
...
begin
Application.Initialize;
if IsConsole then
// You'll have to add rxbHaltOnFailures param hre
// (Delphi doesn't do it automatically)
with TextTestRunner.RunRegisteredTests(rxbHaltOnFailures) do
Free
else
GUITestRunner.RunRegisteredTests;
end.
@echo off
rem TODO #1: Check the path to MSBuild (you might have different .NET version)
set msb=c:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
rem TODO #2: Following path depends on your RAD Studio version
set path=C:\Program Files\Embarcadero\RAD Studio\7.0\bin;%path%
call rsvars.bat
rem TODO #3: Set location of your Test Project dproj-file
set dunit_prj=%~dp0src\MyTests.dproj
rem TODO #4: Set location where your compiled Test Project binary will be located
set dunit_bin=%~dp0bin\MyTests.exe
echo Building tests...
del %dunit_bin% 2> NUL
%msb% %dunit_prj% /p:DCC_Define="CONSOLE_TESTRUNNER" > last-build-log.txt
if not exist %dunit_bin% goto buildfailed
cls
%dunit_bin%
if %errorlevel% neq 0 goto testsfailed
goto testspassed
:buildfailed
color 0c
echo Build failed. Check error logs in last-build-log.txt
type last-build-log.txt
goto done
:testsfailed
color 0c
echo Tests failed
goto done
:testspassed
color 0a
goto done
:done
pause
color 0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment