diff --git a/fcl/fpcunit/demo/consolerunner/suiteconfig.pp b/fcl/fpcunit/demo/consolerunner/suiteconfig.pp index 7a33745eba..95ee0a2d6a 100644 --- a/fcl/fpcunit/demo/consolerunner/suiteconfig.pp +++ b/fcl/fpcunit/demo/consolerunner/suiteconfig.pp @@ -20,15 +20,8 @@ unit suiteconfig; interface uses - fpcunittests, testregistry; - -procedure RegisterUnitTests; + fpcunittests, moneytest; implementation -procedure RegisterUnitTests; -begin - RegisterTests([TTestCaseTest, TTestSuiteTest, TAssertTest, TListenerTest]); -end; - end. diff --git a/fcl/fpcunit/demo/consolerunner/testrunner.pp b/fcl/fpcunit/demo/consolerunner/testrunner.pp index 172818299c..c53e3793b7 100644 --- a/fcl/fpcunit/demo/consolerunner/testrunner.pp +++ b/fcl/fpcunit/demo/consolerunner/testrunner.pp @@ -17,8 +17,7 @@ **********************************************************************} program testrunner; uses - custapp, classes, SysUtils, fpcunit, suiteconfig, testreport, - testregistry; + custapp, classes, SysUtils, fpcunit, suiteconfig, testreport; Const ShortOpts = 'alh'; @@ -125,7 +124,6 @@ Var App : TTestRunner; begin - RegisterUnitTests; App:=TTestRunner.Create(Nil); App.Initialize; App.Title := 'FPCUnit Console Test Case runner.'; diff --git a/fcl/fpcunit/exampletests/fpcunittests.pp b/fcl/fpcunit/exampletests/fpcunittests.pp index 06e554c243..51e8e8242f 100644 --- a/fcl/fpcunit/exampletests/fpcunittests.pp +++ b/fcl/fpcunit/exampletests/fpcunittests.pp @@ -20,7 +20,7 @@ unit fpcunittests; interface uses - SysUtils, Classes, fpcunit, testutils; + SysUtils, Classes, fpcunit, testutils, testregistry; type @@ -48,6 +48,8 @@ type procedure TestExtractMethods; end; + { TAssertTest } + TAssertTest = class(TTestCase) private Fa, @@ -78,6 +80,7 @@ type procedure TestNull; procedure TestNullInterface; procedure TestNotNull; + procedure TestNotNullWithInterface; procedure TestNotNullInterface; procedure TestFailEqualsInt; procedure TestFailEqualsInt64; @@ -310,6 +313,15 @@ begin obj.Free; end; +procedure TAssertTest.TestNotNullWithInterface; +var + obj: TMyIntfObj; +begin + obj := TMyIntfObj.Create; + AssertNotNull(obj); + obj.Free; +end; + procedure TAssertTest.TestNotNullInterface; var myintf: IMyIntf; @@ -732,4 +744,8 @@ begin AssertTrue(True); end; +initialization + + RegisterTests([TTestCaseTest, TTestSuiteTest, TAssertTest, TListenerTest]); + end. diff --git a/fcl/fpcunit/exampletests/moneytest.pp b/fcl/fpcunit/exampletests/moneytest.pp index e444a06d96..3f452e9c7a 100644 --- a/fcl/fpcunit/exampletests/moneytest.pp +++ b/fcl/fpcunit/exampletests/moneytest.pp @@ -5,7 +5,7 @@ unit moneytest; interface uses - Classes, SysUtils, fpcunit, money; + Classes, SysUtils, fpcunit, money, testregistry; type @@ -290,5 +290,9 @@ begin AssertTrue('expected ' + mb.toString + ' but was ' + (FMB2 *2).toString, (FMB2 * 2).equals(mb)); end; +initialization + + RegisterTests([TMoneyTest]); + end. diff --git a/fcl/fpcunit/fpcunit.pp b/fcl/fpcunit/fpcunit.pp index 2a4cd269ef..b8ad076c9f 100644 --- a/fcl/fpcunit/fpcunit.pp +++ b/fcl/fpcunit/fpcunit.pp @@ -90,14 +90,14 @@ type class procedure AssertNotSame(Expected, Actual: Pointer); overload; class procedure AssertNotNull(const AMessage: string; AObject: TObject); overload; class procedure AssertNotNull(AObject: TObject); overload; - class procedure AssertNotNull(const AMessage: string; AInterface: IInterface); overload; - class procedure AssertNotNull(AInterface: IInterface); overload; + class procedure AssertNotNullIntf(const AMessage: string; AInterface: IInterface); overload; + class procedure AssertNotNullIntf(AInterface: IInterface); overload; class procedure AssertNotNull(const AMessage: string; APointer: Pointer); overload; class procedure AssertNotNull(APointer: Pointer); overload; class procedure AssertNull(const AMessage: string; AObject: TObject); overload; class procedure AssertNull(AObject: TObject); overload; - class procedure AssertNull(const AMessage: string; AInterface: IInterface); overload; - class procedure AssertNull(AInterface: IInterface); overload; + class procedure AssertNullIntf(const AMessage: string; AInterface: IInterface); overload; + class procedure AssertNullIntf(AInterface: IInterface); overload; class procedure AssertNull(const AMessage: string; APointer: Pointer); overload; class procedure AssertNull(APointer: Pointer); overload; class procedure AssertNotNull(const AMessage, AString: string); overload; @@ -518,12 +518,12 @@ begin AssertNotNull('', AObject); end; -class procedure TAssert.AssertNotNull(const AMessage: string; AInterface: IInterface); +class procedure TAssert.AssertNotNullIntf(const AMessage: string; AInterface: IInterface); begin AssertTrue(AMessage, (AInterface <> nil)); end; -class procedure TAssert.AssertNotNull(AInterface: IInterface); +class procedure TAssert.AssertNotNullIntf(AInterface: IInterface); begin AssertNotNull('', AInterface); end; @@ -548,12 +548,12 @@ begin AssertNull('', AObject); end; -class procedure TAssert.AssertNull(const AMessage: string; AInterface: IInterface); +class procedure TAssert.AssertNullIntf(const AMessage: string; AInterface: IInterface); begin AssertTrue(AMessage, (AInterface = nil)); end; -class procedure TAssert.AssertNull(AInterface: IInterface); +class procedure TAssert.AssertNullINtf(AInterface: IInterface); begin AssertNull('', AInterface); end; diff --git a/fcl/fpcunit/tests/asserttest.pp b/fcl/fpcunit/tests/asserttest.pp index 75d9823b3e..b2d23a58a9 100644 --- a/fcl/fpcunit/tests/asserttest.pp +++ b/fcl/fpcunit/tests/asserttest.pp @@ -20,7 +20,7 @@ unit asserttest; interface uses - fpcunit; + fpcunit, testregistry; type @@ -210,5 +210,9 @@ begin Fail('Error: Objects are the same!'); end; +initialization + + RegisterTests([TAssertTest]); + end. diff --git a/fcl/fpcunit/tests/suitetest.pp b/fcl/fpcunit/tests/suitetest.pp index de0b6b3c1d..eb18615062 100644 --- a/fcl/fpcunit/tests/suitetest.pp +++ b/fcl/fpcunit/tests/suitetest.pp @@ -20,7 +20,7 @@ unit suitetest; interface uses - fpcunit, testreport; + fpcunit, testreport, testregistry; type @@ -218,5 +218,9 @@ begin end; end; +initialization + + RegisterTests([TSuiteTest]); + end.