Skip to content

Commit 39f8fa5

Browse files
authored
Merge pull request #2837 from speedythesnail/Add-addition-yml-extension
Add addition yml extension
2 parents e4adf0f + 21a52ff commit 39f8fa5

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Current
2+
New: Added .yml file extension for yaml suite files, previously only .yaml was allowed for yaml (Steven Jubb)
23
Fixed: GITHUB-2770: FileAlreadyExistsException when report is generated (melloware)
34
Fixed: GITHUB-2825: Programically Loading TestNG Suite from JAR File Fails to Delete Temporary Copy of Suite File (Steven Jubb)
45
Fixed: GITHUB-2818: Add configuration key for callback discrepancy behavior (Krishnan Mahadevan)

testng-core/src/main/java/org/testng/Converter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private void run(String[] args) throws IOException {
6565
if (file.endsWith(".xml")) {
6666
File newFile = new File(m_outputDirectory, baseName + ".yaml");
6767
writeFile(newFile, Yaml.toYaml(suite).toString());
68-
} else if (file.endsWith(".yaml")) {
68+
} else if (file.endsWith(".yaml") || file.endsWith(".yml")) {
6969
File newFile = new File(m_outputDirectory, baseName + ".xml");
7070
writeFile(newFile, suite.toXml());
7171
} else {

testng-core/src/main/java/org/testng/internal/YamlParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public XmlSuite parse(String filePath, InputStream is, boolean loadClasses)
2121

2222
@Override
2323
public boolean accept(String fileName) {
24-
return Parser.hasFileScheme(fileName) && fileName.endsWith(".yaml");
24+
return Parser.hasFileScheme(fileName)
25+
&& (fileName.endsWith(".yaml") || fileName.endsWith(".yml"));
2526
}
2627
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package test.yaml;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertTrue;
46

57
import java.io.File;
68
import java.io.FileInputStream;
@@ -31,6 +33,17 @@ public Object[][] dp() {
3133
};
3234
}
3335

36+
@Test(
37+
description =
38+
"Validate that the YamlParser accepts yaml files with a .yaml or a .yml file extension, but not other file types.")
39+
public void accept() {
40+
YamlParser yamlParser = new YamlParser();
41+
42+
assertTrue(yamlParser.accept("TestSuite.yml"));
43+
assertTrue(yamlParser.accept("TestSuite.yaml"));
44+
assertFalse(yamlParser.accept("TestSuite.xml"));
45+
}
46+
3447
@Test(dataProvider = "dp")
3548
public void compareFiles(String name) throws IOException {
3649
Collection<XmlSuite> s1 =

0 commit comments

Comments
 (0)