Skip to content

Commit ea3683f

Browse files
Minot change to allow run filter option to work with testcase methods
1 parent 62b7ab8 commit ea3683f

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Source/DUnitX.Extensibility.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ interface
7676
procedure SetMaxTime(const AValue: cardinal);
7777
function GetTimedOut: Boolean;
7878
procedure SetTimedOut(const AValue: Boolean);
79+
function GetIsTestCase : boolean;
7980

8081
property Name : string read GetName;
8182
property FullName : string read GetFullName;
@@ -85,6 +86,7 @@ interface
8586
property Fixture : ITestFixture read GetTestFixture;
8687
property Ignored : boolean read GetIgnored;
8788
property IgnoreReason : string read GetIgnoreReason;
89+
property IsTestCase : boolean read GetIsTestCase;
8890
property TestMethod : TTestMethod read GetTestMethod;
8991
property IgnoreMemoryLeaks : Boolean read GetIgnoreMemoryLeaks write SetIgnoreMemoryLeaks;
9092
property MaxTime: cardinal read GetMaxTime write SetMaxTime;

Source/DUnitX.Filters.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ function TNameFilter.Match(const test: ITest): Boolean;
297297

298298
if not result then
299299
result := FNames.IndexOf(test.FullName) <> -1;
300+
//hacky way to allow filtering on test cases.
301+
if (not result) and test.IsTestCase then
302+
result := FNames.IndexOf(test.MethodName) <> -1;
300303
end;
301304

302305
{ TAndFilter }

Source/DUnitX.Test.pas

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ TDUnitXTest = class(TWeakReferencedObject, ITest, ITestInfo, ISetTestResult, I
8383
procedure SetMaxTime(const AValue: cardinal);
8484
function GetTimedOut: Boolean;
8585
procedure SetTimedOut(const AValue: Boolean);
86+
function GetIsTestCase : boolean;virtual;
87+
8688

8789
//ITestInfo
8890
function GetActive : boolean;
@@ -128,6 +130,7 @@ TDUnitXTestCase = class(TDUnitXTest, ITestExecute)
128130
FRttiMethod : TRttiMethod;
129131
FInstance : TObject;
130132
protected
133+
function GetIsTestCase : boolean;override;
131134
function GetName: string; override;
132135
procedure Execute(const context : ITestExecuteContext); override;
133136
procedure UpdateInstance(const fixtureInstance : TObject);override;
@@ -246,6 +249,11 @@ function TDUnitXTest.GetIgnoreReason: string;
246249
result := FIgnoreReason;
247250
end;
248251

252+
function TDUnitXTest.GetIsTestCase: boolean;
253+
begin
254+
result := false;
255+
end;
256+
249257
function TDUnitXTest.GetMethodName: string;
250258
begin
251259
result := FMethodName;
@@ -384,6 +392,11 @@ procedure TDUnitXTestCase.Execute(const context : ITestExecuteContext);
384392
end;
385393
end;
386394

395+
function TDUnitXTestCase.GetIsTestCase: boolean;
396+
begin
397+
result := true;
398+
end;
399+
387400
function TDUnitXTestCase.GetName: string;
388401
begin
389402
if FCaseName <> '' then

0 commit comments

Comments
 (0)