Merge lp:~jterrell/nunitv2/action-attributes into lp:nunitv2
- action-attributes
- Merge into trunk
Proposed by
Jordan Terrell
Status: | Merged |
---|---|
Merged at revision: | 3372 |
Proposed branch: | lp:~jterrell/nunitv2/action-attributes |
Merge into: | lp:nunitv2 |
Diff against target: |
2251 lines (+1062/-769) (has conflicts) 21 files modified
src/NUnitCore/core/ActionsHelper.cs (+76/-117) src/NUnitCore/core/NUnitFramework.cs (+4/-4) src/NUnitCore/core/NUnitTestFixture.cs (+1/-1) src/NUnitCore/core/ParameterizedTestMethodSuite.cs (+24/-13) src/NUnitCore/core/SetUpFixture.cs (+1/-1) src/NUnitCore/core/TestAction.cs (+90/-0) src/NUnitCore/core/TestAssembly.cs (+2/-2) src/NUnitCore/core/TestMethod.cs (+37/-12) src/NUnitCore/core/TestSuite.cs (+28/-12) src/NUnitCore/core/nunit.core.dll.csproj (+217/-0) src/NUnitCore/tests/ActionAttributeExceptionTests.cs (+18/-46) src/NUnitCore/tests/ActionAttributeTests.cs (+121/-170) src/NUnitFramework/framework/ActionTargets.cs (+28/-0) src/NUnitFramework/framework/Attributes/TestActionAttribute.cs (+23/-0) src/NUnitFramework/framework/Interfaces/ITestAction.cs (+26/-7) src/NUnitFramework/framework/Interfaces/ITestCaseAction.cs (+0/-33) src/NUnitFramework/framework/Interfaces/ITestSuiteAction.cs (+0/-33) src/NUnitFramework/framework/TestDetails.cs (+60/-0) src/NUnitFramework/framework/nunit.framework.dll.csproj (+193/-192) src/tests/test-assembly/ActionAttributeExceptionFixture.cs (+32/-60) src/tests/test-assembly/ActionAttributeFixture.cs (+81/-66) Text conflict in src/NUnitCore/core/nunit.core.dll.csproj |
To merge this branch: | bzr merge lp:~jterrell/nunitv2/action-attributes |
Related bugs: | |
Related blueprints: |
Composable Action Attributes
(High)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
NUnit Core Developers | Pending | ||
Review via email: mp+90591@code.launchpad.net |
Commit message
Description of the change
Final action attribute design implemented...
To post a comment you must log in.
- 3365. By Jordan Terrell
-
Minor tweaks to ActionAttribute targeting...
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/NUnitCore/core/ActionsHelper.cs' |
2 | --- src/NUnitCore/core/ActionsHelper.cs 2011-11-20 06:12:04 +0000 |
3 | +++ src/NUnitCore/core/ActionsHelper.cs 2012-01-29 17:45:28 +0000 |
4 | @@ -6,122 +6,103 @@ |
5 | |
6 | #if CLR_2_0 || CLR_4_0 |
7 | using System; |
8 | -using System.Collections; |
9 | +using System.Collections; |
10 | +using System.Collections.Generic; |
11 | using System.Reflection; |
12 | |
13 | namespace NUnit.Core |
14 | { |
15 | internal class ActionsHelper |
16 | { |
17 | - private static Type _ActionInterfaceType = null; |
18 | - private static Hashtable _ActionTypes = null; |
19 | + private static Type _ActionInterfaceType = null; |
20 | |
21 | static ActionsHelper() |
22 | { |
23 | - _ActionInterfaceType = Type.GetType(NUnitFramework.TestActionInterface); |
24 | - _ActionTypes = new Hashtable(); |
25 | - |
26 | - Type suiteActionInterface = Type.GetType(NUnitFramework.TestSuiteActionInterface); |
27 | - if(suiteActionInterface != null) |
28 | - _ActionTypes.Add(ActionLevel.Suite, suiteActionInterface); |
29 | - |
30 | - Type caseActionInterface = Type.GetType(NUnitFramework.TestCaseActionInterface); |
31 | - if(caseActionInterface != null) |
32 | - _ActionTypes.Add(ActionLevel.Test, caseActionInterface); |
33 | - } |
34 | - |
35 | - public static object[] GetActionsFromTypeAttributes(Type type) |
36 | + _ActionInterfaceType = Type.GetType(NUnitFramework.TestActionInterface); |
37 | + } |
38 | + |
39 | + public static void ExecuteActions(ActionPhase phase, IEnumerable<TestAction> actions, ITest test) |
40 | + { |
41 | + if (actions == null) |
42 | + return; |
43 | + |
44 | + TestAction[] filteredActions = GetFilteredAndSortedActions(actions, phase); |
45 | + |
46 | + foreach (TestAction action in filteredActions) |
47 | + { |
48 | + if(phase == ActionPhase.Before) |
49 | + action.ExecuteBefore(test); |
50 | + else |
51 | + action.ExecuteAfter(test); |
52 | + } |
53 | + } |
54 | + |
55 | + public static TestAction[] GetActionsFromAttributeProvider(ICustomAttributeProvider attributeProvider) |
56 | + { |
57 | + if (attributeProvider == null || _ActionInterfaceType == null) |
58 | + return new TestAction[0]; |
59 | + |
60 | + object[] targets = attributeProvider.GetCustomAttributes(_ActionInterfaceType, false); |
61 | + |
62 | + List<TestAction> actions = new List<TestAction>(); |
63 | + |
64 | + foreach (var target in targets) |
65 | + actions.Add(new TestAction(target)); |
66 | + |
67 | + actions.Sort(SortByTargetDescending); |
68 | + |
69 | + return actions.ToArray(); |
70 | + } |
71 | + |
72 | + public static TestAction[] GetActionsFromTypesAttributes(Type type) |
73 | { |
74 | - if(type == null) |
75 | - return new object[0]; |
76 | - |
77 | - if(type == typeof(object)) |
78 | - return new object[0]; |
79 | - |
80 | - ArrayList actions = new ArrayList(); |
81 | - |
82 | - actions.AddRange(GetActionsFromTypeAttributes(type.BaseType)); |
83 | + if(type == null) |
84 | + return new TestAction[0]; |
85 | + |
86 | + if(type == typeof(object)) |
87 | + return new TestAction[0]; |
88 | + |
89 | + List<TestAction> actions = new List<TestAction>(); |
90 | + |
91 | + actions.AddRange(GetActionsFromTypesAttributes(type.BaseType)); |
92 | |
93 | Type[] declaredInterfaces = GetDeclaredInterfaces(type); |
94 | |
95 | - foreach(Type interfaceType in declaredInterfaces) |
96 | - actions.AddRange(GetActionsFromAttributes(interfaceType)); |
97 | - |
98 | - actions.AddRange(GetActionsFromAttributes(type)); |
99 | + foreach(Type interfaceType in declaredInterfaces) |
100 | + actions.AddRange(GetActionsFromAttributeProvider(interfaceType)); |
101 | + |
102 | + actions.AddRange(GetActionsFromAttributeProvider(type)); |
103 | |
104 | return actions.ToArray(); |
105 | } |
106 | |
107 | private static Type[] GetDeclaredInterfaces(Type type) |
108 | { |
109 | - Type[] interfaces = type.GetInterfaces(); |
110 | - Type[] baseInterfaces = new Type[0]; |
111 | - |
112 | - if (type.BaseType != typeof(object)) |
113 | - return interfaces; |
114 | - |
115 | - ArrayList declaredInterfaces = new ArrayList(); |
116 | + List<Type> interfaces = new List<Type>(type.GetInterfaces()); |
117 | + |
118 | + if (type.BaseType == typeof(object)) |
119 | + return interfaces.ToArray(); |
120 | + |
121 | + List<Type> baseInterfaces = new List<Type>(type.BaseType.GetInterfaces()); |
122 | + List<Type> declaredInterfaces = new List<Type>(); |
123 | + |
124 | foreach (Type interfaceType in interfaces) |
125 | { |
126 | - if (Array.IndexOf(baseInterfaces, interfaceType) < 0) |
127 | + if (!baseInterfaces.Contains(interfaceType)) |
128 | declaredInterfaces.Add(interfaceType); |
129 | } |
130 | |
131 | - return (Type[])declaredInterfaces.ToArray(typeof(Type)); |
132 | - } |
133 | - |
134 | - public static object[] GetActionsFromAttributes(ICustomAttributeProvider attributeProvider) |
135 | - { |
136 | - if(attributeProvider == null || _ActionInterfaceType == null) |
137 | - return new object[0]; |
138 | - |
139 | - return attributeProvider.GetCustomAttributes(_ActionInterfaceType, false); |
140 | - } |
141 | - |
142 | - public static void ExecuteActions(ActionLevel level, ActionPhase phase, IEnumerable actions, object fixture, MethodInfo method) |
143 | - { |
144 | - if (actions == null) |
145 | - return; |
146 | - |
147 | - Type actionType = GetActionType(level); |
148 | - if(actionType == null) |
149 | - return; |
150 | - |
151 | - MethodInfo actionMethod = GetActionMethod(actionType, level, phase); |
152 | - |
153 | - object[] filteredActions = GetFilteredAndSortedActions(actions, phase, actionType); |
154 | - |
155 | - foreach (object action in filteredActions) |
156 | - { |
157 | - if (action == null) |
158 | - continue; |
159 | - |
160 | - Reflect.InvokeMethod(actionMethod, action, fixture, method); |
161 | - } |
162 | - } |
163 | - |
164 | - private static object[] GetFilteredAndSortedActions(IEnumerable actions, ActionPhase phase, Type actionType) |
165 | - { |
166 | - ArrayList filteredActions = new ArrayList(); |
167 | - foreach(object actionItem in actions) |
168 | - { |
169 | - if(actionItem == null) |
170 | - continue; |
171 | - |
172 | - if(actionItem is IEnumerable) |
173 | - { |
174 | - foreach(object nestedItem in ((IEnumerable)actionItem)) |
175 | - { |
176 | - if(nestedItem == null) |
177 | - continue; |
178 | - |
179 | - if (actionType.IsAssignableFrom(nestedItem.GetType()) && filteredActions.Contains(nestedItem) != true) |
180 | - filteredActions.Add(nestedItem); |
181 | - } |
182 | - } |
183 | - else if(actionType.IsAssignableFrom(actionItem.GetType()) && filteredActions.Contains(actionItem) != true) |
184 | + return declaredInterfaces.ToArray(); |
185 | + } |
186 | + |
187 | + private static TestAction[] GetFilteredAndSortedActions(IEnumerable<TestAction> actions, ActionPhase phase) |
188 | + { |
189 | + List<TestAction> filteredActions = new List<TestAction>(); |
190 | + foreach (TestAction actionItem in actions) |
191 | + { |
192 | + if (filteredActions.Contains(actionItem) != true) |
193 | filteredActions.Add(actionItem); |
194 | - } |
195 | + } |
196 | |
197 | if(phase == ActionPhase.After) |
198 | filteredActions.Reverse(); |
199 | @@ -129,32 +110,10 @@ |
200 | return filteredActions.ToArray(); |
201 | } |
202 | |
203 | - private static Type GetActionType(ActionLevel level) |
204 | - { |
205 | - return (Type) _ActionTypes[level]; |
206 | - } |
207 | - |
208 | - private static MethodInfo GetActionMethod(Type actionType, ActionLevel level, ActionPhase phase) |
209 | - { |
210 | - if (phase == ActionPhase.Before) |
211 | - { |
212 | - if (level == ActionLevel.Suite) |
213 | - return Reflect.GetNamedMethod(actionType, "BeforeTestSuite"); |
214 | - |
215 | - return Reflect.GetNamedMethod(actionType, "BeforeTestCase"); |
216 | - } |
217 | - |
218 | - if (level == ActionLevel.Suite) |
219 | - return Reflect.GetNamedMethod(actionType, "AfterTestSuite"); |
220 | - |
221 | - return Reflect.GetNamedMethod(actionType, "AfterTestCase"); |
222 | - } |
223 | - } |
224 | - |
225 | - public enum ActionLevel |
226 | - { |
227 | - Suite, |
228 | - Test |
229 | + private static int SortByTargetDescending(TestAction x, TestAction y) |
230 | + { |
231 | + return y.Targets.CompareTo(x.Targets); |
232 | + } |
233 | } |
234 | |
235 | public enum ActionPhase |
236 | |
237 | === modified file 'src/NUnitCore/core/NUnitFramework.cs' |
238 | --- src/NUnitCore/core/NUnitFramework.cs 2011-12-02 05:50:49 +0000 |
239 | +++ src/NUnitCore/core/NUnitFramework.cs 2012-01-29 17:45:28 +0000 |
240 | @@ -35,7 +35,7 @@ |
241 | public const string DescriptionAttribute = "NUnit.Framework.DescriptionAttribute"; |
242 | public const string RequiredAddinAttribute = "NUnit.Framework.RequiredAddinAttribute"; |
243 | |
244 | - // Attributes that apply only to Classes |
245 | + // Attributes that apply only to Classes |
246 | public const string TestFixtureAttribute = "NUnit.Framework.TestFixtureAttribute"; |
247 | public const string SetUpFixtureAttribute = "NUnit.Framework.SetUpFixtureAttribute"; |
248 | |
249 | @@ -56,9 +56,9 @@ |
250 | |
251 | #region Other Framework Types |
252 | |
253 | - public static readonly string TestSuiteActionInterface = "NUnit.Framework.ITestSuiteAction, nunit.framework"; |
254 | - public static readonly string TestCaseActionInterface = "NUnit.Framework.ITestCaseAction, nunit.framework"; |
255 | - public static readonly string TestActionInterface = "NUnit.Framework.ITestAction, nunit.framework"; |
256 | + public static readonly string TestActionInterface = "NUnit.Framework.ITestAction, nunit.framework"; |
257 | + |
258 | + public static readonly string TestDetailsClass = "NUnit.Framework.TestDetails, nunit.framework"; |
259 | |
260 | public static readonly string AssertException = "NUnit.Framework.AssertionException"; |
261 | public static readonly string IgnoreException = "NUnit.Framework.IgnoreException"; |
262 | |
263 | === modified file 'src/NUnitCore/core/NUnitTestFixture.cs' |
264 | --- src/NUnitCore/core/NUnitTestFixture.cs 2011-08-28 19:58:58 +0000 |
265 | +++ src/NUnitCore/core/NUnitTestFixture.cs 2012-01-29 17:45:28 +0000 |
266 | @@ -31,7 +31,7 @@ |
267 | Reflect.GetMethodsWithAttribute(this.FixtureType, NUnitFramework.TearDownAttribute, true); |
268 | |
269 | #if CLR_2_0 || CLR_4_0 |
270 | - this.actions = ActionsHelper.GetActionsFromTypeAttributes(fixtureType); |
271 | + this.actions = ActionsHelper.GetActionsFromTypesAttributes(fixtureType); |
272 | #endif |
273 | } |
274 | |
275 | |
276 | === modified file 'src/NUnitCore/core/ParameterizedTestMethodSuite.cs' |
277 | --- src/NUnitCore/core/ParameterizedTestMethodSuite.cs 2011-08-26 23:38:44 +0000 |
278 | +++ src/NUnitCore/core/ParameterizedTestMethodSuite.cs 2012-01-29 17:45:28 +0000 |
279 | @@ -3,7 +3,10 @@ |
280 | // This is free software licensed under the NUnit license. You may |
281 | // obtain a copy of the license at http://nunit.org. |
282 | // **************************************************************** |
283 | -using System.Collections; |
284 | +using System.Collections; |
285 | +#if CLR_2_0 || CLR_4_0 |
286 | +using System.Collections.Generic; |
287 | +#endif |
288 | using System.Reflection; |
289 | using System.Text; |
290 | |
291 | @@ -64,7 +67,7 @@ |
292 | } |
293 | |
294 | #if CLR_2_0 || CLR_4_0 |
295 | - this.actions = ActionsHelper.GetActionsFromAttributes(this.method); |
296 | + this.actions = ActionsHelper.GetActionsFromAttributeProvider(this.method); |
297 | #endif |
298 | |
299 | // DYNAMIC: Get the parameters, and add the methods here. |
300 | @@ -105,16 +108,24 @@ |
301 | /// <param name="suiteResult"></param> |
302 | protected override void DoOneTimeTearDown(TestResult suiteResult) |
303 | { |
304 | - } |
305 | - |
306 | - #if CLR_2_0 || CLR_4_0 |
307 | - |
308 | - protected override void ExecuteActions(ActionLevel level, ActionPhase phase) |
309 | - { |
310 | - ActionsHelper.ExecuteActions(level, phase, this.actions, this.Fixture, method); |
311 | - } |
312 | - |
313 | - #endif |
314 | - |
315 | + } |
316 | + |
317 | +#if CLR_2_0 || CLR_4_0 |
318 | + protected override void ExecuteActions(ActionPhase phase) |
319 | + { |
320 | + List<TestAction> targetActions = new List<TestAction>(); |
321 | + |
322 | + if (this.actions != null) |
323 | + { |
324 | + foreach (var action in this.actions) |
325 | + { |
326 | + if (action.DoesTarget(TestAction.TargetsSuite)) |
327 | + targetActions.Add(action); |
328 | + } |
329 | + } |
330 | + |
331 | + ActionsHelper.ExecuteActions(phase, targetActions, this); |
332 | + } |
333 | +#endif |
334 | } |
335 | } |
336 | |
337 | === modified file 'src/NUnitCore/core/SetUpFixture.cs' |
338 | --- src/NUnitCore/core/SetUpFixture.cs 2011-03-30 20:37:44 +0000 |
339 | +++ src/NUnitCore/core/SetUpFixture.cs 2012-01-29 17:45:28 +0000 |
340 | @@ -30,7 +30,7 @@ |
341 | this.fixtureTearDownMethods = Reflect.GetMethodsWithAttribute( type, NUnitFramework.TearDownAttribute, true ); |
342 | |
343 | #if CLR_2_0 || CLR_4_0 |
344 | - this.actions = ActionsHelper.GetActionsFromTypeAttributes(type); |
345 | + this.actions = ActionsHelper.GetActionsFromTypesAttributes(type); |
346 | #endif |
347 | } |
348 | #endregion |
349 | |
350 | === added file 'src/NUnitCore/core/TestAction.cs' |
351 | --- src/NUnitCore/core/TestAction.cs 1970-01-01 00:00:00 +0000 |
352 | +++ src/NUnitCore/core/TestAction.cs 2012-01-29 17:45:28 +0000 |
353 | @@ -0,0 +1,90 @@ |
354 | +#if CLR_2_0 || CLR_4_0 |
355 | +using System; |
356 | +using System.Collections.Generic; |
357 | +using System.Reflection; |
358 | +using System.Text; |
359 | + |
360 | +namespace NUnit.Core |
361 | +{ |
362 | + public class TestAction |
363 | + { |
364 | + public static readonly int TargetsDefault = 0; |
365 | + public static readonly int TargetsTest = 1; |
366 | + public static readonly int TargetsSuite = 2; |
367 | + |
368 | + private static readonly Type _ActionInterfaceType = null; |
369 | + private static readonly Type _TestDetailsClassType = null; |
370 | + |
371 | + static TestAction() |
372 | + { |
373 | + _ActionInterfaceType = Type.GetType(NUnitFramework.TestActionInterface); |
374 | + _TestDetailsClassType = Type.GetType(NUnitFramework.TestDetailsClass); |
375 | + } |
376 | + |
377 | + private readonly object _Action; |
378 | + private readonly int _Targets; |
379 | + |
380 | + public TestAction(object action) |
381 | + { |
382 | + if (action == null) |
383 | + throw new ArgumentNullException("action"); |
384 | + |
385 | + _Action = action; |
386 | + _Targets = (int) Reflect.GetPropertyValue(action, "Targets"); |
387 | + } |
388 | + |
389 | + public void ExecuteBefore(ITest test) |
390 | + { |
391 | + Execute(test, "Before"); |
392 | + } |
393 | + |
394 | + public void ExecuteAfter(ITest test) |
395 | + { |
396 | + Execute(test, "After"); |
397 | + } |
398 | + |
399 | + private void Execute(ITest test, string methodPrefix) |
400 | + { |
401 | + var method = Reflect.GetNamedMethod(_ActionInterfaceType, methodPrefix + "Test"); |
402 | + var details = CreateTestDetails(test); |
403 | + |
404 | + Reflect.InvokeMethod(method, _Action, details); |
405 | + } |
406 | + |
407 | + private static object CreateTestDetails(ITest test) |
408 | + { |
409 | + object fixture = null; |
410 | + MethodInfo method = null; |
411 | + |
412 | + var testMethod = test as TestMethod; |
413 | + if (testMethod != null) |
414 | + method = testMethod.Method; |
415 | + |
416 | + var testObject = test as Test; |
417 | + if(testObject != null) |
418 | + fixture = testObject.Fixture; |
419 | + |
420 | + return Activator.CreateInstance(_TestDetailsClassType, |
421 | + fixture, |
422 | + method, |
423 | + test.TestName.FullName, |
424 | + test.TestType, |
425 | + test.IsSuite); |
426 | + } |
427 | + |
428 | + public bool DoesTarget(int target) |
429 | + { |
430 | + if(target < 0) |
431 | + throw new ArgumentOutOfRangeException("target", "Target must be a positive integer."); |
432 | + |
433 | + if(target == 0) |
434 | + return _Targets == 0; |
435 | + |
436 | + uint self = Convert.ToUInt32(target); |
437 | + return (_Targets & self) == self; |
438 | + } |
439 | + |
440 | + public int Targets { get { return _Targets; } } |
441 | + } |
442 | +} |
443 | +#endif |
444 | \ No newline at end of file |
445 | |
446 | === modified file 'src/NUnitCore/core/TestAssembly.cs' |
447 | --- src/NUnitCore/core/TestAssembly.cs 2011-03-30 20:37:44 +0000 |
448 | +++ src/NUnitCore/core/TestAssembly.cs 2012-01-29 17:45:28 +0000 |
449 | @@ -21,8 +21,8 @@ |
450 | /// <param name="path">The path.</param> |
451 | public TestAssembly(Assembly assembly, string path) : base(path) |
452 | { |
453 | -#if CLR_2_0 || CLR_4_0 |
454 | - this.actions = ActionsHelper.GetActionsFromAttributes(assembly); |
455 | +#if CLR_2_0 || CLR_4_0 |
456 | + this.actions = ActionsHelper.GetActionsFromAttributeProvider(assembly); |
457 | #endif |
458 | } |
459 | |
460 | |
461 | === modified file 'src/NUnitCore/core/TestMethod.cs' |
462 | --- src/NUnitCore/core/TestMethod.cs 2011-12-26 18:36:39 +0000 |
463 | +++ src/NUnitCore/core/TestMethod.cs 2012-01-29 17:45:28 +0000 |
464 | @@ -2,7 +2,8 @@ |
465 | // This is free software licensed under the NUnit license. You |
466 | // may obtain a copy of the license as well as information regarding |
467 | // copyright ownership at http://nunit.org. |
468 | -// **************************************************************** |
469 | +// **************************************************************** |
470 | + |
471 | namespace NUnit.Core |
472 | { |
473 | using System; |
474 | @@ -13,6 +14,10 @@ |
475 | using System.Text.RegularExpressions; |
476 | using System.Reflection; |
477 | |
478 | +#if CLR_2_0 || CLR_4_0 |
479 | + using System.Collections.Generic; |
480 | +#endif |
481 | + |
482 | /// <summary> |
483 | /// The TestMethod class represents a Test implemented as a method. |
484 | /// |
485 | @@ -47,12 +52,12 @@ |
486 | /// <summary> |
487 | /// The actions |
488 | /// </summary> |
489 | - protected object[] actions; |
490 | + protected TestAction[] actions; |
491 | |
492 | /// <summary> |
493 | /// The parent suite's actions |
494 | - /// </summary> |
495 | - protected object[] suiteActions; |
496 | + /// </summary> |
497 | + protected TestAction[] suiteActions; |
498 | #endif |
499 | |
500 | /// <summary> |
501 | @@ -239,8 +244,8 @@ |
502 | |
503 | try |
504 | { |
505 | -#if CLR_2_0 || CLR_4_0 |
506 | - this.actions = ActionsHelper.GetActionsFromAttributes(method); |
507 | +#if CLR_2_0 || CLR_4_0 |
508 | + this.actions = ActionsHelper.GetActionsFromAttributeProvider(method); |
509 | #endif |
510 | |
511 | // Temporary... to allow for tests that directly execute a test case); |
512 | @@ -379,22 +384,42 @@ |
513 | |
514 | #if CLR_2_0 || CLR_4_0 |
515 | |
516 | - protected virtual void ExecuteActions(ActionLevel level, ActionPhase phase) |
517 | - { |
518 | - object[][] targetActions = new object[][] { this.suiteActions, this.actions }; |
519 | - ActionsHelper.ExecuteActions(level, phase, targetActions, this.Fixture, this.Method); |
520 | + protected virtual void ExecuteActions(ActionPhase phase) |
521 | + { |
522 | + List<TestAction> targetActions = new List<TestAction>(); |
523 | + |
524 | + if (this.suiteActions != null) |
525 | + { |
526 | + foreach (var action in this.suiteActions) |
527 | + { |
528 | + if(action.DoesTarget(TestAction.TargetsTest)) |
529 | + targetActions.Add(action); |
530 | + } |
531 | + } |
532 | + |
533 | + if (this.actions != null) |
534 | + { |
535 | + foreach (var action in this.actions) |
536 | + { |
537 | + |
538 | + if (action.DoesTarget(TestAction.TargetsDefault) || (!(Parent is ParameterizedMethodSuite) && action.DoesTarget(TestAction.TargetsTest))) |
539 | + targetActions.Add(action); |
540 | + } |
541 | + } |
542 | + |
543 | + ActionsHelper.ExecuteActions(phase, targetActions, this); |
544 | } |
545 | |
546 | private void RunBeforeActions(TestResult testResult) |
547 | { |
548 | - ExecuteActions(ActionLevel.Test, ActionPhase.Before); |
549 | + ExecuteActions(ActionPhase.Before); |
550 | } |
551 | |
552 | private void RunAfterActions(TestResult testResult) |
553 | { |
554 | try |
555 | { |
556 | - ExecuteActions(ActionLevel.Test, ActionPhase.After); |
557 | + ExecuteActions(ActionPhase.After); |
558 | } |
559 | catch (Exception ex) |
560 | { |
561 | |
562 | === modified file 'src/NUnitCore/core/TestSuite.cs' |
563 | --- src/NUnitCore/core/TestSuite.cs 2011-12-28 03:44:23 +0000 |
564 | +++ src/NUnitCore/core/TestSuite.cs 2012-01-29 17:45:28 +0000 |
565 | @@ -2,8 +2,9 @@ |
566 | // This is free software licensed under the NUnit license. You |
567 | // may obtain a copy of the license as well as information regarding |
568 | // copyright ownership at http://nunit.org. |
569 | -// **************************************************************** |
570 | - |
571 | +// **************************************************************** |
572 | + |
573 | + |
574 | namespace NUnit.Core |
575 | { |
576 | using System; |
577 | @@ -13,6 +14,10 @@ |
578 | using System.Reflection; |
579 | using NUnit.Core.Filters; |
580 | |
581 | +#if CLR_2_0 || CLR_4_0 |
582 | + using System.Collections.Generic; |
583 | +#endif |
584 | + |
585 | /// <summary> |
586 | /// Summary description for TestSuite. |
587 | /// </summary> |
588 | @@ -52,7 +57,7 @@ |
589 | /// <summary> |
590 | /// The actions for this suite |
591 | /// </summary> |
592 | - protected object[] actions; |
593 | + protected TestAction[] actions; |
594 | #endif |
595 | |
596 | /// <summary> |
597 | @@ -196,13 +201,13 @@ |
598 | } |
599 | |
600 | #if CLR_2_0 || CLR_4_0 |
601 | - internal virtual object[] GetTestActions() |
602 | - { |
603 | - ArrayList allActions = new ArrayList(); |
604 | + internal virtual TestAction[] GetTestActions() |
605 | + { |
606 | + List<TestAction> allActions = new List<TestAction>(); |
607 | |
608 | if (this.Parent != null && this.Parent is TestSuite) |
609 | { |
610 | - object[] parentActions = ((TestSuite)this.Parent).GetTestActions(); |
611 | + TestAction[] parentActions = ((TestSuite)this.Parent).GetTestActions(); |
612 | |
613 | if (parentActions != null) |
614 | allActions.AddRange(parentActions); |
615 | @@ -378,16 +383,27 @@ |
616 | |
617 | #if CLR_2_0 || CLR_4_0 |
618 | |
619 | - protected virtual void ExecuteActions(ActionLevel level, ActionPhase phase) |
620 | - { |
621 | - ActionsHelper.ExecuteActions(level, phase, this.actions, this.Fixture, null); |
622 | + protected virtual void ExecuteActions(ActionPhase phase) |
623 | + { |
624 | + List<TestAction> targetActions = new List<TestAction>(); |
625 | + |
626 | + if (this.actions != null) |
627 | + { |
628 | + foreach (var action in this.actions) |
629 | + { |
630 | + if (action.DoesTarget(TestAction.TargetsSuite) || action.DoesTarget(TestAction.TargetsDefault)) |
631 | + targetActions.Add(action); |
632 | + } |
633 | + } |
634 | + |
635 | + ActionsHelper.ExecuteActions(phase, targetActions, this); |
636 | } |
637 | |
638 | protected virtual void DoOneTimeBeforeTestSuiteActions(TestResult suiteResult) |
639 | { |
640 | try |
641 | { |
642 | - ExecuteActions(ActionLevel.Suite, ActionPhase.Before); |
643 | + ExecuteActions(ActionPhase.Before); |
644 | TestExecutionContext.CurrentContext.Update(); |
645 | } |
646 | catch (Exception ex) |
647 | @@ -462,7 +478,7 @@ |
648 | { |
649 | try |
650 | { |
651 | - ExecuteActions(ActionLevel.Suite, ActionPhase.After); |
652 | + ExecuteActions(ActionPhase.After); |
653 | } |
654 | catch (Exception ex) |
655 | { |
656 | |
657 | === modified file 'src/NUnitCore/core/nunit.core.dll.csproj' |
658 | --- src/NUnitCore/core/nunit.core.dll.csproj 2012-01-10 23:03:38 +0000 |
659 | +++ src/NUnitCore/core/nunit.core.dll.csproj 2012-01-29 17:45:28 +0000 |
660 | @@ -1,3 +1,4 @@ |
661 | +<<<<<<< TREE |
662 | <?xml version="1.0" encoding="utf-8"?> |
663 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> |
664 | <PropertyGroup> |
665 | @@ -210,4 +211,220 @@ |
666 | <PostBuildEvent> |
667 | </PostBuildEvent> |
668 | </PropertyGroup> |
669 | +======= |
670 | +<?xml version="1.0" encoding="utf-8"?> |
671 | +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> |
672 | + <PropertyGroup> |
673 | + <ProjectType>Local</ProjectType> |
674 | + <ProductVersion>9.0.30729</ProductVersion> |
675 | + <SchemaVersion>2.0</SchemaVersion> |
676 | + <ProjectGuid>{EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}</ProjectGuid> |
677 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
678 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
679 | + <AssemblyKeyContainerName> |
680 | + </AssemblyKeyContainerName> |
681 | + <AssemblyName>nunit.core</AssemblyName> |
682 | + <DefaultClientScript>JScript</DefaultClientScript> |
683 | + <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> |
684 | + <DefaultTargetSchema>IE50</DefaultTargetSchema> |
685 | + <DelaySign>false</DelaySign> |
686 | + <OutputType>Library</OutputType> |
687 | + <RootNamespace>NUnit.Core</RootNamespace> |
688 | + <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> |
689 | + <FileUpgradeFlags> |
690 | + </FileUpgradeFlags> |
691 | + <UpgradeBackupLocation> |
692 | + </UpgradeBackupLocation> |
693 | + <OldToolsVersion>2.0</OldToolsVersion> |
694 | + <PublishUrl>http://localhost/nunit.core/</PublishUrl> |
695 | + <Install>true</Install> |
696 | + <InstallFrom>Web</InstallFrom> |
697 | + <UpdateEnabled>true</UpdateEnabled> |
698 | + <UpdateMode>Foreground</UpdateMode> |
699 | + <UpdateInterval>7</UpdateInterval> |
700 | + <UpdateIntervalUnits>Days</UpdateIntervalUnits> |
701 | + <UpdatePeriodically>false</UpdatePeriodically> |
702 | + <UpdateRequired>false</UpdateRequired> |
703 | + <MapFileExtensions>true</MapFileExtensions> |
704 | + <ApplicationRevision>0</ApplicationRevision> |
705 | + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> |
706 | + <IsWebBootstrapper>true</IsWebBootstrapper> |
707 | + <UseApplicationTrust>false</UseApplicationTrust> |
708 | + <BootstrapperEnabled>true</BootstrapperEnabled> |
709 | + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> |
710 | + </PropertyGroup> |
711 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
712 | + <OutputPath>..\..\..\bin\Debug\lib\</OutputPath> |
713 | + <BaseAddress>285212672</BaseAddress> |
714 | + <ConfigurationOverrideFile> |
715 | + </ConfigurationOverrideFile> |
716 | + <DefineConstants>TRACE;DEBUG;CLR_2_0,NET_2_0,CS_3_0</DefineConstants> |
717 | + <DocumentationFile> |
718 | + </DocumentationFile> |
719 | + <DebugSymbols>true</DebugSymbols> |
720 | + <FileAlignment>4096</FileAlignment> |
721 | + <NoWarn>1699</NoWarn> |
722 | + <Optimize>false</Optimize> |
723 | + <RegisterForComInterop>false</RegisterForComInterop> |
724 | + <RemoveIntegerChecks>false</RemoveIntegerChecks> |
725 | + <WarningLevel>4</WarningLevel> |
726 | + <DebugType>full</DebugType> |
727 | + <ErrorReport>prompt</ErrorReport> |
728 | + </PropertyGroup> |
729 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
730 | + <OutputPath>..\..\..\bin\Release\lib\</OutputPath> |
731 | + <BaseAddress>285212672</BaseAddress> |
732 | + <ConfigurationOverrideFile> |
733 | + </ConfigurationOverrideFile> |
734 | + <DefineConstants>TRACE;CLR_2_0,NET_2_0,CS_3_0</DefineConstants> |
735 | + <DocumentationFile> |
736 | + </DocumentationFile> |
737 | + <FileAlignment>4096</FileAlignment> |
738 | + <NoWarn>1699</NoWarn> |
739 | + <Optimize>true</Optimize> |
740 | + <RegisterForComInterop>false</RegisterForComInterop> |
741 | + <RemoveIntegerChecks>false</RemoveIntegerChecks> |
742 | + <WarningLevel>4</WarningLevel> |
743 | + <DebugType>none</DebugType> |
744 | + <ErrorReport>prompt</ErrorReport> |
745 | + </PropertyGroup> |
746 | + <ItemGroup> |
747 | + <Reference Include="System"> |
748 | + <Name>System</Name> |
749 | + </Reference> |
750 | + <Reference Include="System.Data"> |
751 | + <Name>System.Data</Name> |
752 | + </Reference> |
753 | + <Reference Include="System.Xml"> |
754 | + <Name>System.XML</Name> |
755 | + </Reference> |
756 | + <ProjectReference Include="..\interfaces\nunit.core.interfaces.dll.csproj"> |
757 | + <Name>nunit.core.interfaces.dll</Name> |
758 | + <Project>{435428F8-5995-4CE4-8022-93D595A8CC0F}</Project> |
759 | + <Private>False</Private> |
760 | + </ProjectReference> |
761 | + <Reference Include="System.Configuration" /> |
762 | + </ItemGroup> |
763 | + <ItemGroup> |
764 | + <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> |
765 | + <Visible>False</Visible> |
766 | + <ProductName>.NET Framework 2.0 %28x86%29</ProductName> |
767 | + <Install>true</Install> |
768 | + </BootstrapperPackage> |
769 | + <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> |
770 | + <Visible>False</Visible> |
771 | + <ProductName>.NET Framework 3.0 %28x86%29</ProductName> |
772 | + <Install>false</Install> |
773 | + </BootstrapperPackage> |
774 | + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> |
775 | + <Visible>False</Visible> |
776 | + <ProductName>.NET Framework 3.5</ProductName> |
777 | + <Install>false</Install> |
778 | + </BootstrapperPackage> |
779 | + </ItemGroup> |
780 | + <ItemGroup> |
781 | + <Compile Include="..\..\CommonAssemblyInfo.cs"> |
782 | + <Link>CommonAssemblyInfo.cs</Link> |
783 | + </Compile> |
784 | + <Compile Include="AbstractTestCaseDecoration.cs" /> |
785 | + <Compile Include="AssemblyHelper.cs" /> |
786 | + <Compile Include="AssemblyInfo.cs" /> |
787 | + <Compile Include="AssemblyReader.cs" /> |
788 | + <Compile Include="AssemblyResolver.cs" /> |
789 | + <Compile Include="ActionsHelper.cs" /> |
790 | + <Compile Include="Builders\CombinatorialStrategy.cs" /> |
791 | + <Compile Include="Builders\CombinatorialTestCaseProvider.cs" /> |
792 | + <Compile Include="Builders\CombiningStrategy.cs" /> |
793 | + <Compile Include="Builders\DatapointProvider.cs" /> |
794 | + <Compile Include="Builders\InlineDataPointProvider.cs" /> |
795 | + <Compile Include="Builders\LegacySuiteBuilder.cs" /> |
796 | + <Compile Include="Builders\NUnitTestCaseBuilder.cs" /> |
797 | + <Compile Include="Builders\NUnitTestFixtureBuilder.cs" /> |
798 | + <Compile Include="Builders\PairwiseStrategy.cs" /> |
799 | + <Compile Include="Builders\ProviderCache.cs" /> |
800 | + <Compile Include="Builders\ProviderInfo.cs" /> |
801 | + <Compile Include="Builders\SequentialStrategy.cs" /> |
802 | + <Compile Include="Builders\SetUpFixtureBuilder.cs" /> |
803 | + <Compile Include="Builders\TestAssemblyBuilder.cs" /> |
804 | + <Compile Include="Builders\TestCaseParameterProvider.cs" /> |
805 | + <Compile Include="Builders\TestCaseSourceProvider.cs" /> |
806 | + <Compile Include="Builders\ValueSourceProvider.cs" /> |
807 | + <Compile Include="ContextDictionary.cs" /> |
808 | + <Compile Include="CoreExtensions.cs" /> |
809 | + <Compile Include="CultureDetector.cs" /> |
810 | + <Compile Include="DirectorySwapper.cs" /> |
811 | + <Compile Include="DomainAgent.cs" /> |
812 | + <Compile Include="EventListenerTextWriter.cs" /> |
813 | + <Compile Include="EventPump.cs" /> |
814 | + <Compile Include="EventQueue.cs" /> |
815 | + <Compile Include="ExpectedExceptionProcessor.cs" /> |
816 | + <Compile Include="Extensibility\DataPointProviders.cs" /> |
817 | + <Compile Include="Extensibility\EventListenerCollection.cs" /> |
818 | + <Compile Include="Extensibility\FrameworkRegistry.cs" /> |
819 | + <Compile Include="Extensibility\SuiteBuilderCollection.cs" /> |
820 | + <Compile Include="Extensibility\TestCaseBuilderCollection.cs" /> |
821 | + <Compile Include="Extensibility\TestCaseProviders.cs" /> |
822 | + <Compile Include="Extensibility\TestDecoratorCollection.cs" /> |
823 | + <Compile Include="ExtensionHost.cs" /> |
824 | + <Compile Include="ExtensionPoint.cs" /> |
825 | + <Compile Include="IgnoreDecorator.cs" /> |
826 | + <Compile Include="InternalTrace.cs" /> |
827 | + <Compile Include="InternalTraceWriter.cs" /> |
828 | + <Compile Include="InvalidSuiteException.cs" /> |
829 | + <Compile Include="InvalidTestFixtureException.cs" /> |
830 | + <Compile Include="LegacySuite.cs" /> |
831 | + <Compile Include="Log4NetCapture.cs" /> |
832 | + <Compile Include="LogCapture.cs" /> |
833 | + <Compile Include="Logger.cs" /> |
834 | + <Compile Include="MethodHelper.cs" /> |
835 | + <Compile Include="NamespaceSuite.cs" /> |
836 | + <Compile Include="NamespaceTreeBuilder.cs" /> |
837 | + <Compile Include="NoTestFixturesException.cs" /> |
838 | + <Compile Include="NullListener.cs" /> |
839 | + <Compile Include="NUnitConfiguration.cs" /> |
840 | + <Compile Include="NUnitException.cs" /> |
841 | + <Compile Include="NUnitFramework.cs" /> |
842 | + <Compile Include="NUnitTestFixture.cs" /> |
843 | + <Compile Include="NUnitTestMethod.cs" /> |
844 | + <Compile Include="ParameterizedFixtureSuite.cs" /> |
845 | + <Compile Include="ParameterizedTestMethodSuite.cs" /> |
846 | + <Compile Include="PlatformHelper.cs" /> |
847 | + <Compile Include="ProjectRootSuite.cs" /> |
848 | + <Compile Include="ProxyTestRunner.cs" /> |
849 | + <Compile Include="QueuingEventListener.cs" /> |
850 | + <Compile Include="Reflect.cs" /> |
851 | + <Compile Include="RemoteTestRunner.cs" /> |
852 | + <Compile Include="SetUpFixture.cs" /> |
853 | + <Compile Include="SimpleTestRunner.cs" /> |
854 | + <Compile Include="StringTextWriter.cs" /> |
855 | + <Compile Include="SuiteBuilderAttribute.cs" /> |
856 | + <Compile Include="TestAction.cs" /> |
857 | + <Compile Include="TestAssembly.cs" /> |
858 | + <Compile Include="TestBuilderAttribute.cs" /> |
859 | + <Compile Include="TestCaseBuilderAttribute.cs" /> |
860 | + <Compile Include="TestDecoratorAttribute.cs" /> |
861 | + <Compile Include="TestExecutionContext.cs" /> |
862 | + <Compile Include="TestFixture.cs" /> |
863 | + <Compile Include="TestFixtureBuilder.cs" /> |
864 | + <Compile Include="TestMethod.cs" /> |
865 | + <Compile Include="TestRunnerThread.cs" /> |
866 | + <Compile Include="TestSuite.cs" /> |
867 | + <Compile Include="TestSuiteBuilder.cs" /> |
868 | + <Compile Include="TestThread.cs" /> |
869 | + <Compile Include="TextCapture.cs" /> |
870 | + <Compile Include="ThreadedTestRunner.cs" /> |
871 | + <Compile Include="ThreadUtility.cs" /> |
872 | + <Compile Include="TypeHelper.cs" /> |
873 | + </ItemGroup> |
874 | + <ItemGroup> |
875 | + <None Include="nunit.core.build" /> |
876 | + </ItemGroup> |
877 | + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
878 | + <PropertyGroup> |
879 | + <PreBuildEvent> |
880 | + </PreBuildEvent> |
881 | + <PostBuildEvent> |
882 | + </PostBuildEvent> |
883 | + </PropertyGroup> |
884 | +>>>>>>> MERGE-SOURCE |
885 | </Project> |
886 | \ No newline at end of file |
887 | |
888 | === modified file 'src/NUnitCore/tests/ActionAttributeExceptionTests.cs' |
889 | --- src/NUnitCore/tests/ActionAttributeExceptionTests.cs 2011-03-30 20:37:44 +0000 |
890 | +++ src/NUnitCore/tests/ActionAttributeExceptionTests.cs 2012-01-29 17:45:28 +0000 |
891 | @@ -42,52 +42,24 @@ |
892 | } |
893 | |
894 | [Test] |
895 | - public void BeforeTestSuiteException() |
896 | - { |
897 | - ExceptionThrowingActionAttribute.Reset(); |
898 | - ExceptionThrowingActionAttribute.ThrowBeforeSuiteException = true; |
899 | - |
900 | - ActionAttributeExceptionFixture.Reset(); |
901 | - |
902 | - TestResult result = FindFailureTestResult(RunTest()); |
903 | - |
904 | - Assert.IsTrue(result.FailureSite == FailureSite.SetUp); |
905 | - Assert.IsFalse(ActionAttributeExceptionFixture.TestRun); |
906 | - } |
907 | - |
908 | - [Test] |
909 | - public void AfterTestSuiteException() |
910 | - { |
911 | - ExceptionThrowingActionAttribute.Reset(); |
912 | - ExceptionThrowingActionAttribute.ThrowAfterSuiteException = true; |
913 | - |
914 | - ActionAttributeExceptionFixture.Reset(); |
915 | - |
916 | - TestResult result = FindFailureTestResult(RunTest()); |
917 | - |
918 | - Assert.IsTrue(result.FailureSite == FailureSite.TearDown); |
919 | - Assert.IsTrue(ActionAttributeExceptionFixture.TestRun); |
920 | - } |
921 | - |
922 | - [Test] |
923 | - public void BeforeTestCaseException() |
924 | - { |
925 | - ExceptionThrowingActionAttribute.Reset(); |
926 | - ExceptionThrowingActionAttribute.ThrowBeforeCaseException = true; |
927 | - |
928 | - ActionAttributeExceptionFixture.Reset(); |
929 | - |
930 | - TestResult result = FindFailureTestResult(RunTest()); |
931 | - |
932 | - Assert.IsTrue(result.FailureSite == FailureSite.SetUp); |
933 | - Assert.IsFalse(ActionAttributeExceptionFixture.TestRun); |
934 | - } |
935 | - |
936 | - [Test] |
937 | - public void AfterTestCaseException() |
938 | - { |
939 | - ExceptionThrowingActionAttribute.Reset(); |
940 | - ExceptionThrowingActionAttribute.ThrowAfterCaseException = true; |
941 | + public void BeforeTestException() |
942 | + { |
943 | + ExceptionThrowingActionAttribute.Reset(); |
944 | + ExceptionThrowingActionAttribute.ThrowBeforeException = true; |
945 | + |
946 | + ActionAttributeExceptionFixture.Reset(); |
947 | + |
948 | + TestResult result = FindFailureTestResult(RunTest()); |
949 | + |
950 | + Assert.IsTrue(result.FailureSite == FailureSite.SetUp); |
951 | + Assert.IsFalse(ActionAttributeExceptionFixture.TestRun); |
952 | + } |
953 | + |
954 | + [Test] |
955 | + public void AfterTestException() |
956 | + { |
957 | + ExceptionThrowingActionAttribute.Reset(); |
958 | + ExceptionThrowingActionAttribute.ThrowAfterException = true; |
959 | |
960 | ActionAttributeExceptionFixture.Reset(); |
961 | |
962 | |
963 | === modified file 'src/NUnitCore/tests/ActionAttributeTests.cs' |
964 | --- src/NUnitCore/tests/ActionAttributeTests.cs 2011-08-26 23:38:44 +0000 |
965 | +++ src/NUnitCore/tests/ActionAttributeTests.cs 2012-01-29 17:45:28 +0000 |
966 | @@ -1,7 +1,7 @@ |
967 | #if CLR_2_0 || CLR_4_0 |
968 | using System; |
969 | using System.Collections; |
970 | -using System.Collections.Specialized; |
971 | +using System.Collections.Generic; |
972 | using NUnit.Framework; |
973 | using NUnit.TestData.ActionAttributeTests; |
974 | |
975 | @@ -19,22 +19,32 @@ |
976 | } |
977 | |
978 | private TestResult _result = null; |
979 | - private readonly string[] _definitionSites = new string[] |
980 | + private readonly string[] _suiteSites = new string[] |
981 | { |
982 | "Assembly", |
983 | - "BaseSetUpFixture", |
984 | - "SetUpFixture", |
985 | + "BaseSetupFixture", |
986 | + "SetupFixture", |
987 | "BaseInterface", |
988 | "BaseFixture", |
989 | "Interface", |
990 | - "Fixture", |
991 | - "Method" |
992 | + "Fixture" |
993 | + }; |
994 | + |
995 | + private readonly string[] _parameterizedTestOutput = new string[] |
996 | + { |
997 | + "SomeTest-Case1", |
998 | + "SomeTest-Case2" |
999 | + }; |
1000 | + |
1001 | + private readonly string[] _testOutput = new string[] |
1002 | + { |
1003 | + "SomeTestNotParameterized", |
1004 | }; |
1005 | |
1006 | [TestFixtureSetUp] |
1007 | public void Setup() |
1008 | { |
1009 | - ActionAttributeFixture.Results = new StringCollection(); |
1010 | + ActionAttributeFixture.Results = new List<string>(); |
1011 | |
1012 | TestSuiteBuilder builder = new TestSuiteBuilder(); |
1013 | TestPackage package = new TestPackage(AssemblyHelper.GetAssemblyPath(typeof(ActionAttributeFixture))); |
1014 | @@ -47,173 +57,114 @@ |
1015 | [Test] |
1016 | public void TestsRunsSuccessfully() |
1017 | { |
1018 | - Assert.IsTrue(_result.IsSuccess, "Test run was not successful."); |
1019 | - Assert.Contains("SomeTest-Case1", ActionAttributeFixture.Results, "Test Case 1 was not run."); |
1020 | - Assert.Contains("SomeTest-Case2", ActionAttributeFixture.Results, "Test Case 2 was not run."); |
1021 | - Assert.Contains("SomeOtherTest", ActionAttributeFixture.Results, "SomeOtherTest was not run."); |
1022 | - |
1023 | + Assert.IsTrue(_result.IsSuccess, "Test run was not successful."); |
1024 | + |
1025 | + Console.WriteLine("{prefix}.{phase}.{hasFixture}.{hasMethod}"); |
1026 | foreach(string message in ActionAttributeFixture.Results) |
1027 | Console.WriteLine(message); |
1028 | } |
1029 | |
1030 | - [Test] |
1031 | - public void DefinitionSites_BeforeSuite_ExecuteFirst_InOrder() |
1032 | - { |
1033 | - for (int i = 0; i < _definitionSites.Length - 1; i++) |
1034 | - { |
1035 | - string prefix = string.Format("{0}.BeforeTestSuite-", _definitionSites[i]); |
1036 | - |
1037 | - Assert.IsTrue( |
1038 | - ActionAttributeFixture.Results[i].StartsWith(prefix), |
1039 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1040 | - } |
1041 | - } |
1042 | - |
1043 | - |
1044 | - [Test] |
1045 | - public void DefinitionSites_AfterSuite_ExecuteLast_InOrder() |
1046 | - { |
1047 | - int lastIndex = ActionAttributeFixture.Results.Count - 1; |
1048 | - for (int i = lastIndex; i > lastIndex - _definitionSites.Length; i--) |
1049 | - { |
1050 | - string prefix = string.Format("{0}.AfterTestSuite-", _definitionSites[lastIndex - i]); |
1051 | - |
1052 | - Assert.IsTrue( |
1053 | - ActionAttributeFixture.Results[i].StartsWith(prefix), |
1054 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1055 | - } |
1056 | - } |
1057 | - |
1058 | - [Test] |
1059 | - public void DefinitionSites_BeforeTest_ExecuteInOrder_ForSomeOtherTest() |
1060 | - { |
1061 | - int startIndex = ActionAttributeFixture.Results.IndexOf("SomeOtherTest") - _definitionSites.Length - 1; |
1062 | - for (int i = startIndex; i < startIndex; i++) |
1063 | - { |
1064 | - string prefix = string.Format("{0}.BeforeTestCase-", _definitionSites[i - startIndex]); |
1065 | - |
1066 | - Assert.IsTrue( |
1067 | - ActionAttributeFixture.Results[i].StartsWith(prefix), |
1068 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1069 | - } |
1070 | - } |
1071 | - |
1072 | - [Test] |
1073 | - public void DefinitionSites_AfterTest_ExecuteInOrder_ForSomeOtherTest() |
1074 | - { |
1075 | - int startIndex = ActionAttributeFixture.Results.IndexOf("SomeOtherTest"); |
1076 | - for (int i = 1; i <= _definitionSites.Length - 1; i++) |
1077 | - { |
1078 | - string prefix = string.Format("{0}.AfterTestCase-", _definitionSites[_definitionSites.Length - 1 - i]); |
1079 | - |
1080 | - Assert.IsTrue( |
1081 | - ActionAttributeFixture.Results[startIndex + i].StartsWith(prefix), |
1082 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1083 | - } |
1084 | - } |
1085 | - |
1086 | - [Test] |
1087 | - public void AllDefinitionSites_BeforeTest_ExecuteInOrder_ForSomeTestCase1() |
1088 | - { |
1089 | - int startIndex = ActionAttributeFixture.Results.IndexOf("SomeTest-Case1") - _definitionSites.Length; |
1090 | - for (int i = startIndex; i < startIndex; i++) |
1091 | - { |
1092 | - string prefix = string.Format("{0}.BeforeTestCase-", _definitionSites[i - startIndex]); |
1093 | - |
1094 | - Assert.IsTrue( |
1095 | - ActionAttributeFixture.Results[i].StartsWith(prefix), |
1096 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1097 | - } |
1098 | - } |
1099 | - |
1100 | - [Test] |
1101 | - public void AllDefinitionSites_AfterTest_ExecuteInOrder_ForSomeTestCase1() |
1102 | - { |
1103 | - int startIndex = ActionAttributeFixture.Results.IndexOf("SomeTest-Case1"); |
1104 | - for (int i = 1; i <= _definitionSites.Length; i++) |
1105 | - { |
1106 | - string prefix = string.Format("{0}.AfterTestCase-", _definitionSites[_definitionSites.Length - i]); |
1107 | - |
1108 | - Assert.IsTrue( |
1109 | - ActionAttributeFixture.Results[startIndex + i].StartsWith(prefix), |
1110 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1111 | - } |
1112 | - } |
1113 | - |
1114 | - [Test] |
1115 | - public void AllDefinitionSites_BeforeTest_ExecuteInOrder_ForSomeTestCase2() |
1116 | - { |
1117 | - int startIndex = ActionAttributeFixture.Results.IndexOf("SomeTest-Case2") - _definitionSites.Length; |
1118 | - for (int i = startIndex; i < startIndex; i++) |
1119 | - { |
1120 | - string prefix = string.Format("{0}.BeforeTestCase-", _definitionSites[i - startIndex]); |
1121 | - |
1122 | - Assert.IsTrue( |
1123 | - ActionAttributeFixture.Results[i].StartsWith(prefix), |
1124 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1125 | - } |
1126 | - } |
1127 | - |
1128 | - [Test] |
1129 | - public void AllDefinitionSites_AfterTest_ExecuteInOrder_ForSomeTestCase2() |
1130 | - { |
1131 | - int startIndex = ActionAttributeFixture.Results.IndexOf("SomeTest-Case2"); |
1132 | - for (int i = 1; i <= _definitionSites.Length; i++) |
1133 | - { |
1134 | - string prefix = string.Format("{0}.AfterTestCase-", _definitionSites[_definitionSites.Length - i]); |
1135 | - |
1136 | - Assert.IsTrue( |
1137 | - ActionAttributeFixture.Results[startIndex + i].StartsWith(prefix), |
1138 | - string.Format("Did not find prefix '{0}' at index {1}", prefix, i)); |
1139 | - } |
1140 | - } |
1141 | - |
1142 | - [Test] |
1143 | - public void MethodDefinedSite_BeforeSuite_BeforeSomeTestCase1() |
1144 | - { |
1145 | - int testCase = ActionAttributeFixture.Results.IndexOf("SomeTest-Case1"); |
1146 | - int index = ActionAttributeFixture.Results.IndexOf("Method.BeforeTestSuite-ActionAttributeFixture-SomeTest"); |
1147 | - |
1148 | - Assert.IsTrue(index >= 0); |
1149 | - Assert.IsTrue(testCase > index); |
1150 | - } |
1151 | - |
1152 | - [Test] |
1153 | - public void MethodDefinedSite_AfterSuite_BeforeSomeTestCase2() |
1154 | - { |
1155 | - int testCase = ActionAttributeFixture.Results.IndexOf("SomeTest-Case2"); |
1156 | - int index = ActionAttributeFixture.Results.IndexOf("Method.AfterTestSuite-ActionAttributeFixture-SomeTest"); |
1157 | - |
1158 | - Assert.IsTrue(index >= 0); |
1159 | - Assert.IsTrue(testCase < index); |
1160 | - } |
1161 | - |
1162 | - [Test] |
1163 | - public void AllActions_BeforeAndAfterTest_HasAccessToFixture() |
1164 | - { |
1165 | - foreach(string message in ActionAttributeFixture.Results) |
1166 | - { |
1167 | - if (message.Contains("BeforeTestCase") || message.Contains("AfterTestCase")) |
1168 | - Assert.IsTrue(message.Contains(typeof(ActionAttributeFixture).Name), string.Format("'{0}' shows action does not have access to fixture.", message)); |
1169 | - } |
1170 | - } |
1171 | - |
1172 | - [Test] |
1173 | - public void AllActions_BeforeAndAfterTest_HasAccessToMethodInfo() |
1174 | - { |
1175 | - StringCollection validEndSegments = new StringCollection(); |
1176 | - validEndSegments.AddRange(new string[] {"SomeOtherTest", "SomeTest"}); |
1177 | - |
1178 | - foreach (string message in ActionAttributeFixture.Results) |
1179 | - { |
1180 | - if (message.Contains("BeforeTestCase") || message.Contains("AfterTestCase")) |
1181 | - { |
1182 | - string endSegment = message.Substring(message.LastIndexOf('-') + 1); |
1183 | - |
1184 | - Assert.IsTrue(validEndSegments.Contains(endSegment), |
1185 | - string.Format("'{0}' shows action does not have access to method info.", message)); |
1186 | - } |
1187 | - } |
1188 | + private void AssertResultEquals(List<string> input, int index, string expected) |
1189 | + { |
1190 | + Assert.IsTrue(input[index].Equals(expected), string.Format("Did not find '{0}' at index {1}; instead '{2}'", expected, index, input[index])); |
1191 | + } |
1192 | + |
1193 | + [Test] |
1194 | + public void ExpectedOutput_InCorrectOrder() |
1195 | + { |
1196 | + List<string> expectedResults = new List<string>(@"AssemblySuite.Before.false.false |
1197 | +AssemblySite.Before.false.false |
1198 | +BaseSetupFixtureSuite.Before.true.false |
1199 | +BaseSetupFixtureSite.Before.true.false |
1200 | +SetupFixtureSuite.Before.true.false |
1201 | +SetupFixtureSite.Before.true.false |
1202 | +BaseInterfaceSuite.Before.true.false |
1203 | +BaseInterfaceSite.Before.true.false |
1204 | +BaseFixtureSuite.Before.true.false |
1205 | +BaseFixtureSite.Before.true.false |
1206 | +InterfaceSuite.Before.true.false |
1207 | +InterfaceSite.Before.true.false |
1208 | +FixtureSuite.Before.true.false |
1209 | +FixtureSite.Before.true.false |
1210 | +ParameterizedSuite.Before.true.false |
1211 | +AssemblyTest.Before.true.true |
1212 | +BaseSetupFixtureTest.Before.true.true |
1213 | +SetupFixtureTest.Before.true.true |
1214 | +BaseInterfaceTest.Before.true.true |
1215 | +BaseFixtureTest.Before.true.true |
1216 | +InterfaceTest.Before.true.true |
1217 | +FixtureTest.Before.true.true |
1218 | +ParameterizedTest.Before.true.true |
1219 | +ParameterizedSite.Before.true.true |
1220 | +SomeTest-Case1 |
1221 | +ParameterizedSite.After.true.true |
1222 | +ParameterizedTest.After.true.true |
1223 | +FixtureTest.After.true.true |
1224 | +InterfaceTest.After.true.true |
1225 | +BaseFixtureTest.After.true.true |
1226 | +BaseInterfaceTest.After.true.true |
1227 | +SetupFixtureTest.After.true.true |
1228 | +BaseSetupFixtureTest.After.true.true |
1229 | +AssemblyTest.After.true.true |
1230 | +AssemblyTest.Before.true.true |
1231 | +BaseSetupFixtureTest.Before.true.true |
1232 | +SetupFixtureTest.Before.true.true |
1233 | +BaseInterfaceTest.Before.true.true |
1234 | +BaseFixtureTest.Before.true.true |
1235 | +InterfaceTest.Before.true.true |
1236 | +FixtureTest.Before.true.true |
1237 | +ParameterizedTest.Before.true.true |
1238 | +ParameterizedSite.Before.true.true |
1239 | +SomeTest-Case2 |
1240 | +ParameterizedSite.After.true.true |
1241 | +ParameterizedTest.After.true.true |
1242 | +FixtureTest.After.true.true |
1243 | +InterfaceTest.After.true.true |
1244 | +BaseFixtureTest.After.true.true |
1245 | +BaseInterfaceTest.After.true.true |
1246 | +SetupFixtureTest.After.true.true |
1247 | +BaseSetupFixtureTest.After.true.true |
1248 | +AssemblyTest.After.true.true |
1249 | +ParameterizedSuite.After.true.false |
1250 | +AssemblyTest.Before.true.true |
1251 | +BaseSetupFixtureTest.Before.true.true |
1252 | +SetupFixtureTest.Before.true.true |
1253 | +BaseInterfaceTest.Before.true.true |
1254 | +BaseFixtureTest.Before.true.true |
1255 | +InterfaceTest.Before.true.true |
1256 | +FixtureTest.Before.true.true |
1257 | +MethodTest.Before.true.true |
1258 | +MethodSite.Before.true.true |
1259 | +SomeTestNotParameterized |
1260 | +MethodSite.After.true.true |
1261 | +MethodTest.After.true.true |
1262 | +FixtureTest.After.true.true |
1263 | +InterfaceTest.After.true.true |
1264 | +BaseFixtureTest.After.true.true |
1265 | +BaseInterfaceTest.After.true.true |
1266 | +SetupFixtureTest.After.true.true |
1267 | +BaseSetupFixtureTest.After.true.true |
1268 | +AssemblyTest.After.true.true |
1269 | +FixtureSite.After.true.false |
1270 | +FixtureSuite.After.true.false |
1271 | +InterfaceSite.After.true.false |
1272 | +InterfaceSuite.After.true.false |
1273 | +BaseFixtureSite.After.true.false |
1274 | +BaseFixtureSuite.After.true.false |
1275 | +BaseInterfaceSite.After.true.false |
1276 | +BaseInterfaceSuite.After.true.false |
1277 | +SetupFixtureSite.After.true.false |
1278 | +SetupFixtureSuite.After.true.false |
1279 | +BaseSetupFixtureSite.After.true.false |
1280 | +BaseSetupFixtureSuite.After.true.false |
1281 | +AssemblySite.After.false.false |
1282 | +AssemblySuite.After.false.false".Split(new[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries)); |
1283 | + |
1284 | + |
1285 | + Assert.AreEqual(expectedResults.Count, ActionAttributeFixture.Results.Count); |
1286 | + |
1287 | + for(int i = 0; i < expectedResults.Count; i++) |
1288 | + Assert.IsTrue(expectedResults[i] == ActionAttributeFixture.Results[i]); |
1289 | } |
1290 | } |
1291 | } |
1292 | |
1293 | === added file 'src/NUnitFramework/framework/ActionTargets.cs' |
1294 | --- src/NUnitFramework/framework/ActionTargets.cs 1970-01-01 00:00:00 +0000 |
1295 | +++ src/NUnitFramework/framework/ActionTargets.cs 2012-01-29 17:45:28 +0000 |
1296 | @@ -0,0 +1,28 @@ |
1297 | +#if CLR_2_0 || CLR_4_0 |
1298 | +using System; |
1299 | + |
1300 | +namespace NUnit.Framework |
1301 | +{ |
1302 | + /// <summary> |
1303 | + /// The different targets a test action attribute can be applied to |
1304 | + /// </summary> |
1305 | + [Flags] |
1306 | + public enum ActionTargets |
1307 | + { |
1308 | + /// <summary> |
1309 | + /// Default target, which is determined by where the action attribute is attached |
1310 | + /// </summary> |
1311 | + Default = 0, |
1312 | + |
1313 | + /// <summary> |
1314 | + /// Target a individual test case |
1315 | + /// </summary> |
1316 | + Test = 1, |
1317 | + |
1318 | + /// <summary> |
1319 | + /// Target a suite of test cases |
1320 | + /// </summary> |
1321 | + Suite = 2 |
1322 | + } |
1323 | +} |
1324 | +#endif |
1325 | |
1326 | === added file 'src/NUnitFramework/framework/Attributes/TestActionAttribute.cs' |
1327 | --- src/NUnitFramework/framework/Attributes/TestActionAttribute.cs 1970-01-01 00:00:00 +0000 |
1328 | +++ src/NUnitFramework/framework/Attributes/TestActionAttribute.cs 2012-01-29 17:45:28 +0000 |
1329 | @@ -0,0 +1,23 @@ |
1330 | +#if CLR_2_0 || CLR_4_0 |
1331 | +using System; |
1332 | +using System.Collections.Generic; |
1333 | +using System.Text; |
1334 | + |
1335 | +namespace NUnit.Framework |
1336 | +{ |
1337 | + /// <summary> |
1338 | + /// Provide actions to execute before and after tests. |
1339 | + /// </summary> |
1340 | + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] |
1341 | + public abstract class TestActionAttribute : Attribute, ITestAction |
1342 | + { |
1343 | + public virtual void BeforeTest(TestDetails testDetails) { } |
1344 | + public virtual void AfterTest(TestDetails testDetails) { } |
1345 | + |
1346 | + public virtual ActionTargets Targets |
1347 | + { |
1348 | + get { return ActionTargets.Default; } |
1349 | + } |
1350 | + } |
1351 | +} |
1352 | +#endif |
1353 | \ No newline at end of file |
1354 | |
1355 | === modified file 'src/NUnitFramework/framework/Interfaces/ITestAction.cs' |
1356 | --- src/NUnitFramework/framework/Interfaces/ITestAction.cs 2011-03-30 20:37:44 +0000 |
1357 | +++ src/NUnitFramework/framework/Interfaces/ITestAction.cs 2012-01-29 17:45:28 +0000 |
1358 | @@ -5,15 +5,34 @@ |
1359 | // **************************************************************** |
1360 | |
1361 | #if CLR_2_0 || CLR_4_0 |
1362 | -using System; |
1363 | - |
1364 | +using System; |
1365 | +using System.Reflection; |
1366 | + |
1367 | namespace NUnit.Framework |
1368 | -{ |
1369 | - /// <summary> |
1370 | - /// The base interface for test actions |
1371 | - /// </summary> |
1372 | +{ |
1373 | + /// <summary> |
1374 | + /// When implemented by an attribute, this interface implemented to provide actions to execute before and after tests. |
1375 | + /// </summary> |
1376 | public interface ITestAction |
1377 | - { |
1378 | + { |
1379 | + /// <summary> |
1380 | + /// Executed before each test is run |
1381 | + /// </summary> |
1382 | + /// <param name="testDetails">Provides details about the test that is going to be run.</param> |
1383 | + void BeforeTest(TestDetails testDetails); |
1384 | + |
1385 | + /// <summary> |
1386 | + /// Executed after each test is run |
1387 | + /// </summary> |
1388 | + /// <param name="testDetails">Provides details about the test that has just been run.</param> |
1389 | + void AfterTest(TestDetails testDetails); |
1390 | + |
1391 | + |
1392 | + /// <summary> |
1393 | + /// Provides the target for the action attribute |
1394 | + /// </summary> |
1395 | + /// <returns>The target for the action attribute</returns> |
1396 | + ActionTargets Targets { get; } |
1397 | } |
1398 | } |
1399 | #endif |
1400 | |
1401 | === removed file 'src/NUnitFramework/framework/Interfaces/ITestCaseAction.cs' |
1402 | --- src/NUnitFramework/framework/Interfaces/ITestCaseAction.cs 2011-08-26 23:38:44 +0000 |
1403 | +++ src/NUnitFramework/framework/Interfaces/ITestCaseAction.cs 1970-01-01 00:00:00 +0000 |
1404 | @@ -1,33 +0,0 @@ |
1405 | -// **************************************************************** |
1406 | -// Copyright 2011, Charlie Poole |
1407 | -// This is free software licensed under the NUnit license. You may |
1408 | -// obtain a copy of the license at http://nunit.org |
1409 | -// **************************************************************** |
1410 | - |
1411 | -#if CLR_2_0 || CLR_4_0 |
1412 | -using System; |
1413 | -using System.Reflection; |
1414 | - |
1415 | -namespace NUnit.Framework |
1416 | -{ |
1417 | - /// <summary> |
1418 | - /// The interface implemented to provide actions to execute before and after tests. |
1419 | - /// </summary> |
1420 | - public interface ITestCaseAction : ITestAction |
1421 | - { |
1422 | - /// <summary> |
1423 | - /// Executed before each test case is run |
1424 | - /// </summary> |
1425 | - /// <param name="fixture">The fixture the test is part of, if available.</param> |
1426 | - /// <param name="method">The method that implements the test case, if available.</param> |
1427 | - void BeforeTestCase(object fixture, MethodInfo method); |
1428 | - |
1429 | - /// <summary> |
1430 | - /// Executed after each test case is run |
1431 | - /// </summary> |
1432 | - /// <param name="fixture">The fixture the test is part of, if available.</param> |
1433 | - /// <param name="method">The method that implements the test case, if available.</param> |
1434 | - void AfterTestCase(object fixture, MethodInfo method); |
1435 | - } |
1436 | -} |
1437 | -#endif |
1438 | |
1439 | === removed file 'src/NUnitFramework/framework/Interfaces/ITestSuiteAction.cs' |
1440 | --- src/NUnitFramework/framework/Interfaces/ITestSuiteAction.cs 2011-08-26 23:38:44 +0000 |
1441 | +++ src/NUnitFramework/framework/Interfaces/ITestSuiteAction.cs 1970-01-01 00:00:00 +0000 |
1442 | @@ -1,33 +0,0 @@ |
1443 | -// **************************************************************** |
1444 | -// Copyright 2011, Charlie Poole |
1445 | -// This is free software licensed under the NUnit license. You may |
1446 | -// obtain a copy of the license at http://nunit.org |
1447 | -// **************************************************************** |
1448 | - |
1449 | -#if CLR_2_0 || CLR_4_0 |
1450 | -using System; |
1451 | -using System.Reflection; |
1452 | - |
1453 | -namespace NUnit.Framework |
1454 | -{ |
1455 | - /// <summary> |
1456 | - /// The interface implemented to provide actions to execute before and after suites. |
1457 | - /// </summary> |
1458 | - public interface ITestSuiteAction : ITestAction |
1459 | - { |
1460 | - /// <summary> |
1461 | - /// Executed before each suite is run |
1462 | - /// </summary> |
1463 | - /// <param name="fixture">The fixture that defines the test suite, if available.</param> |
1464 | - /// <param name="method">The method that defines the test suite, if available.</param> |
1465 | - void BeforeTestSuite(object fixture, MethodInfo method); |
1466 | - |
1467 | - /// <summary> |
1468 | - /// Executed after each suite is run |
1469 | - /// </summary> |
1470 | - /// <param name="fixture">The fixture that defines the test suite, if available.</param> |
1471 | - /// <param name="method">The method that defines the test suite, if available.</param> |
1472 | - void AfterTestSuite(object fixture, MethodInfo method); |
1473 | - } |
1474 | -} |
1475 | -#endif |
1476 | |
1477 | === added file 'src/NUnitFramework/framework/TestDetails.cs' |
1478 | --- src/NUnitFramework/framework/TestDetails.cs 1970-01-01 00:00:00 +0000 |
1479 | +++ src/NUnitFramework/framework/TestDetails.cs 2012-01-29 17:45:28 +0000 |
1480 | @@ -0,0 +1,60 @@ |
1481 | +#if CLR_2_0 || CLR_4_0 |
1482 | + |
1483 | +using System; |
1484 | +using System.Collections.Generic; |
1485 | +using System.Reflection; |
1486 | +using System.Text; |
1487 | + |
1488 | +namespace NUnit.Framework |
1489 | +{ |
1490 | + /// <summary> |
1491 | + /// Provides details about a test |
1492 | + /// </summary> |
1493 | + public class TestDetails |
1494 | + { |
1495 | + ///<summary> |
1496 | + /// Creates an instance of TestDetails |
1497 | + ///</summary> |
1498 | + ///<param name="fixture">The fixture that the test is a member of, if available.</param> |
1499 | + ///<param name="method">The method that implements the test, if available.</param> |
1500 | + ///<param name="fullName">The full name of the test.</param> |
1501 | + ///<param name="type">A string representing the type of test, e.g. "Test Case".</param> |
1502 | + ///<param name="isSuite">Indicates if the test represents a suite of tests.</param> |
1503 | + public TestDetails(object fixture, MethodInfo method, string fullName, string type, bool isSuite) |
1504 | + { |
1505 | + Fixture = fixture; |
1506 | + Method = method; |
1507 | + |
1508 | + FullName = fullName; |
1509 | + Type = type; |
1510 | + IsSuite = isSuite; |
1511 | + } |
1512 | + |
1513 | + ///<summary> |
1514 | + /// The fixture that the test is a member of, if available. |
1515 | + ///</summary> |
1516 | + public object Fixture { get; private set; } |
1517 | + |
1518 | + /// <summary> |
1519 | + /// The method that implements the test, if available. |
1520 | + /// </summary> |
1521 | + public MethodInfo Method { get; private set; } |
1522 | + |
1523 | + /// <summary> |
1524 | + /// The full name of the test. |
1525 | + /// </summary> |
1526 | + public string FullName { get; private set; } |
1527 | + |
1528 | + /// <summary> |
1529 | + /// A string representing the type of test, e.g. "Test Case". |
1530 | + /// </summary> |
1531 | + public string Type { get; private set; } |
1532 | + |
1533 | + /// <summary> |
1534 | + /// Indicates if the test represents a suite of tests. |
1535 | + /// </summary> |
1536 | + public bool IsSuite { get; private set; } |
1537 | + } |
1538 | +} |
1539 | + |
1540 | +#endif |
1541 | \ No newline at end of file |
1542 | |
1543 | === modified file 'src/NUnitFramework/framework/nunit.framework.dll.csproj' |
1544 | --- src/NUnitFramework/framework/nunit.framework.dll.csproj 2011-06-11 23:59:16 +0000 |
1545 | +++ src/NUnitFramework/framework/nunit.framework.dll.csproj 2012-01-29 17:45:28 +0000 |
1546 | @@ -1,193 +1,194 @@ |
1547 | -<?xml version="1.0" encoding="utf-8"?> |
1548 | -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> |
1549 | - <PropertyGroup> |
1550 | - <ProjectType>Local</ProjectType> |
1551 | - <ProductVersion>9.0.21022</ProductVersion> |
1552 | - <SchemaVersion>2.0</SchemaVersion> |
1553 | - <ProjectGuid>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</ProjectGuid> |
1554 | - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
1555 | - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
1556 | - <AssemblyKeyContainerName> |
1557 | - </AssemblyKeyContainerName> |
1558 | - <AssemblyName>nunit.framework</AssemblyName> |
1559 | - <DefaultClientScript>JScript</DefaultClientScript> |
1560 | - <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> |
1561 | - <DefaultTargetSchema>IE50</DefaultTargetSchema> |
1562 | - <DelaySign>false</DelaySign> |
1563 | - <OutputType>Library</OutputType> |
1564 | - <RootNamespace>NUnit.Framework</RootNamespace> |
1565 | - <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> |
1566 | - <FileUpgradeFlags> |
1567 | - </FileUpgradeFlags> |
1568 | - <UpgradeBackupLocation> |
1569 | - </UpgradeBackupLocation> |
1570 | - <OldToolsVersion>2.0</OldToolsVersion> |
1571 | - <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> |
1572 | - </PropertyGroup> |
1573 | - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
1574 | - <OutputPath>..\..\..\bin\Debug\framework\</OutputPath> |
1575 | - <BaseAddress>285212672</BaseAddress> |
1576 | - <ConfigurationOverrideFile> |
1577 | - </ConfigurationOverrideFile> |
1578 | - <DefineConstants>TRACE;DEBUG;CLR_2_0</DefineConstants> |
1579 | - <DocumentationFile>..\..\..\bin\Debug\framework\nunit.framework.xml</DocumentationFile> |
1580 | - <DebugSymbols>true</DebugSymbols> |
1581 | - <FileAlignment>4096</FileAlignment> |
1582 | - <NoWarn>1699</NoWarn> |
1583 | - <Optimize>false</Optimize> |
1584 | - <RegisterForComInterop>false</RegisterForComInterop> |
1585 | - <RemoveIntegerChecks>false</RemoveIntegerChecks> |
1586 | - <WarningLevel>4</WarningLevel> |
1587 | - <DebugType>full</DebugType> |
1588 | - <ErrorReport>prompt</ErrorReport> |
1589 | - </PropertyGroup> |
1590 | - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
1591 | - <OutputPath>..\..\..\bin\Release\framework\</OutputPath> |
1592 | - <BaseAddress>285212672</BaseAddress> |
1593 | - <ConfigurationOverrideFile> |
1594 | - </ConfigurationOverrideFile> |
1595 | - <DefineConstants>TRACE;CLR_2_0</DefineConstants> |
1596 | - <DocumentationFile>..\..\..\bin\Release\framework\nunit.framework.xml</DocumentationFile> |
1597 | - <FileAlignment>4096</FileAlignment> |
1598 | - <NoWarn>1699</NoWarn> |
1599 | - <Optimize>true</Optimize> |
1600 | - <RegisterForComInterop>false</RegisterForComInterop> |
1601 | - <RemoveIntegerChecks>false</RemoveIntegerChecks> |
1602 | - <WarningLevel>4</WarningLevel> |
1603 | - <DebugType>none</DebugType> |
1604 | - <ErrorReport>prompt</ErrorReport> |
1605 | - </PropertyGroup> |
1606 | - <ItemGroup> |
1607 | - <Reference Include="System"> |
1608 | - <Name>System</Name> |
1609 | - </Reference> |
1610 | - <Reference Include="System.Data"> |
1611 | - <Name>System.Data</Name> |
1612 | - </Reference> |
1613 | - <Reference Include="System.Xml"> |
1614 | - <Name>System.XML</Name> |
1615 | - </Reference> |
1616 | - </ItemGroup> |
1617 | - <ItemGroup> |
1618 | - <Compile Include="..\..\CommonAssemblyInfo.cs"> |
1619 | - <Link>CommonAssemblyInfo.cs</Link> |
1620 | - </Compile> |
1621 | - <Compile Include="AssemblyInfo.cs" /> |
1622 | - <Compile Include="Assert.cs" /> |
1623 | - <Compile Include="AssertionHelper.cs" /> |
1624 | - <Compile Include="Assume.cs" /> |
1625 | - <Compile Include="Attributes\CategoryAttribute.cs" /> |
1626 | - <Compile Include="Attributes\DatapointAttributes.cs" /> |
1627 | - <Compile Include="Attributes\DescriptionAttribute.cs" /> |
1628 | - <Compile Include="Attributes\ExpectedExceptionAttribute.cs" /> |
1629 | - <Compile Include="Attributes\ExplicitAttribute.cs" /> |
1630 | - <Compile Include="Attributes\IgnoreAttribute.cs" /> |
1631 | - <Compile Include="Attributes\IncludeExcludeAttributes.cs" /> |
1632 | - <Compile Include="Attributes\JoinTypeAttributes.cs" /> |
1633 | - <Compile Include="Attributes\MaxTimeAttribute.cs" /> |
1634 | - <Compile Include="Attributes\PropertyAttribute.cs" /> |
1635 | - <Compile Include="Attributes\RandomAttribute.cs" /> |
1636 | - <Compile Include="Attributes\RangeAttribute.cs" /> |
1637 | - <Compile Include="Attributes\RepeatAttribute.cs" /> |
1638 | - <Compile Include="Attributes\RequiredAddinAttribute.cs" /> |
1639 | - <Compile Include="Attributes\SetCultureAttribute.cs" /> |
1640 | - <Compile Include="Attributes\SetUICultureAttribute.cs" /> |
1641 | - <Compile Include="Attributes\SetUpAttribute.cs" /> |
1642 | - <Compile Include="Attributes\SetUpFixtureAttribute.cs" /> |
1643 | - <Compile Include="Attributes\SuiteAttribute.cs" /> |
1644 | - <Compile Include="Attributes\TearDownAttribute.cs" /> |
1645 | - <Compile Include="Attributes\TestAttribute.cs" /> |
1646 | - <Compile Include="Attributes\TestCaseAttribute.cs" /> |
1647 | - <Compile Include="Attributes\TestCaseSourceAttribute.cs" /> |
1648 | - <Compile Include="Attributes\TestFixtureAttribute.cs" /> |
1649 | - <Compile Include="Attributes\TestFixtureSetUpAttribute.cs" /> |
1650 | - <Compile Include="Attributes\TestFixtureTearDownAttribute.cs" /> |
1651 | - <Compile Include="Attributes\TheoryAttribute.cs" /> |
1652 | - <Compile Include="Attributes\ThreadingAttributes.cs" /> |
1653 | - <Compile Include="Attributes\ValuesAttribute.cs" /> |
1654 | - <Compile Include="Attributes\ValueSourceAttribute.cs" /> |
1655 | - <Compile Include="CollectionAssert.cs" /> |
1656 | - <Compile Include="Constraints\AttributeConstraints.cs" /> |
1657 | - <Compile Include="Constraints\BasicConstraints.cs" /> |
1658 | - <Compile Include="Constraints\BinaryOperations.cs" /> |
1659 | - <Compile Include="Constraints\CollectionConstraints.cs" /> |
1660 | - <Compile Include="Constraints\CollectionTally.cs" /> |
1661 | - <Compile Include="Constraints\ComparisonAdapter.cs" /> |
1662 | - <Compile Include="Constraints\ComparisonConstraints.cs" /> |
1663 | - <Compile Include="Constraints\Constraint.cs" /> |
1664 | - <Compile Include="Constraints\ConstraintBuilder.cs" /> |
1665 | - <Compile Include="Constraints\ConstraintExpression.cs" /> |
1666 | - <Compile Include="Constraints\ConstraintExpressionBase.cs" /> |
1667 | - <Compile Include="Constraints\ConstraintFactory.cs" /> |
1668 | - <Compile Include="Constraints\ConstraintOperators.cs" /> |
1669 | - <Compile Include="Constraints\ContainsConstraint.cs" /> |
1670 | - <Compile Include="Constraints\DelayedConstraint.cs" /> |
1671 | - <Compile Include="Constraints\DirectoryConstraints.cs" /> |
1672 | - <Compile Include="Constraints\EmptyConstraint.cs" /> |
1673 | - <Compile Include="Constraints\EqualConstraint.cs" /> |
1674 | - <Compile Include="Constraints\EqualityAdapter.cs" /> |
1675 | - <Compile Include="Constraints\FloatingPointNumerics.cs" /> |
1676 | - <Compile Include="Constraints\GreaterThanConstraint.cs" /> |
1677 | - <Compile Include="Constraints\GreaterThanOrEqualConstraint.cs" /> |
1678 | - <Compile Include="Constraints\IResolveConstraint.cs" /> |
1679 | - <Compile Include="Constraints\LessThanConstraint.cs" /> |
1680 | - <Compile Include="Constraints\LessThanOrEqualConstraint.cs" /> |
1681 | - <Compile Include="Constraints\MessageWriter.cs" /> |
1682 | - <Compile Include="Constraints\MsgUtils.cs" /> |
1683 | - <Compile Include="Constraints\Numerics.cs" /> |
1684 | - <Compile Include="Constraints\NUnitComparer.cs" /> |
1685 | - <Compile Include="Constraints\NUnitEqualityComparer.cs" /> |
1686 | - <Compile Include="Constraints\PathConstraints.cs" /> |
1687 | - <Compile Include="Constraints\PredicateConstraint.cs" /> |
1688 | - <Compile Include="Constraints\PrefixConstraints.cs" /> |
1689 | - <Compile Include="Constraints\PropertyConstraint.cs" /> |
1690 | - <Compile Include="Constraints\RangeConstraint.cs" /> |
1691 | - <Compile Include="Constraints\ResolvableConstraintExpression.cs" /> |
1692 | - <Compile Include="Constraints\ReusableConstraint.cs" /> |
1693 | - <Compile Include="Constraints\SameAsConstraint.cs" /> |
1694 | - <Compile Include="Constraints\SerializableConstraints.cs" /> |
1695 | - <Compile Include="Constraints\StringConstraints.cs" /> |
1696 | - <Compile Include="Constraints\ThrowsConstraint.cs" /> |
1697 | - <Compile Include="Constraints\Tolerance.cs" /> |
1698 | - <Compile Include="Constraints\TypeConstraints.cs" /> |
1699 | - <Compile Include="Contains.cs" /> |
1700 | - <Compile Include="DirectoryAssert.cs" /> |
1701 | - <Compile Include="Exceptions\AssertionException.cs" /> |
1702 | - <Compile Include="Exceptions\IgnoreException.cs" /> |
1703 | - <Compile Include="Exceptions\InconclusiveException.cs" /> |
1704 | - <Compile Include="Exceptions\SuccessException.cs" /> |
1705 | - <Compile Include="FileAssert.cs" /> |
1706 | - <Compile Include="GlobalSettings.cs" /> |
1707 | - <Compile Include="Has.cs" /> |
1708 | - <Compile Include="Interfaces\INUnitEqualityComparer.cs" /> |
1709 | - <Compile Include="Interfaces\ITestAction.cs" /> |
1710 | - <Compile Include="IExpectException.cs" /> |
1711 | - <Compile Include="Is.cs" /> |
1712 | - <Compile Include="Interfaces\ITestCaseAction.cs" /> |
1713 | - <Compile Include="ITestCaseData.cs" /> |
1714 | - <Compile Include="Interfaces\ITestSuiteAction.cs" /> |
1715 | - <Compile Include="Iz.cs" /> |
1716 | - <Compile Include="List.cs" /> |
1717 | - <Compile Include="ListMapper.cs" /> |
1718 | - <Compile Include="Randomizer.cs" /> |
1719 | - <Compile Include="SpecialValue.cs" /> |
1720 | - <Compile Include="StringAssert.cs" /> |
1721 | - <Compile Include="TestCaseData.cs" /> |
1722 | - <Compile Include="TestContext.cs" /> |
1723 | - <Compile Include="TestState.cs" /> |
1724 | - <Compile Include="TestStatus.cs" /> |
1725 | - <Compile Include="Text.cs" /> |
1726 | - <Compile Include="TextMessageWriter.cs" /> |
1727 | - <Compile Include="Throws.cs" /> |
1728 | - </ItemGroup> |
1729 | - <ItemGroup> |
1730 | - <None Include="nunit.framework.build" /> |
1731 | - </ItemGroup> |
1732 | - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
1733 | - <PropertyGroup> |
1734 | - <PreBuildEvent> |
1735 | - </PreBuildEvent> |
1736 | - <PostBuildEvent> |
1737 | - </PostBuildEvent> |
1738 | - </PropertyGroup> |
1739 | +<?xml version="1.0" encoding="utf-8"?> |
1740 | +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> |
1741 | + <PropertyGroup> |
1742 | + <ProjectType>Local</ProjectType> |
1743 | + <ProductVersion>9.0.30729</ProductVersion> |
1744 | + <SchemaVersion>2.0</SchemaVersion> |
1745 | + <ProjectGuid>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</ProjectGuid> |
1746 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
1747 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
1748 | + <AssemblyKeyContainerName> |
1749 | + </AssemblyKeyContainerName> |
1750 | + <AssemblyName>nunit.framework</AssemblyName> |
1751 | + <DefaultClientScript>JScript</DefaultClientScript> |
1752 | + <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> |
1753 | + <DefaultTargetSchema>IE50</DefaultTargetSchema> |
1754 | + <DelaySign>false</DelaySign> |
1755 | + <OutputType>Library</OutputType> |
1756 | + <RootNamespace>NUnit.Framework</RootNamespace> |
1757 | + <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> |
1758 | + <FileUpgradeFlags> |
1759 | + </FileUpgradeFlags> |
1760 | + <UpgradeBackupLocation> |
1761 | + </UpgradeBackupLocation> |
1762 | + <OldToolsVersion>2.0</OldToolsVersion> |
1763 | + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> |
1764 | + </PropertyGroup> |
1765 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
1766 | + <OutputPath>..\..\..\bin\Debug\framework\</OutputPath> |
1767 | + <BaseAddress>285212672</BaseAddress> |
1768 | + <ConfigurationOverrideFile> |
1769 | + </ConfigurationOverrideFile> |
1770 | + <DefineConstants>TRACE;DEBUG;CLR_2_0</DefineConstants> |
1771 | + <DocumentationFile>..\..\..\bin\Debug\framework\nunit.framework.xml</DocumentationFile> |
1772 | + <DebugSymbols>true</DebugSymbols> |
1773 | + <FileAlignment>4096</FileAlignment> |
1774 | + <NoWarn>1699</NoWarn> |
1775 | + <Optimize>false</Optimize> |
1776 | + <RegisterForComInterop>false</RegisterForComInterop> |
1777 | + <RemoveIntegerChecks>false</RemoveIntegerChecks> |
1778 | + <WarningLevel>4</WarningLevel> |
1779 | + <DebugType>full</DebugType> |
1780 | + <ErrorReport>prompt</ErrorReport> |
1781 | + </PropertyGroup> |
1782 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
1783 | + <OutputPath>..\..\..\bin\Release\framework\</OutputPath> |
1784 | + <BaseAddress>285212672</BaseAddress> |
1785 | + <ConfigurationOverrideFile> |
1786 | + </ConfigurationOverrideFile> |
1787 | + <DefineConstants>TRACE;CLR_2_0</DefineConstants> |
1788 | + <DocumentationFile>..\..\..\bin\Release\framework\nunit.framework.xml</DocumentationFile> |
1789 | + <FileAlignment>4096</FileAlignment> |
1790 | + <NoWarn>1699</NoWarn> |
1791 | + <Optimize>true</Optimize> |
1792 | + <RegisterForComInterop>false</RegisterForComInterop> |
1793 | + <RemoveIntegerChecks>false</RemoveIntegerChecks> |
1794 | + <WarningLevel>4</WarningLevel> |
1795 | + <DebugType>none</DebugType> |
1796 | + <ErrorReport>prompt</ErrorReport> |
1797 | + </PropertyGroup> |
1798 | + <ItemGroup> |
1799 | + <Reference Include="System"> |
1800 | + <Name>System</Name> |
1801 | + </Reference> |
1802 | + <Reference Include="System.Data"> |
1803 | + <Name>System.Data</Name> |
1804 | + </Reference> |
1805 | + <Reference Include="System.Xml"> |
1806 | + <Name>System.XML</Name> |
1807 | + </Reference> |
1808 | + </ItemGroup> |
1809 | + <ItemGroup> |
1810 | + <Compile Include="..\..\CommonAssemblyInfo.cs"> |
1811 | + <Link>CommonAssemblyInfo.cs</Link> |
1812 | + </Compile> |
1813 | + <Compile Include="AssemblyInfo.cs" /> |
1814 | + <Compile Include="Assert.cs" /> |
1815 | + <Compile Include="AssertionHelper.cs" /> |
1816 | + <Compile Include="Assume.cs" /> |
1817 | + <Compile Include="ActionTargets.cs" /> |
1818 | + <Compile Include="Attributes\CategoryAttribute.cs" /> |
1819 | + <Compile Include="Attributes\DatapointAttributes.cs" /> |
1820 | + <Compile Include="Attributes\DescriptionAttribute.cs" /> |
1821 | + <Compile Include="Attributes\ExpectedExceptionAttribute.cs" /> |
1822 | + <Compile Include="Attributes\ExplicitAttribute.cs" /> |
1823 | + <Compile Include="Attributes\IgnoreAttribute.cs" /> |
1824 | + <Compile Include="Attributes\IncludeExcludeAttributes.cs" /> |
1825 | + <Compile Include="Attributes\JoinTypeAttributes.cs" /> |
1826 | + <Compile Include="Attributes\MaxTimeAttribute.cs" /> |
1827 | + <Compile Include="Attributes\PropertyAttribute.cs" /> |
1828 | + <Compile Include="Attributes\RandomAttribute.cs" /> |
1829 | + <Compile Include="Attributes\RangeAttribute.cs" /> |
1830 | + <Compile Include="Attributes\RepeatAttribute.cs" /> |
1831 | + <Compile Include="Attributes\RequiredAddinAttribute.cs" /> |
1832 | + <Compile Include="Attributes\SetCultureAttribute.cs" /> |
1833 | + <Compile Include="Attributes\SetUICultureAttribute.cs" /> |
1834 | + <Compile Include="Attributes\SetUpAttribute.cs" /> |
1835 | + <Compile Include="Attributes\SetUpFixtureAttribute.cs" /> |
1836 | + <Compile Include="Attributes\SuiteAttribute.cs" /> |
1837 | + <Compile Include="Attributes\TearDownAttribute.cs" /> |
1838 | + <Compile Include="Attributes\TestActionAttribute.cs" /> |
1839 | + <Compile Include="Attributes\TestAttribute.cs" /> |
1840 | + <Compile Include="Attributes\TestCaseAttribute.cs" /> |
1841 | + <Compile Include="Attributes\TestCaseSourceAttribute.cs" /> |
1842 | + <Compile Include="Attributes\TestFixtureAttribute.cs" /> |
1843 | + <Compile Include="Attributes\TestFixtureSetUpAttribute.cs" /> |
1844 | + <Compile Include="Attributes\TestFixtureTearDownAttribute.cs" /> |
1845 | + <Compile Include="Attributes\TheoryAttribute.cs" /> |
1846 | + <Compile Include="Attributes\ThreadingAttributes.cs" /> |
1847 | + <Compile Include="Attributes\ValuesAttribute.cs" /> |
1848 | + <Compile Include="Attributes\ValueSourceAttribute.cs" /> |
1849 | + <Compile Include="CollectionAssert.cs" /> |
1850 | + <Compile Include="Constraints\AttributeConstraints.cs" /> |
1851 | + <Compile Include="Constraints\BasicConstraints.cs" /> |
1852 | + <Compile Include="Constraints\BinaryOperations.cs" /> |
1853 | + <Compile Include="Constraints\CollectionConstraints.cs" /> |
1854 | + <Compile Include="Constraints\CollectionTally.cs" /> |
1855 | + <Compile Include="Constraints\ComparisonAdapter.cs" /> |
1856 | + <Compile Include="Constraints\ComparisonConstraints.cs" /> |
1857 | + <Compile Include="Constraints\Constraint.cs" /> |
1858 | + <Compile Include="Constraints\ConstraintBuilder.cs" /> |
1859 | + <Compile Include="Constraints\ConstraintExpression.cs" /> |
1860 | + <Compile Include="Constraints\ConstraintExpressionBase.cs" /> |
1861 | + <Compile Include="Constraints\ConstraintFactory.cs" /> |
1862 | + <Compile Include="Constraints\ConstraintOperators.cs" /> |
1863 | + <Compile Include="Constraints\ContainsConstraint.cs" /> |
1864 | + <Compile Include="Constraints\DelayedConstraint.cs" /> |
1865 | + <Compile Include="Constraints\DirectoryConstraints.cs" /> |
1866 | + <Compile Include="Constraints\EmptyConstraint.cs" /> |
1867 | + <Compile Include="Constraints\EqualConstraint.cs" /> |
1868 | + <Compile Include="Constraints\EqualityAdapter.cs" /> |
1869 | + <Compile Include="Constraints\FloatingPointNumerics.cs" /> |
1870 | + <Compile Include="Constraints\GreaterThanConstraint.cs" /> |
1871 | + <Compile Include="Constraints\GreaterThanOrEqualConstraint.cs" /> |
1872 | + <Compile Include="Constraints\IResolveConstraint.cs" /> |
1873 | + <Compile Include="Constraints\LessThanConstraint.cs" /> |
1874 | + <Compile Include="Constraints\LessThanOrEqualConstraint.cs" /> |
1875 | + <Compile Include="Constraints\MessageWriter.cs" /> |
1876 | + <Compile Include="Constraints\MsgUtils.cs" /> |
1877 | + <Compile Include="Constraints\Numerics.cs" /> |
1878 | + <Compile Include="Constraints\NUnitComparer.cs" /> |
1879 | + <Compile Include="Constraints\NUnitEqualityComparer.cs" /> |
1880 | + <Compile Include="Constraints\PathConstraints.cs" /> |
1881 | + <Compile Include="Constraints\PredicateConstraint.cs" /> |
1882 | + <Compile Include="Constraints\PrefixConstraints.cs" /> |
1883 | + <Compile Include="Constraints\PropertyConstraint.cs" /> |
1884 | + <Compile Include="Constraints\RangeConstraint.cs" /> |
1885 | + <Compile Include="Constraints\ResolvableConstraintExpression.cs" /> |
1886 | + <Compile Include="Constraints\ReusableConstraint.cs" /> |
1887 | + <Compile Include="Constraints\SameAsConstraint.cs" /> |
1888 | + <Compile Include="Constraints\SerializableConstraints.cs" /> |
1889 | + <Compile Include="Constraints\StringConstraints.cs" /> |
1890 | + <Compile Include="Constraints\ThrowsConstraint.cs" /> |
1891 | + <Compile Include="Constraints\Tolerance.cs" /> |
1892 | + <Compile Include="Constraints\TypeConstraints.cs" /> |
1893 | + <Compile Include="Contains.cs" /> |
1894 | + <Compile Include="DirectoryAssert.cs" /> |
1895 | + <Compile Include="Exceptions\AssertionException.cs" /> |
1896 | + <Compile Include="Exceptions\IgnoreException.cs" /> |
1897 | + <Compile Include="Exceptions\InconclusiveException.cs" /> |
1898 | + <Compile Include="Exceptions\SuccessException.cs" /> |
1899 | + <Compile Include="FileAssert.cs" /> |
1900 | + <Compile Include="GlobalSettings.cs" /> |
1901 | + <Compile Include="Has.cs" /> |
1902 | + <Compile Include="Interfaces\INUnitEqualityComparer.cs" /> |
1903 | + <Compile Include="Interfaces\ITestAction.cs" /> |
1904 | + <Compile Include="IExpectException.cs" /> |
1905 | + <Compile Include="TestDetails.cs" /> |
1906 | + <Compile Include="Is.cs" /> |
1907 | + <Compile Include="ITestCaseData.cs" /> |
1908 | + <Compile Include="Iz.cs" /> |
1909 | + <Compile Include="List.cs" /> |
1910 | + <Compile Include="ListMapper.cs" /> |
1911 | + <Compile Include="Randomizer.cs" /> |
1912 | + <Compile Include="SpecialValue.cs" /> |
1913 | + <Compile Include="StringAssert.cs" /> |
1914 | + <Compile Include="TestCaseData.cs" /> |
1915 | + <Compile Include="TestContext.cs" /> |
1916 | + <Compile Include="TestState.cs" /> |
1917 | + <Compile Include="TestStatus.cs" /> |
1918 | + <Compile Include="Text.cs" /> |
1919 | + <Compile Include="TextMessageWriter.cs" /> |
1920 | + <Compile Include="Throws.cs" /> |
1921 | + </ItemGroup> |
1922 | + <ItemGroup> |
1923 | + <None Include="nunit.framework.build" /> |
1924 | + </ItemGroup> |
1925 | + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
1926 | + <PropertyGroup> |
1927 | + <PreBuildEvent> |
1928 | + </PreBuildEvent> |
1929 | + <PostBuildEvent> |
1930 | + </PostBuildEvent> |
1931 | + </PropertyGroup> |
1932 | </Project> |
1933 | \ No newline at end of file |
1934 | |
1935 | === modified file 'src/tests/test-assembly/ActionAttributeExceptionFixture.cs' |
1936 | --- src/tests/test-assembly/ActionAttributeExceptionFixture.cs 2011-08-26 19:45:20 +0000 |
1937 | +++ src/tests/test-assembly/ActionAttributeExceptionFixture.cs 2012-01-29 17:45:28 +0000 |
1938 | @@ -1,8 +1,8 @@ |
1939 | #if CLR_2_0 || CLR_4_0 |
1940 | using System; |
1941 | using System.Reflection; |
1942 | -using NUnit.Framework; |
1943 | - |
1944 | +using NUnit.Framework; |
1945 | + |
1946 | namespace NUnit.TestData |
1947 | { |
1948 | [ExceptionThrowingAction] |
1949 | @@ -29,7 +29,7 @@ |
1950 | [TearDown] |
1951 | public void TearDown() |
1952 | { |
1953 | - TearDownRun = false; |
1954 | + TearDownRun = true; |
1955 | } |
1956 | |
1957 | [ExceptionThrowingAction] |
1958 | @@ -41,67 +41,39 @@ |
1959 | } |
1960 | |
1961 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] |
1962 | - public class ExceptionThrowingActionAttribute : Attribute, ITestSuiteAction, ITestCaseAction |
1963 | + public class ExceptionThrowingActionAttribute : TestActionAttribute |
1964 | { |
1965 | - private static bool _ThrowBeforeSuiteException; |
1966 | - private static bool _ThrowAfterSuiteException; |
1967 | - private static bool _ThrowBeforeCaseException; |
1968 | - private static bool _ThrowAfterCaseException; |
1969 | + private static bool _ThrowBeforeException; |
1970 | + private static bool _ThrowAfterException; |
1971 | |
1972 | public static void Reset() |
1973 | { |
1974 | - ThrowBeforeSuiteException = false; |
1975 | - ThrowAfterSuiteException = false; |
1976 | - ThrowBeforeCaseException = false; |
1977 | - ThrowAfterCaseException = false; |
1978 | - } |
1979 | - |
1980 | - public void BeforeTestSuite(object fixture, MethodInfo method) |
1981 | - { |
1982 | - if (ThrowBeforeSuiteException) |
1983 | - throw new InvalidOperationException("Failure in BeforeTestSuite."); |
1984 | - } |
1985 | - |
1986 | - public void AfterTestSuite(object fixture, MethodInfo method) |
1987 | - { |
1988 | - if (ThrowAfterSuiteException) |
1989 | - throw new InvalidOperationException("Failure in AfterTestSuite."); |
1990 | - } |
1991 | - |
1992 | - public void BeforeTestCase(object fixture, MethodInfo method) |
1993 | - { |
1994 | - if (ThrowBeforeCaseException) |
1995 | - throw new InvalidOperationException("Failure in BeforeTestCase."); |
1996 | - } |
1997 | - |
1998 | - public void AfterTestCase(object fixture, MethodInfo method) |
1999 | - { |
2000 | - if (ThrowAfterCaseException) |
2001 | - throw new InvalidOperationException("Failure in AfterTestCase."); |
2002 | - } |
2003 | - |
2004 | - public static bool ThrowBeforeSuiteException |
2005 | - { |
2006 | - get { return _ThrowBeforeSuiteException; } |
2007 | - set { _ThrowBeforeSuiteException = value; } |
2008 | - } |
2009 | - |
2010 | - public static bool ThrowAfterSuiteException |
2011 | - { |
2012 | - get { return _ThrowAfterSuiteException; } |
2013 | - set { _ThrowAfterSuiteException = value; } |
2014 | - } |
2015 | - |
2016 | - public static bool ThrowBeforeCaseException |
2017 | - { |
2018 | - get { return _ThrowBeforeCaseException; } |
2019 | - set { _ThrowBeforeCaseException = value; } |
2020 | - } |
2021 | - |
2022 | - public static bool ThrowAfterCaseException |
2023 | - { |
2024 | - get { return _ThrowAfterCaseException; } |
2025 | - set { _ThrowAfterCaseException = value; } |
2026 | + ThrowBeforeException = false; |
2027 | + ThrowAfterException = false; |
2028 | + } |
2029 | + |
2030 | + public override void BeforeTest(TestDetails testDetails) |
2031 | + { |
2032 | + if (ThrowBeforeException) |
2033 | + throw new InvalidOperationException("Failure in BeforeTest."); |
2034 | + } |
2035 | + |
2036 | + public override void AfterTest(TestDetails testDetails) |
2037 | + { |
2038 | + if (ThrowAfterException) |
2039 | + throw new InvalidOperationException("Failure in AfterTest."); |
2040 | + } |
2041 | + |
2042 | + public static bool ThrowBeforeException |
2043 | + { |
2044 | + get { return _ThrowBeforeException; } |
2045 | + set { _ThrowBeforeException = value; } |
2046 | + } |
2047 | + |
2048 | + public static bool ThrowAfterException |
2049 | + { |
2050 | + get { return _ThrowAfterException; } |
2051 | + set { _ThrowAfterException = value; } |
2052 | } |
2053 | } |
2054 | } |
2055 | |
2056 | === modified file 'src/tests/test-assembly/ActionAttributeFixture.cs' |
2057 | --- src/tests/test-assembly/ActionAttributeFixture.cs 2011-08-26 23:38:44 +0000 |
2058 | +++ src/tests/test-assembly/ActionAttributeFixture.cs 2012-01-29 17:45:28 +0000 |
2059 | @@ -1,111 +1,126 @@ |
2060 | #if CLR_2_0 || CLR_4_0 |
2061 | using System; |
2062 | -using System.Collections.Specialized; |
2063 | +using System.Collections.Generic; |
2064 | using NUnit.Framework; |
2065 | using System.Diagnostics; |
2066 | -using System.Reflection; |
2067 | +using System.Reflection; |
2068 | using NUnit.TestData.ActionAttributeTests; |
2069 | |
2070 | -[assembly: SampleAction("Assembly")] |
2071 | +[assembly: SampleAction("AssemblySuite", ActionTargets.Suite)] |
2072 | +[assembly: SampleAction("AssemblyTest", ActionTargets.Test)] |
2073 | +[assembly: SampleAction("AssemblySite")] |
2074 | |
2075 | namespace NUnit.TestData.ActionAttributeTests |
2076 | { |
2077 | - [SetUpFixture] |
2078 | - [SampleAction("SetUpFixture")] |
2079 | + [SetUpFixture] |
2080 | + [SampleAction("SetupFixtureSuite", ActionTargets.Suite)] |
2081 | + [SampleAction("SetupFixtureTest", ActionTargets.Test)] |
2082 | + [SampleAction("SetupFixtureSite")] |
2083 | public class SetupFixture : BaseSetupFixture |
2084 | { |
2085 | - } |
2086 | - |
2087 | - [SampleAction("BaseSetUpFixture")] |
2088 | + } |
2089 | + |
2090 | + [SampleAction("BaseSetupFixtureSuite", ActionTargets.Suite)] |
2091 | + [SampleAction("BaseSetupFixtureTest", ActionTargets.Test)] |
2092 | + [SampleAction("BaseSetupFixtureSite")] |
2093 | public abstract class BaseSetupFixture |
2094 | { |
2095 | } |
2096 | |
2097 | - [TestFixture] |
2098 | - [SampleAction("Fixture")] |
2099 | + [TestFixture] |
2100 | + [SampleAction("FixtureSuite", ActionTargets.Suite)] |
2101 | + [SampleAction("FixtureTest", ActionTargets.Test)] |
2102 | + [SampleAction("FixtureSite")] |
2103 | public class ActionAttributeFixture : BaseActionAttributeFixture, IWithAction |
2104 | { |
2105 | - private static StringCollection _Results = null; |
2106 | - public static StringCollection Results |
2107 | + private static List<string> _Results = null; |
2108 | + public static List<string> Results |
2109 | { |
2110 | get { return _Results; } |
2111 | set { _Results = value; } |
2112 | } |
2113 | |
2114 | - StringCollection IWithAction.Results { get { return Results; } } |
2115 | + List<string> IWithAction.Results { get { return Results; } } |
2116 | |
2117 | - [Test, TestCase("SomeTest-Case1"), TestCase("SomeTest-Case2")] |
2118 | - [SampleAction("Method")] |
2119 | + [Test, TestCase("SomeTest-Case1"), TestCase("SomeTest-Case2")] |
2120 | + [SampleAction("ParameterizedSuite", ActionTargets.Suite)] |
2121 | + [SampleAction("ParameterizedTest", ActionTargets.Test)] |
2122 | + [SampleAction("ParameterizedSite")] |
2123 | public void SomeTest(string message) |
2124 | { |
2125 | ((IWithAction)this).Results.Add(message); |
2126 | } |
2127 | |
2128 | - [Test] |
2129 | - public void SomeOtherTest() |
2130 | - { |
2131 | - ((IWithAction)this).Results.Add("SomeOtherTest"); |
2132 | + [Test] |
2133 | + [SampleAction("MethodSuite", ActionTargets.Suite)] // should never get invoked |
2134 | + [SampleAction("MethodTest", ActionTargets.Test)] |
2135 | + [SampleAction("MethodSite")] |
2136 | + public void SomeTestNotParameterized() |
2137 | + { |
2138 | + ((IWithAction)this).Results.Add("SomeTestNotParameterized"); |
2139 | } |
2140 | - |
2141 | - } |
2142 | - |
2143 | - [SampleAction("BaseFixture")] |
2144 | + } |
2145 | + |
2146 | + [SampleAction("BaseFixtureSuite", ActionTargets.Suite)] |
2147 | + [SampleAction("BaseFixtureTest", ActionTargets.Test)] |
2148 | + [SampleAction("BaseFixtureSite")] |
2149 | public abstract class BaseActionAttributeFixture : IBaseWithAction |
2150 | { |
2151 | - } |
2152 | - |
2153 | - [SampleAction("Interface")] |
2154 | - public interface IWithAction : IBaseWithAction |
2155 | + } |
2156 | + |
2157 | + [SampleAction("InterfaceSuite", ActionTargets.Suite)] |
2158 | + [SampleAction("InterfaceTest", ActionTargets.Test)] |
2159 | + [SampleAction("InterfaceSite")] |
2160 | + public interface IWithAction |
2161 | { |
2162 | - StringCollection Results { get; } |
2163 | - } |
2164 | - |
2165 | - [SampleAction("BaseInterface")] |
2166 | + List<string> Results { get; } |
2167 | + } |
2168 | + |
2169 | + [SampleAction("BaseInterfaceSuite", ActionTargets.Suite)] |
2170 | + [SampleAction("BaseInterfaceTest", ActionTargets.Test)] |
2171 | + [SampleAction("BaseInterfaceSite")] |
2172 | public interface IBaseWithAction |
2173 | { |
2174 | } |
2175 | |
2176 | - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module, AllowMultiple = true, Inherited = true)] |
2177 | - public class SampleActionAttribute : Attribute, ITestSuiteAction, ITestCaseAction |
2178 | + public class SampleActionAttribute : TestActionAttribute |
2179 | { |
2180 | - private string _Prefix = null; |
2181 | + private readonly string _Prefix = null; |
2182 | + private readonly ActionTargets _Targets = ActionTargets.Default; |
2183 | |
2184 | public SampleActionAttribute(string prefix) |
2185 | { |
2186 | _Prefix = prefix; |
2187 | - } |
2188 | - |
2189 | - void ITestSuiteAction.BeforeTestSuite(object fixture, MethodInfo method) |
2190 | - { |
2191 | - AddResult(fixture, method); |
2192 | - } |
2193 | - |
2194 | - void ITestSuiteAction.AfterTestSuite(object fixture, MethodInfo method) |
2195 | - { |
2196 | - AddResult(fixture, method); |
2197 | - } |
2198 | - |
2199 | - void ITestCaseAction.BeforeTestCase(object fixture, MethodInfo method) |
2200 | - { |
2201 | - AddResult(fixture, method); |
2202 | - } |
2203 | - |
2204 | - void ITestCaseAction.AfterTestCase(object fixture, MethodInfo method) |
2205 | - { |
2206 | - AddResult(fixture, method); |
2207 | - } |
2208 | - |
2209 | - private void AddResult(object fixture, MethodInfo method) |
2210 | - { |
2211 | - StackFrame frame = new StackFrame(1); |
2212 | - MethodBase actionMethod = frame.GetMethod(); |
2213 | - |
2214 | - string actionMethodName = actionMethod.Name.Substring(actionMethod.Name.LastIndexOf('.') + 1); |
2215 | - string message = string.Format("{0}.{1}-{2}" + (method != null ? "-{3}" : ""), |
2216 | + } |
2217 | + |
2218 | + public SampleActionAttribute(string prefix, ActionTargets targets) |
2219 | + { |
2220 | + _Prefix = prefix; |
2221 | + _Targets = targets; |
2222 | + } |
2223 | + |
2224 | + public override void BeforeTest(TestDetails testDetails) |
2225 | + { |
2226 | + AddResult("Before", testDetails); |
2227 | + } |
2228 | + |
2229 | + public override void AfterTest(TestDetails testDetails) |
2230 | + { |
2231 | + AddResult("After", testDetails); |
2232 | + } |
2233 | + |
2234 | + public override ActionTargets Targets |
2235 | + { |
2236 | + get { return _Targets; } |
2237 | + } |
2238 | + |
2239 | + private void AddResult(string phase, TestDetails testDetails) |
2240 | + { |
2241 | + string message = string.Format("{0}.{1}.{2}.{3}", |
2242 | _Prefix, |
2243 | - actionMethodName, |
2244 | - fixture == null ? "{no-fixture}" : fixture.GetType().Name, |
2245 | - method != null ? method.Name : ""); |
2246 | + phase, |
2247 | + testDetails.Fixture != null ? "true" : "false", |
2248 | + testDetails.Method != null ? "true" : "false"); |
2249 | |
2250 | if(ActionAttributeFixture.Results != null) |
2251 | ActionAttributeFixture.Results.Add(message); |