forked from VSoftTechnologies/DUnitX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DUnitX.Extensibility.pas
205 lines (171 loc) · 9.17 KB
/
DUnitX.Extensibility.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{***************************************************************************}
{ }
{ DUnitX }
{ }
{ Copyright (C) 2013 Vincent Parrett }
{ }
{ vincent@finalbuilder.com }
{ http://www.finalbuilder.com }
{ }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (the "License"); }
{ you may not use this file except in compliance with the License. }
{ You may obtain a copy of the License at }
{ }
{ http://www.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
unit DUnitX.Extensibility;
interface
uses
TimeSpan,
Rtti,
Generics.Collections,
DUnitX.Types,
DUnitX.Generics;
type
TTestMethod = procedure of object;
//These interfaces mirror the Info classes in the framework but expose stuff we need for runtime.
ITestFixture = interface;
///
/// Describes the Test at runtime.
///
ITest = interface
['{0CCCE0C7-9AD1-4C3A-86EF-E882D3A839AB}']
function GetName : string;
function GetFullName : string;
function GetMethodName : string;
function GetCategories : TList<string>;
function GetTestMethod : TTestMethod;
function GetTestFixture : ITestFixture;
function GetTestStartTime : TDateTime;
function GetTestEndTime : TDateTime;
function GetTestDuration : TTimeSpan;
function GetEnabled : boolean;
procedure SetEnabled(const value : boolean);
function GetIgnored : boolean;
function GetIgnoreReason : string;
function GetIgnoreMemoryLeaks() : Boolean;
procedure SetIgnoreMemoryLeaks(const AValue : Boolean);
property Name : string read GetName;
property FullName : string read GetFullName;
property MethodName : string read GetMethodName;
property Categories : TList<string> read GetCategories;
property Enabled : boolean read GetEnabled write SetEnabled;
property Fixture : ITestFixture read GetTestFixture;
property Ignored : boolean read GetIgnored;
property IgnoreReason : string read GetIgnoreReason;
property TestMethod : TTestMethod read GetTestMethod;
property IgnoreMemoryLeaks : Boolean read GetIgnoreMemoryLeaks write SetIgnoreMemoryLeaks;
end;
ITestList = interface(IList<ITest>)
['{83ABC05F-5762-4FD2-9791-E32F5A9A4D06}']
end;
ITestFixtureList = interface;
///
/// Describes the Test Fixture at runtime.
///
ITestFixture = interface
['{B2F140C3-1D6A-4C09-B4C6-0D6AFC99BC87}']
function GetName : string;
function GetFullName : string;
function GetUnitName : string;
function GetDescription : string;
function GetCategories : TList<string>;
function GetTests : ITestList;
function GetTestClass : TClass;
function GetSetupMethod : TTestMethod;
function GetSetupMethodName : string;
function GetSetupFixtureMethod : TTestMethod;
function GetSetupFixtureMethodName : string;
function GetTearDownMethod : TTestMethod;
function GetTearDownMethodName : string;
function GetTearDownFixtureMethod : TTestMethod;
function GetTearDownFixtureMethodName : string;
function GetTestInOwnThread : boolean;
function GetEnabled : boolean;
procedure SetEnabled(const value : boolean);
function GetChildren : ITestFixtureList;
function GetHasChildren : boolean;
function GetNameSpace : string;
function GetHasTests : boolean;
function GetHasChildTests : boolean;
function IsNameSpaceOnly : boolean;
procedure OnMethodExecuted(const AMethod : TTestMethod);
function GetFixtureInstance : TObject;
function AddTest(const AMethodName : string; const AMethod : TTestMethod; const AName : string; const ACategory : string; const AEnabled : boolean = true;const AIgnored : boolean = false; const AIgnoreReason : string = '') : ITest;
function AddTestCase(const AMethodName : string; const ACaseName : string; const AName : string; const ACategory : string; const AMethod : TRttiMethod; const AEnabled : boolean; const AArgs : TValueArray) : ITest;
function AddChildFixture(const ATestClass : TClass; const AName : string; const ACategory : string) : ITestFixture;overload;
function AddChildFixture(const AInstance : TObject; const AName : string; const ACategory : string) : ITestFixture;overload;
procedure SetSetupTestMethod(const AMethodName : string; const AMethod : TTestMethod);
procedure SetSetupFixtureMethod(const AMethodName : string; const AMethod : TTestMethod);
procedure SetTearDownTestMethod(const AMethodName : string; const AMethod : TTestMethod);
procedure SetTearDownFixtureMethod(const AMethodName : string; const AMethod : TTestMethod; const AIsDestructor : boolean);
procedure SetTestInOwnThread(const value : boolean);
procedure ExecuteFixtureTearDown;
property Name : string read GetName;
property NameSpace : string read GetNameSpace;
property FullName : string read GetFullName;
property UnitName : string read GetUnitName;
property Categories : TList<string> read GetCategories;
property Children : ITestFixtureList read GetChildren;
property Description : string read GetDescription;
property Enabled : boolean read GetEnabled write SetEnabled;
property FixtureInstance : TObject read GetFixtureInstance;
property HasChildFixtures : boolean read GetHasChildren;
property HasTests : boolean read GetHasTests;
property HasChildTests : boolean read GetHasChildTests;
property TestClass : TClass read GetTestClass;
property Tests : ITestList read GetTests;
property SetupMethod : TTestMethod read GetSetupMethod;
property SetupMethodName : string read GetSetupMethodName;
property SetupFixtureMethod : TTestMethod read GetSetupFixtureMethod;
property SetupFixtureMethodName : string read GetSetupFixtureMethodName;
property TearDownMethod : TTestMethod read GetTearDownMethod;
property TearDownMethodName : string read GetTearDownMethodName;
property TearDownFixtureMethod : TTestMethod read GetTearDownFixtureMethod;
property TearDownFixtureMethodName : string read GetTearDownFixtureMethodName;
property TestInOwnThread : boolean read GetTestInOwnThread write SetTestInOwnThread;
end;
ITestFixtureList = interface(IList<ITestFixture>)
['{BB78BD03-4818-4CF4-B40C-AD037DF2EFB9}']
end;
TTestList = class(TDUnitXList<ITest>, ITestList)
end;
TTestFixtureList = class(TDUnitXList<ITestFixture>, ITestFixtureList)
end;
IFixtureProviderContext = interface
['{933F8442-77F1-4574-BB5E-2F3D0B8E6E6F}']
function CreateFixture(const AFixtureClass : TClass; const AName : string; const ACategory : string) : ITestFixture;overload;
function CreateFixture(const AInstance : TObject; const AName : string; const ACategory : string) : ITestFixture;overload;
function GetUseRtti : boolean;
//The runner UseRtti property exposed for plugin use.
property UseRtti : boolean read GetUseRtti;
end;
IFixtureProvider = interface
['{48D58C88-1236-4B96-9D5F-5DD81DB71504}']
procedure Execute(const context : IFixtureProviderContext);
end;
IPluginLoadContext = interface
['{0A60FE65-C3E3-4E98-9686-8BB6A793810B}']
procedure RegisterFixtureProvider(const provider : IFixtureProvider);
//procedure RegisterSomeOtherFeature(const provider : ISomeOtherFeature);
end;
IPlugin = interface
['{C706DD67-58D0-4B66-92A6-6FBE2AF065A4}']
procedure GetPluginFeatures(const context : IPluginLoadContext);
end;
IFixtureFilter = interface
['{0FBC270E-2DC0-4135-8724-C2AD567A009A}']
procedure InitFromOptions(const ARun : string; const AInclude : string; const AExclude : string);
end;
implementation
end.