Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program UnitTest1;
- {$IFDEF CONSOLE_TESTRUNNER}
- {$APPTYPE CONSOLE}
- {$ENDIF}
- uses
- Forms, Classes, SysUtils,
- TestFramework,
- GUITestRunner,
- TextTestRunner;
- {$R *.RES}
- type
- TIntTestCase = class(TTestCase)
- private
- FValue: Integer;
- public
- constructor Create(AValue: Integer); reintroduce;
- function GetName: string; override;
- published
- procedure Run;
- end;
- { TIntTestCase }
- constructor TIntTestCase.Create(AValue: Integer);
- begin
- inherited Create('Run');
- FValue := AValue;
- end;
- function TIntTestCase.GetName: string;
- begin
- Result := Format('Run_%.3d', [FValue]);
- end;
- procedure TIntTestCase.Run;
- begin
- Check(FValue mod 2 = 0, Format('%d is not an even value', [FValue]));
- end;
- procedure RegisterTests;
- const
- TestCount = 10;
- ValueHigh = 1000;
- var
- I: Integer;
- begin
- Randomize;
- for I := 0 to TestCount - 1 do
- RegisterTest(TIntTestCase.Create(Random(ValueHigh) + 1));
- end;
- begin
- Application.Initialize;
- RegisterTests;
- if IsConsole then
- TextTestRunner.RunRegisteredTests
- else
- GUITestRunner.RunRegisteredTests;
- end.
Add Comment
Please, Sign In to add comment