2015-12-22 12:29:25 +01:00
|
|
|
program DMVCFrameworkTests;
|
|
|
|
|
2021-02-04 14:11:33 +01:00
|
|
|
{$IFDEF CONSOLE_TESTRUNNER}
|
2015-12-22 12:29:25 +01:00
|
|
|
{$APPTYPE CONSOLE}
|
2021-02-04 14:11:33 +01:00
|
|
|
{$ENDIF}
|
|
|
|
{$STRONGLINKTYPES ON}
|
2016-08-24 16:08:18 +02:00
|
|
|
|
2021-03-04 14:29:13 +01:00
|
|
|
|
2015-12-22 12:29:25 +01:00
|
|
|
uses
|
2017-08-20 02:36:22 +02:00
|
|
|
System.SysUtils,
|
2023-01-29 17:29:24 +01:00
|
|
|
System.IOUtils,
|
2024-01-29 23:41:01 +01:00
|
|
|
MVCFramework.Logger,
|
2017-08-20 02:36:22 +02:00
|
|
|
DUnitX.TestFramework,
|
2023-06-06 17:34:24 +02:00
|
|
|
DUnitX.Loggers.XML.NUnit,
|
2021-04-05 19:35:46 +02:00
|
|
|
{$IFDEF CONSOLE_TESTRUNNER}
|
2021-02-04 14:11:33 +01:00
|
|
|
DUnitX.Loggers.Console,
|
2021-04-05 19:35:46 +02:00
|
|
|
{$ENDIF }
|
|
|
|
{$IFDEF TESTINSIGHT}
|
2021-02-04 14:11:33 +01:00
|
|
|
TestInsight.DUnitX,
|
2021-04-05 19:35:46 +02:00
|
|
|
{$ENDIF }
|
2015-12-22 12:29:25 +01:00
|
|
|
FrameworkTestsU in 'FrameworkTestsU.pas',
|
|
|
|
LiveServerTestU in 'LiveServerTestU.pas',
|
|
|
|
BOs in 'BOs.pas',
|
|
|
|
TestServerControllerU in '..\TestServer\TestServerControllerU.pas',
|
2016-05-19 11:22:55 +02:00
|
|
|
RESTAdapterTestsU in 'RESTAdapterTestsU.pas',
|
2021-04-05 19:35:46 +02:00
|
|
|
MVCFramework.Tests.WebModule1 in '..\RESTClient\MVCFramework.Tests.WebModule1.pas' {TestWebModule1: TWebModule},
|
2016-11-13 20:59:21 +01:00
|
|
|
MVCFramework.Tests.RESTClient in '..\RESTClient\MVCFramework.Tests.RESTClient.pas',
|
2017-02-07 14:08:36 +01:00
|
|
|
MVCFramework.Tests.AppController in '..\RESTClient\MVCFramework.Tests.AppController.pas',
|
2017-04-26 14:39:18 +02:00
|
|
|
BusinessObjectsU in '..\..\..\samples\commons\BusinessObjectsU.pas',
|
2017-05-25 16:57:49 +02:00
|
|
|
MVCFramework.SystemJSONUtils in '..\..\..\sources\MVCFramework.SystemJSONUtils.pas',
|
2017-09-08 16:59:02 +02:00
|
|
|
MVCFramework.Serializer.Commons in '..\..\..\sources\MVCFramework.Serializer.Commons.pas',
|
2017-09-24 19:40:40 +02:00
|
|
|
MVCFramework.Patches in '..\..\..\sources\MVCFramework.Patches.pas',
|
|
|
|
JSONRPCTestsU in 'JSONRPCTestsU.pas',
|
2018-10-23 16:18:34 +02:00
|
|
|
MVCFramework.JSONRPC in '..\..\..\sources\MVCFramework.JSONRPC.pas',
|
2018-10-31 01:07:23 +01:00
|
|
|
RandomUtilsU in '..\..\..\samples\commons\RandomUtilsU.pas',
|
2019-03-08 09:33:41 +01:00
|
|
|
MVCFramework.Serializer.JsonDataObjects in '..\..\..\sources\MVCFramework.Serializer.JsonDataObjects.pas',
|
2019-05-19 11:06:03 +02:00
|
|
|
JsonDataObjects in '..\..\..\sources\JsonDataObjects.pas',
|
|
|
|
Serializers.JsonDataObjectsTestU in 'Serializers.JsonDataObjectsTestU.pas',
|
|
|
|
MVCFramework.Tests.Serializer.Entities in '..\..\common\MVCFramework.Tests.Serializer.Entities.pas',
|
2021-04-05 19:35:46 +02:00
|
|
|
MVCFramework.Tests.Serializer.EntitiesModule in '..\..\common\MVCFramework.Tests.Serializer.EntitiesModule.pas' {EntitiesModule: TDataModule},
|
2019-06-25 17:32:30 +02:00
|
|
|
MVCFramework.Tests.Serializer.Intf in '..\..\common\MVCFramework.Tests.Serializer.Intf.pas',
|
2021-04-05 19:35:46 +02:00
|
|
|
MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes in '..\..\..\sources\MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes.pas',
|
2020-05-27 11:28:22 +02:00
|
|
|
ActiveRecordTestsU in 'ActiveRecordTestsU.pas',
|
2020-08-26 01:07:21 +02:00
|
|
|
TestConstsU in 'TestConstsU.pas',
|
2020-09-12 03:24:38 +02:00
|
|
|
MVCFramework.RESTClient.Indy in '..\..\..\sources\MVCFramework.RESTClient.Indy.pas',
|
|
|
|
MVCFramework.RESTClient.Intf in '..\..\..\sources\MVCFramework.RESTClient.Intf.pas',
|
|
|
|
MVCFramework.RESTClient.Commons in '..\..\..\sources\MVCFramework.RESTClient.Commons.pas',
|
2020-12-12 19:26:18 +01:00
|
|
|
MVCFramework.RESTClient in '..\..\..\sources\MVCFramework.RESTClient.pas',
|
2020-12-18 14:41:01 +01:00
|
|
|
PGUtilsU in 'PGUtilsU.pas',
|
|
|
|
MVCFramework.ActiveRecord in '..\..\..\sources\MVCFramework.ActiveRecord.pas',
|
2021-02-04 14:11:33 +01:00
|
|
|
MVCFramework.ActiveRecordController in '..\..\..\sources\MVCFramework.ActiveRecordController.pas',
|
|
|
|
ActiveRecordControllerTestU in 'ActiveRecordControllerTestU.pas',
|
2022-08-01 19:11:42 +02:00
|
|
|
ActiveRecordControllerWebModuleU in 'webmodules\ActiveRecordControllerWebModuleU.pas' {ActiveRecordControllerWebModule: TWebModule},
|
|
|
|
FDConnectionConfigU in '..\..\common\FDConnectionConfigU.pas',
|
|
|
|
StandaloneServerTestU in 'StandaloneServerTestU.pas',
|
|
|
|
StandAloneServerWebModuleTest in 'webmodules\StandAloneServerWebModuleTest.pas' {TestWebModule2: TWebModule},
|
2021-02-15 18:28:45 +01:00
|
|
|
MVCFramework.Commons in '..\..\..\sources\MVCFramework.Commons.pas',
|
2021-04-05 19:35:46 +02:00
|
|
|
MVCFramework.Serializer.JsonDataObjects.CustomTypes in '..\..\..\sources\MVCFramework.Serializer.JsonDataObjects.CustomTypes.pas',
|
2021-09-15 14:24:39 +02:00
|
|
|
MVCFramework.SQLGenerators.Firebird in '..\..\..\sources\MVCFramework.SQLGenerators.Firebird.pas',
|
2021-11-21 19:27:06 +01:00
|
|
|
MVCFramework.Utils in '..\..\..\sources\MVCFramework.Utils.pas',
|
|
|
|
MVCFramework.SQLGenerators.Interbase in '..\..\..\sources\MVCFramework.SQLGenerators.Interbase.pas',
|
|
|
|
MVCFramework.SQLGenerators.MSSQL in '..\..\..\sources\MVCFramework.SQLGenerators.MSSQL.pas',
|
|
|
|
MVCFramework.SQLGenerators.MySQL in '..\..\..\sources\MVCFramework.SQLGenerators.MySQL.pas',
|
|
|
|
MVCFramework.SQLGenerators.PostgreSQL in '..\..\..\sources\MVCFramework.SQLGenerators.PostgreSQL.pas',
|
|
|
|
MVCFramework.SQLGenerators.Sqlite in '..\..\..\sources\MVCFramework.SQLGenerators.Sqlite.pas',
|
|
|
|
MVCFramework.RQL.AST2FirebirdSQL in '..\..\..\sources\MVCFramework.RQL.AST2FirebirdSQL.pas',
|
|
|
|
MVCFramework.RQL.AST2InterbaseSQL in '..\..\..\sources\MVCFramework.RQL.AST2InterbaseSQL.pas',
|
|
|
|
MVCFramework.RQL.AST2MSSQL in '..\..\..\sources\MVCFramework.RQL.AST2MSSQL.pas',
|
|
|
|
MVCFramework.RQL.AST2MySQL in '..\..\..\sources\MVCFramework.RQL.AST2MySQL.pas',
|
|
|
|
MVCFramework.RQL.AST2PostgreSQL in '..\..\..\sources\MVCFramework.RQL.AST2PostgreSQL.pas',
|
|
|
|
MVCFramework.RQL.AST2SQLite in '..\..\..\sources\MVCFramework.RQL.AST2SQLite.pas',
|
2022-08-01 19:11:42 +02:00
|
|
|
MVCFramework.RQL.Parser in '..\..\..\sources\MVCFramework.RQL.Parser.pas',
|
|
|
|
Entities in 'Entities.pas',
|
|
|
|
EntitiesProcessors in 'EntitiesProcessors.pas',
|
2022-10-26 00:11:32 +02:00
|
|
|
MVCFramework.Nullables in '..\..\..\sources\MVCFramework.Nullables.pas',
|
|
|
|
IntfObjectPoolTestU in 'IntfObjectPoolTestU.pas',
|
2023-05-24 10:55:43 +02:00
|
|
|
ObjectPoolTestU in 'ObjectPoolTestU.pas',
|
|
|
|
MVCFramework.DotEnv.Parser in '..\..\..\sources\MVCFramework.DotEnv.Parser.pas',
|
2024-03-21 19:03:35 +01:00
|
|
|
MVCFramework.DotEnv in '..\..\..\sources\MVCFramework.DotEnv.pas',
|
2024-03-28 23:57:59 +01:00
|
|
|
InjectorTestU in 'InjectorTestU.pas',
|
|
|
|
MVCFramework.Container in '..\..\..\sources\MVCFramework.Container.pas';
|
2015-12-22 12:29:25 +01:00
|
|
|
|
|
|
|
{$R *.RES}
|
2021-02-04 14:11:33 +01:00
|
|
|
|
2019-02-24 20:43:06 +01:00
|
|
|
{$IFDEF CONSOLE_TESTRUNNER}
|
2015-12-22 12:29:25 +01:00
|
|
|
|
2021-03-04 14:29:13 +01:00
|
|
|
|
2019-02-24 20:43:06 +01:00
|
|
|
procedure MainConsole();
|
2017-08-20 02:36:22 +02:00
|
|
|
var
|
2019-02-24 20:43:06 +01:00
|
|
|
runner: ITestRunner;
|
|
|
|
results: IRunResults;
|
|
|
|
logger: ITestLogger;
|
2023-01-29 17:29:24 +01:00
|
|
|
OutputNUnitFolder: String;
|
2015-12-22 12:29:25 +01:00
|
|
|
begin
|
2017-08-20 02:36:22 +02:00
|
|
|
try
|
2019-02-24 20:43:06 +01:00
|
|
|
// Check command line options, will exit if invalid
|
2017-08-20 02:36:22 +02:00
|
|
|
TDUnitX.CheckCommandLine;
|
2019-02-24 20:43:06 +01:00
|
|
|
// Create the test runner
|
2017-08-20 02:36:22 +02:00
|
|
|
runner := TDUnitX.CreateRunner;
|
2019-02-24 20:43:06 +01:00
|
|
|
// Tell the runner to use RTTI to find Fixtures
|
2017-08-20 02:36:22 +02:00
|
|
|
runner.UseRTTI := True;
|
2019-02-24 20:43:06 +01:00
|
|
|
// tell the runner how we will log things
|
|
|
|
// Log to the console window
|
|
|
|
logger := TDUnitXConsoleLogger.Create(True);
|
2017-08-20 02:36:22 +02:00
|
|
|
runner.AddLogger(logger);
|
2023-01-29 17:29:24 +01:00
|
|
|
|
2019-02-24 20:43:06 +01:00
|
|
|
// Generate an NUnit compatible XML File
|
2023-01-29 17:29:24 +01:00
|
|
|
if TDUnitX.Options.XMLOutputFile.IsEmpty then
|
|
|
|
begin
|
|
|
|
OutputNUnitFolder := TPath.Combine(
|
|
|
|
TDirectory.GetParent(TDirectory.GetParent(TDirectory.GetParent(AppPath))), 'UnitTestReports');
|
|
|
|
TDirectory.CreateDirectory(OutputNUnitFolder);
|
|
|
|
{$if defined(win32)}
|
|
|
|
TDUnitX.Options.XMLOutputFile := TPath.Combine(OutputNUnitFolder,'dmvcframework_nunit_win32.xml');
|
|
|
|
{$endif}
|
|
|
|
{$if defined(win64)}
|
|
|
|
TDUnitX.Options.XMLOutputFile := TPath.Combine(OutputNUnitFolder, 'dmvcframework_nunit_win64.xml');
|
|
|
|
{$endif}
|
|
|
|
{$if defined(linux64)}
|
|
|
|
TDUnitX.Options.XMLOutputFile := TPath.Combine(OutputNUnitFolder, 'dmvcframework_nunit_linux64.xml');
|
|
|
|
{$endif}
|
|
|
|
end;
|
|
|
|
|
|
|
|
runner.AddLogger(TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile));
|
2019-02-24 20:43:06 +01:00
|
|
|
runner.FailsOnNoAsserts := False; // When true, Assertions must be made during tests;
|
2017-04-29 23:56:56 +02:00
|
|
|
|
2019-02-24 20:43:06 +01:00
|
|
|
// Run tests
|
2017-08-20 02:36:22 +02:00
|
|
|
results := runner.Execute;
|
|
|
|
if not results.AllPassed then
|
|
|
|
System.ExitCode := EXIT_ERRORS;
|
2016-08-24 16:08:18 +02:00
|
|
|
|
2019-02-24 20:43:06 +01:00
|
|
|
{$IFNDEF CI}
|
|
|
|
// We don't want this happening when running under CI.
|
2017-08-20 02:36:22 +02:00
|
|
|
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
|
|
|
|
begin
|
|
|
|
System.Write('Done.. press <Enter> key to quit.');
|
|
|
|
System.Readln;
|
|
|
|
end;
|
2019-02-24 20:43:06 +01:00
|
|
|
{$ENDIF}
|
2017-08-20 02:36:22 +02:00
|
|
|
except
|
|
|
|
on E: Exception do
|
|
|
|
System.Writeln(E.ClassName, ': ', E.Message);
|
|
|
|
end;
|
2019-02-24 20:43:06 +01:00
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2021-03-04 14:29:13 +01:00
|
|
|
|
2019-02-24 20:43:06 +01:00
|
|
|
begin
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
2024-01-29 23:41:01 +01:00
|
|
|
UseConsoleLogger := False;
|
2024-05-09 23:50:01 +02:00
|
|
|
TMVCSqids.SQIDS_ALPHABET := 'axDlw8dRnsPCrbZIAEMFG4TQ6gc3iWtOy9v5NBz0LfSmuKV71JHkUhYpej2Xqo';
|
|
|
|
TMVCSqids.SQIDS_MIN_LENGTH := 6;
|
|
|
|
|
2021-02-04 14:11:33 +01:00
|
|
|
{$IF Defined(CONSOLE_TESTRUNNER)}
|
2019-02-24 20:43:06 +01:00
|
|
|
MainConsole();
|
2021-03-04 14:29:13 +01:00
|
|
|
{$ELSE}
|
|
|
|
{$IF Defined(TESTINSIGHT)}
|
2021-02-04 14:11:33 +01:00
|
|
|
TestInsight.DUnitX.RunRegisteredTests();
|
2021-03-04 14:29:13 +01:00
|
|
|
{$ELSE}
|
|
|
|
raise Exception.Create('No Runner defined');
|
|
|
|
{$ENDIF}
|
2019-02-24 20:43:06 +01:00
|
|
|
{$ENDIF}
|
|
|
|
|
2015-12-22 12:29:25 +01:00
|
|
|
end.
|