Skip to content

Commit 3c964b8

Browse files
committedDec 7, 2021
Review fixes
- use InstanceCreator#newInstance() - use TestNG exception with detail exception message - create and link github issue
1 parent a1f2e3f commit 3c964b8

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed
 

‎CHANGES.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Current
2-
New: Yaml parser: implement loadClasses flag (Dzmitry Sankouski)
2+
Fixed: GITHUB-2689: Yaml parser: implement loadClasses flag (Dzmitry Sankouski)
33
Fixed: GITHUB-2676: NPE is triggered when working with ITestObjectFactory (Krishnan Mahadevan)
44
Fixed: GITHUB-2674: Run onTestSkipped for each value from data provider (Krishnan Mahadevan)
55
Fixed: GITHUB-2672: Log real stacktrace when test times out. (cdalexndr)

‎testng-core/src/main/java/org/testng/internal/Yaml.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.Map;
99
import java.util.function.Consumer;
1010
import org.testng.TestNGException;
11+
import org.testng.internal.objects.InstanceCreator;
1112
import org.testng.util.Strings;
1213
import org.testng.xml.XmlClass;
1314
import org.testng.xml.XmlInclude;
@@ -378,13 +379,13 @@ public Object newInstance(Node node) {
378379
nodeTuple ->
379380
((ScalarNode) nodeTuple.getKeyNode()).getValue().equals("name"))
380381
.findFirst()
381-
.orElseThrow(RuntimeException::new)
382+
.orElseThrow(() -> new TestNGException("Node 'name' not found"))
382383
.getValueNode();
383384
className = ((ScalarNode) valueNode).getValue();
384385
} else {
385386
className = ((ScalarNode) node).getValue();
386387
}
387-
return c.newInstance(className, loadClasses);
388+
return InstanceCreator.newInstance(c, className, loadClasses);
388389
} catch (Exception e) {
389390
throw new TestNGException("Failed to instantiate class", e);
390391
}

‎testng-core/src/test/java/test/yaml/YamlTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testXmlDependencyGroups() throws IOException {
7272
assertThat(Yaml.toYaml(actualXmlSuite).toString()).isEqualToNormalizingNewlines(expectedYaml);
7373
}
7474

75-
@Test
75+
@Test(description = "GITHUB-2689")
7676
public void testLoadClassesFlag() throws IOException {
7777
YamlParser yamlParser = new YamlParser();
7878
String yamlSuiteFile = "src/test/resources/yaml/suiteWithNonExistentTest.yaml";

0 commit comments

Comments
 (0)