|
17 | 17 | import java.util.regex.Pattern;
|
18 | 18 | import java.util.stream.Collectors;
|
19 | 19 | import org.testng.IClass;
|
| 20 | +import org.testng.IFactoryMethod; |
20 | 21 | import org.testng.IRetryAnalyzer;
|
21 | 22 | import org.testng.ITestClass;
|
22 | 23 | import org.testng.ITestClassInstance;
|
@@ -104,6 +105,10 @@ public BaseTestMethod(
|
104 | 105 | m_instance = instance;
|
105 | 106 | }
|
106 | 107 |
|
| 108 | + protected final IObject.IdentifiableObject identifiableObject() { |
| 109 | + return m_instance; |
| 110 | + } |
| 111 | + |
107 | 112 | /** {@inheritDoc} */
|
108 | 113 | @Override
|
109 | 114 | public boolean isAlwaysRun() {
|
@@ -300,6 +305,19 @@ public void setTimeOut(long timeOut) {
|
300 | 305 | m_timeOut = timeOut;
|
301 | 306 | }
|
302 | 307 |
|
| 308 | + @Override |
| 309 | + public Optional<IFactoryMethod> getFactoryMethod() { |
| 310 | + IObject.IdentifiableObject identifiable = identifiableObject(); |
| 311 | + if (identifiable == null) { |
| 312 | + return Optional.empty(); |
| 313 | + } |
| 314 | + Object instance = identifiableObject().getInstance(); |
| 315 | + if (instance instanceof ParameterInfo) { |
| 316 | + return Optional.of(() -> Optional.of(((ParameterInfo) instance).getParameters())); |
| 317 | + } |
| 318 | + return ITestNGMethod.super.getFactoryMethod(); |
| 319 | + } |
| 320 | + |
303 | 321 | /**
|
304 | 322 | * {@inheritDoc}
|
305 | 323 | *
|
@@ -539,11 +557,10 @@ public String getSimpleName() {
|
539 | 557 | }
|
540 | 558 |
|
541 | 559 | private String instanceParameters() {
|
542 |
| - IParameterInfo instance = getFactoryMethodParamsInfo(); |
543 |
| - if (instance != null) { |
544 |
| - return ", instance params:" + Arrays.toString(instance.getParameters()); |
545 |
| - } |
546 |
| - return ""; |
| 560 | + return getFactoryMethod() |
| 561 | + .flatMap(IFactoryMethod::getParameters) |
| 562 | + .map(it -> ", instance params:" + Arrays.toString(it)) |
| 563 | + .orElse(""); |
547 | 564 | }
|
548 | 565 |
|
549 | 566 | protected String getSignature() {
|
|
0 commit comments