forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigInvoker.java
631 lines (570 loc) · 24.1 KB
/
ConfigInvoker.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
package org.testng.internal.invokers;
import static org.testng.internal.invokers.InvokedMethodListenerMethod.AFTER_INVOCATION;
import static org.testng.internal.invokers.InvokedMethodListenerMethod.BEFORE_INVOCATION;
import static org.testng.internal.invokers.Invoker.SAME_CLASS;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.testng.ConfigurationNotInvokedException;
import org.testng.IClass;
import org.testng.IConfigurable;
import org.testng.IInvokedMethodListener;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.SuiteRunState;
import org.testng.TestNGException;
import org.testng.annotations.IConfigurationAnnotation;
import org.testng.collections.Lists;
import org.testng.collections.Maps;
import org.testng.collections.Sets;
import org.testng.internal.*;
import org.testng.internal.annotations.AnnotationHelper;
import org.testng.internal.invokers.ConfigMethodArguments.Builder;
import org.testng.internal.thread.ThreadUtil;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
class ConfigInvoker extends BaseInvoker implements IConfigInvoker {
/** Test methods whose configuration methods have failed. */
protected final Map<ITestNGMethod, Set<Object>> m_methodInvocationResults =
Maps.newConcurrentMap();
private final boolean m_continueOnFailedConfiguration;
private final Set<ITestNGMethod> m_executedConfigMethods = ConcurrentHashMap.newKeySet();
/** Group failures must be synced as the Invoker is accessed concurrently */
private final Map<String, Boolean> m_beforegroupsFailures = Maps.newConcurrentMap();
public ConfigInvoker(
ITestResultNotifier notifier,
Collection<IInvokedMethodListener> invokedMethodListeners,
ITestContext testContext,
SuiteRunState suiteState,
IConfiguration configuration) {
super(notifier, invokedMethodListeners, testContext, suiteState, configuration);
this.m_continueOnFailedConfiguration =
testContext.getSuite().getXmlSuite().getConfigFailurePolicy()
== XmlSuite.FailurePolicy.CONTINUE;
}
/**
* @return false if this class has successfully run all its @Configuration method or true if at
* least one of these methods failed.
*/
public boolean hasConfigurationFailureFor(
ITestNGMethod testNGMethod, String[] groups, IClass testClass, Object instance) {
boolean result = false;
Class<?> cls = testClass.getRealClass();
if (m_suiteState.isFailed()) {
result = true;
} else {
boolean hasConfigurationFailures = classConfigurationFailed(cls, instance);
if (hasConfigurationFailures) {
if (!m_continueOnFailedConfiguration) {
result = true;
} else {
Set<Object> set = getInvocationResults(testClass);
result = set.contains(instance);
}
return result;
}
// if method is BeforeClass, currentTestMethod will be null
if (m_continueOnFailedConfiguration && hasConfigFailure(testNGMethod)) {
Object key = TestNgMethodUtils.getMethodInvocationToken(testNGMethod, instance);
result = m_methodInvocationResults.get(testNGMethod).contains(key);
} else if (!m_continueOnFailedConfiguration) {
for (Class<?> clazz : m_classInvocationResults.keySet()) {
if (clazz.isAssignableFrom(cls)
&& m_classInvocationResults.get(clazz).contains(instance)) {
result = true;
break;
}
}
}
}
// check if there are failed @BeforeGroups
for (String group : groups) {
if (m_beforegroupsFailures.containsKey(group)) {
result = true;
break;
}
}
return result;
}
/**
* Filter all the beforeGroups methods and invoke only those that apply to the current test method
*
* @param arguments - A {@link GroupConfigMethodArguments} object.
*/
public void invokeBeforeGroupsConfigurations(GroupConfigMethodArguments arguments) {
List<ITestNGMethod> filteredMethods = Lists.newArrayList();
String[] groups = arguments.getTestMethod().getGroups();
for (String group : groups) {
List<ITestNGMethod> methods =
arguments.getGroupMethods().getBeforeGroupMethodsForGroup(group);
if (methods != null) {
filteredMethods.addAll(methods);
}
}
ITestNGMethod[] beforeMethodsArray = filteredMethods.toArray(new ITestNGMethod[0]);
//
// Invoke the right groups methods
//
if (beforeMethodsArray.length > 0) {
ITestNGMethod[] filteredConfigurations =
Arrays.stream(beforeMethodsArray)
.filter(ConfigInvoker::isGroupLevelConfigurationMethod)
.toArray(ITestNGMethod[]::new);
if (filteredConfigurations.length == 0) {
return;
}
// don't pass the IClass or the instance as the method may be external
// the invocation must be similar to @BeforeTest/@BeforeSuite
ConfigMethodArguments configMethodArguments =
new Builder()
.usingConfigMethodsAs(filteredConfigurations)
.forSuite(arguments.getSuite())
.usingParameters(arguments.getParameters())
.usingInstance(arguments.getInstance())
.forTestMethod(arguments.getTestMethod())
.build();
invokeConfigurations(configMethodArguments);
}
//
// Remove them so they don't get run again
//
arguments.getGroupMethods().removeBeforeGroups(groups);
}
private static boolean isGroupLevelConfigurationMethod(ITestNGMethod itm) {
return itm.hasBeforeGroupsConfiguration() || itm.hasAfterGroupsConfiguration();
}
public void invokeAfterGroupsConfigurations(GroupConfigMethodArguments arguments) {
// Skip this if the current method doesn't belong to any group
// (only a method that belongs to a group can trigger the invocation
// of afterGroups methods)
if (arguments.getTestMethod().getGroups().length == 0) {
return;
}
// See if the currentMethod is the last method in any of the groups
// it belongs to
Map<String, String> filteredGroups = Maps.newHashMap();
String[] groups = arguments.getTestMethod().getGroups();
for (String group : groups) {
if (arguments.getGroupMethods().isLastMethodForGroup(group, arguments.getTestMethod())) {
filteredGroups.put(group, group);
}
}
if (filteredGroups.isEmpty()) {
return;
}
// The list of afterMethods to run
Map<ITestNGMethod, ITestNGMethod> afterMethods = Maps.newHashMap();
// Now filteredGroups contains all the groups for which we need to run the afterGroups
// method. Find all the methods that correspond to these groups and invoke them.
for (String g : filteredGroups.values()) {
List<ITestNGMethod> methods = arguments.getGroupMethods().getAfterGroupMethodsForGroup(g);
// Note: should put them in a map if we want to make sure the same afterGroups
// doesn't get run twice
if (methods != null) {
for (ITestNGMethod m : methods) {
afterMethods.put(m, m);
}
}
}
// Got our afterMethods, invoke them
ITestNGMethod[] filteredConfigurations =
afterMethods.keySet().stream()
.filter(ConfigInvoker::isGroupLevelConfigurationMethod)
.toArray(ITestNGMethod[]::new);
if (filteredConfigurations.length == 0) {
return;
}
// don't pass the IClass or the instance as the method may be external
// the invocation must be similar to @BeforeTest/@BeforeSuite
ConfigMethodArguments configMethodArguments =
new Builder()
.usingConfigMethodsAs(filteredConfigurations)
.forSuite(arguments.getSuite())
.usingParameters(arguments.getParameters())
.usingInstance(arguments.getInstance())
.forTestMethod(arguments.getTestMethod())
.build();
invokeConfigurations(configMethodArguments);
// Remove the groups so they don't get run again
arguments.getGroupMethods().removeAfterGroups(filteredGroups.keySet());
}
public void invokeConfigurations(ConfigMethodArguments arguments) {
if (arguments.getConfigMethods().length == 0) {
log(5, "No configuration methods found");
return;
}
ITestNGMethod[] methods =
TestNgMethodUtils.filterMethods(
arguments.getTestClass(), arguments.getConfigMethods(), SAME_CLASS);
Object[] parameters = new Object[] {};
for (ITestNGMethod tm : methods) {
if (null == arguments.getTestClass()) {
arguments.setTestClass(tm.getTestClass());
}
ITestResult testResult = TestResult.newContextAwareTestResult(tm, m_testContext);
testResult.setStatus(ITestResult.STARTED);
IConfigurationAnnotation configurationAnnotation = null;
try {
Object inst = tm.getInstance();
if (inst == null) {
inst = arguments.getInstance();
}
Class<?> objectClass = inst.getClass();
ConstructorOrMethod method = tm.getConstructorOrMethod();
// Only run the configuration if
// - the test is enabled and
// - the Configuration method belongs to the same class or a parent
configurationAnnotation = AnnotationHelper.findConfiguration(annotationFinder(), method);
boolean alwaysRun = MethodHelper.isAlwaysRun(configurationAnnotation);
boolean canProcessMethod =
MethodHelper.isEnabled(objectClass, annotationFinder()) || alwaysRun;
if (!canProcessMethod) {
log(
3,
"Skipping "
+ Utils.detailedMethodName(tm, true)
+ " because "
+ objectClass.getName()
+ " is not enabled");
continue;
}
if (!MethodHelper.isEnabled(configurationAnnotation)) {
log(3, "Skipping " + Utils.detailedMethodName(tm, true) + " because it is not enabled");
continue;
}
if (hasConfigurationFailureFor(
arguments.getTestMethod(),
tm.getGroups(),
arguments.getTestClass(),
arguments.getInstance())
&& !alwaysRun
&& !m_continueOnFailedConfiguration) {
log(3, "Skipping " + Utils.detailedMethodName(tm, true));
InvokedMethod invokedMethod = new InvokedMethod(System.currentTimeMillis(), testResult);
runConfigurationListeners(testResult, arguments.getTestMethod(), true /* before */);
runInvokedMethodListeners(BEFORE_INVOCATION, invokedMethod, testResult);
testResult.setEndMillis(testResult.getStartMillis());
testResult.setStatus(ITestResult.SKIP);
runInvokedMethodListeners(AFTER_INVOCATION, invokedMethod, testResult);
handleConfigurationSkip(
tm,
testResult,
configurationAnnotation,
arguments.getTestMethod(),
arguments.getInstance(),
arguments.getSuite());
continue;
}
log(3, "Invoking " + Utils.detailedMethodName(tm, true));
if (arguments.getTestMethodResult() != null) {
((TestResult) arguments.getTestMethodResult()).setMethod(arguments.getTestMethod());
}
parameters =
Parameters.createConfigurationParameters(
tm.getConstructorOrMethod().getMethod(),
arguments.getParameters(),
arguments.getParameterValues(),
arguments.getTestMethod(),
annotationFinder(),
arguments.getSuite(),
m_testContext,
arguments.getTestMethodResult());
testResult.setParameters(parameters);
runConfigurationListeners(testResult, arguments.getTestMethod(), true /* before */);
Object newInstance = computeInstance(arguments.getInstance(), inst, tm);
if (isConfigMethodEligibleForScrutiny(tm)) {
if (m_executedConfigMethods.add(arguments.getTestMethod())) {
invokeConfigurationMethod(newInstance, tm, parameters, testResult);
}
} else {
invokeConfigurationMethod(newInstance, tm, parameters, testResult);
}
copyAttributesFromNativelyInjectedTestResult(parameters, arguments.getTestMethodResult());
runConfigurationListeners(testResult, arguments.getTestMethod(), false /* after */);
if (testResult.getStatus() == ITestResult.SKIP) {
Throwable t = testResult.getThrowable();
if (t != null) {
throw t;
}
}
} catch (Throwable ex) {
handleConfigurationFailure(
ex,
tm,
testResult,
configurationAnnotation,
arguments.getTestMethod(),
arguments.getInstance(),
arguments.getSuite());
copyAttributesFromNativelyInjectedTestResult(parameters, arguments.getTestMethodResult());
}
} // for methods
}
/** Effectively invokes a configuration method on all passed in instances. */
// TODO: Change this method to be more like invokeMethod() so that we can handle calls to {@code
// IInvokedMethodListener} better.
private void invokeConfigurationMethod(
Object targetInstance, ITestNGMethod tm, Object[] params, ITestResult testResult)
throws InvocationTargetException, IllegalAccessException {
// Mark this method with the current thread id
tm.setId(ThreadUtil.currentThreadInfo());
InvokedMethod invokedMethod = new InvokedMethod(System.currentTimeMillis(), testResult);
runInvokedMethodListeners(BEFORE_INVOCATION, invokedMethod, testResult);
if (tm instanceof IInvocationStatus) {
((IInvocationStatus) tm).setInvokedAt(invokedMethod.getDate());
}
if (testResult.getStatus() == ITestResult.SKIP) {
// There was a skip marked by the listener invocation.
testResult.setEndMillis(System.currentTimeMillis());
Reporter.setCurrentTestResult(testResult);
runInvokedMethodListeners(AFTER_INVOCATION, invokedMethod, testResult);
Reporter.setCurrentTestResult(null);
return;
}
try {
Reporter.setCurrentTestResult(testResult);
ConstructorOrMethod method = tm.getConstructorOrMethod();
IConfigurable configurableInstance = computeConfigurableInstance(method, targetInstance);
if (RuntimeBehavior.isDryRun()) {
testResult.setStatus(ITestResult.SUCCESS);
return;
}
boolean willfullyIgnored = false;
boolean usesConfigurableInstance = configurableInstance != null;
if (usesConfigurableInstance) {
willfullyIgnored =
!MethodInvocationHelper.invokeConfigurable(
targetInstance, params, configurableInstance, method.getMethod(), testResult);
} else {
MethodInvocationHelper.invokeMethodConsideringTimeout(
tm, method, targetInstance, params, testResult);
}
boolean testStatusRemainedUnchanged = testResult.isNotRunning();
if (usesConfigurableInstance && willfullyIgnored && testStatusRemainedUnchanged) {
throw new ConfigurationNotInvokedException(tm);
}
testResult.setStatus(ITestResult.SUCCESS);
} catch (ConfigurationNotInvokedException
| InvocationTargetException
| IllegalAccessException ex) {
throwConfigurationFailure(testResult, ex);
testResult.setStatus(ITestResult.FAILURE);
throw ex;
} catch (Throwable ex) {
throwConfigurationFailure(testResult, ex);
testResult.setStatus(ITestResult.FAILURE);
throw new TestNGException(ex);
} finally {
testResult.setEndMillis(System.currentTimeMillis());
Reporter.setCurrentTestResult(testResult);
runInvokedMethodListeners(AFTER_INVOCATION, invokedMethod, testResult);
Reporter.setCurrentTestResult(null);
}
}
private void throwConfigurationFailure(ITestResult testResult, Throwable ex) {
testResult.setStatus(ITestResult.FAILURE);
testResult.setThrowable(ex.getCause() == null ? ex : ex.getCause());
}
private IConfigurable computeConfigurableInstance(
ConstructorOrMethod method, Object targetInstance) {
return IConfigurable.class.isAssignableFrom(method.getDeclaringClass())
? (IConfigurable) targetInstance
: m_configuration.getConfigurable();
}
private void runConfigurationListeners(ITestResult tr, ITestNGMethod tm, boolean before) {
if (before) {
TestListenerHelper.runPreConfigurationListeners(
tr, tm, m_notifier.getConfigurationListeners());
} else {
TestListenerHelper.runPostConfigurationListeners(
tr, tm, m_notifier.getConfigurationListeners());
}
}
/** Marks the current <code>TestResult</code> as skipped and invokes the listeners. */
private void handleConfigurationSkip(
ITestNGMethod tm,
ITestResult testResult,
IConfigurationAnnotation annotation,
ITestNGMethod currentTestMethod,
Object instance,
XmlSuite suite) {
recordConfigurationInvocationFailed(
tm, testResult.getTestClass(), annotation, currentTestMethod, instance, suite);
testResult.setStatus(ITestResult.SKIP);
runConfigurationListeners(testResult, currentTestMethod, false /* after */);
}
private boolean hasConfigFailure(ITestNGMethod currentTestMethod) {
return currentTestMethod != null && m_methodInvocationResults.containsKey(currentTestMethod);
}
private void handleConfigurationFailure(
Throwable ite,
ITestNGMethod tm,
ITestResult testResult,
IConfigurationAnnotation annotation,
ITestNGMethod currentTestMethod,
Object instance,
XmlSuite suite) {
Throwable cause = ite.getCause() != null ? ite.getCause() : ite;
if (isSkipExceptionAndSkip(cause)) {
testResult.setThrowable(cause);
handleConfigurationSkip(tm, testResult, annotation, currentTestMethod, instance, suite);
return;
}
Utils.log(
"",
3,
"Failed to invoke configuration method "
+ tm.getQualifiedName()
+ ":"
+ cause.getMessage());
handleException(cause, tm, testResult, 1);
testResult.setStatus(ITestResult.FAILURE);
runConfigurationListeners(testResult, currentTestMethod, false /* after */);
//
// If in TestNG mode, need to take a look at the annotation to figure out
// what kind of @Configuration method we're dealing with
//
if (null != annotation) {
recordConfigurationInvocationFailed(
tm, testResult.getTestClass(), annotation, currentTestMethod, instance, suite);
}
}
private static boolean isConfigMethodEligibleForScrutiny(ITestNGMethod tm) {
if (!tm.isBeforeMethodConfiguration()) {
return false;
}
if (!(tm instanceof ConfigurationMethod)) {
return false;
}
ConfigurationMethod cfg = (ConfigurationMethod) tm;
return cfg.isFirstTimeOnly();
}
/** @return true if this class or a parent class failed to initialize. */
private boolean classConfigurationFailed(Class<?> cls, Object instance) {
return m_classInvocationResults.entrySet().stream()
.anyMatch(
classSetEntry -> {
Set<Object> obj = classSetEntry.getValue();
Class<?> c = classSetEntry.getKey();
boolean containsBeforeTestOrBeforeSuiteFailure = obj.contains(null);
return c == cls
|| c.isAssignableFrom(cls)
&& (obj.contains(instance) || containsBeforeTestOrBeforeSuiteFailure);
});
}
private static void copyAttributesFromNativelyInjectedTestResult(
Object[] source, ITestResult target) {
if (source == null || target == null) {
return;
}
Arrays.stream(source)
.filter(each -> each instanceof ITestResult)
.findFirst()
.ifPresent(eachSource -> TestResult.copyAttributes((ITestResult) eachSource, target));
}
private void setMethodInvocationFailure(ITestNGMethod method, Object instance) {
if (method == null) {
return;
}
Set<Object> instances =
m_methodInvocationResults.computeIfAbsent(method, k -> Sets.newHashSet());
instances.add(TestNgMethodUtils.getMethodInvocationToken(method, instance));
}
private void setClassInvocationFailure(Class<?> clazz, Object instance) {
synchronized (m_classInvocationResults) {
Set<Object> instances =
m_classInvocationResults.computeIfAbsent(clazz, k -> Sets.newHashSet());
instances.add(instance);
}
}
/**
* Record internally the failure of a Configuration, so that we can determine later if @Test
* should be skipped.
*/
private void recordConfigurationInvocationFailed(
ITestNGMethod tm,
IClass testClass,
IConfigurationAnnotation annotation,
ITestNGMethod currentTestMethod,
Object instance,
XmlSuite suite) {
// If beforeTestClass or afterTestClass failed, mark either the config method's
// entire class as failed, or the class under tests as failed, depending on
// the configuration failure policy
if (annotation.getBeforeTestClass() || annotation.getAfterTestClass()) {
// tm is the configuration method, and currentTestMethod is null for BeforeClass
// methods, so we need testClass
if (m_continueOnFailedConfiguration) {
setClassInvocationFailure(testClass.getRealClass(), instance);
} else {
setClassInvocationFailure(tm.getRealClass(), instance);
}
}
// If before/afterTestMethod failed, mark either the config method's entire
// class as failed, or just the current test method as failed, depending on
// the configuration failure policy
else if (annotation.getBeforeTestMethod() || annotation.getAfterTestMethod()) {
if (m_continueOnFailedConfiguration) {
setMethodInvocationFailure(currentTestMethod, instance);
} else {
setClassInvocationFailure(tm.getRealClass(), instance);
}
}
// If beforeSuite or afterSuite failed, mark *all* the classes as failed
// for configurations. At this point, the entire Suite is screwed
else if (annotation.getBeforeSuite() || annotation.getAfterSuite()) {
m_suiteState.failed();
}
// beforeTest or afterTest: mark all the classes in the same
// <test> stanza as failed for configuration
else if (annotation.getBeforeTest() || annotation.getAfterTest()) {
setClassInvocationFailure(tm.getRealClass(), instance);
XmlClass[] classes = ClassHelper.findClassesInSameTest(tm.getRealClass(), suite);
for (XmlClass xmlClass : classes) {
setClassInvocationFailure(xmlClass.getSupportClass(), instance);
}
}
String[] beforeGroups = annotation.getBeforeGroups();
for (String group : beforeGroups) {
m_beforegroupsFailures.put(group, Boolean.FALSE);
}
}
private static Object computeInstance(Object instance, Object inst, ITestNGMethod tm) {
if (instance == null
|| !tm.getConstructorOrMethod().getDeclaringClass().isAssignableFrom(instance.getClass())) {
return inst;
}
return instance;
}
private Set<Object> getInvocationResults(IClass testClass) {
Class<?> cls = testClass.getRealClass();
Set<Object> set = null;
// We need to continuously search till either our Set is not null (or) till we reached
// Object class because it is very much possible that the test method is residing in a child
// class
// and maybe the parent method has configuration methods which may have had a failure
// So lets walk up the inheritance tree until either we find failures or till we
// reached the Object class.
while (!cls.equals(Object.class)) {
set = m_classInvocationResults.get(cls);
if (set != null) {
break;
}
cls = cls.getSuperclass();
}
if (set == null) {
// This should never happen because we have walked up all the way till Object class
// and yet found no failures, but our logic indicates that there was a failure somewhere up
// the
// inheritance order. We don't know what to do at this point.
throw new IllegalStateException("No failure logs for " + testClass.getRealClass());
}
return set;
}
}