Skip to content

Commit

Permalink
Merge pull request #2837 from speedythesnail/Add-addition-yml-extension
Browse files Browse the repository at this point in the history
Add addition yml extension
  • Loading branch information
juherr committed Nov 24, 2022
2 parents e4adf0f + 21a52ff commit 39f8fa5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
@@ -1,4 +1,5 @@
Current
New: Added .yml file extension for yaml suite files, previously only .yaml was allowed for yaml (Steven Jubb)
Fixed: GITHUB-2770: FileAlreadyExistsException when report is generated (melloware)
Fixed: GITHUB-2825: Programically Loading TestNG Suite from JAR File Fails to Delete Temporary Copy of Suite File (Steven Jubb)
Fixed: GITHUB-2818: Add configuration key for callback discrepancy behavior (Krishnan Mahadevan)
Expand Down
2 changes: 1 addition & 1 deletion testng-core/src/main/java/org/testng/Converter.java
Expand Up @@ -65,7 +65,7 @@ private void run(String[] args) throws IOException {
if (file.endsWith(".xml")) {
File newFile = new File(m_outputDirectory, baseName + ".yaml");
writeFile(newFile, Yaml.toYaml(suite).toString());
} else if (file.endsWith(".yaml")) {
} else if (file.endsWith(".yaml") || file.endsWith(".yml")) {
File newFile = new File(m_outputDirectory, baseName + ".xml");
writeFile(newFile, suite.toXml());
} else {
Expand Down
Expand Up @@ -21,6 +21,7 @@ public XmlSuite parse(String filePath, InputStream is, boolean loadClasses)

@Override
public boolean accept(String fileName) {
return Parser.hasFileScheme(fileName) && fileName.endsWith(".yaml");
return Parser.hasFileScheme(fileName)
&& (fileName.endsWith(".yaml") || fileName.endsWith(".yml"));
}
}
13 changes: 13 additions & 0 deletions testng-core/src/test/java/test/yaml/YamlTest.java
@@ -1,6 +1,8 @@
package test.yaml;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -31,6 +33,17 @@ public Object[][] dp() {
};
}

@Test(
description =
"Validate that the YamlParser accepts yaml files with a .yaml or a .yml file extension, but not other file types.")
public void accept() {
YamlParser yamlParser = new YamlParser();

assertTrue(yamlParser.accept("TestSuite.yml"));
assertTrue(yamlParser.accept("TestSuite.yaml"));
assertFalse(yamlParser.accept("TestSuite.xml"));
}

@Test(dataProvider = "dp")
public void compareFiles(String name) throws IOException {
Collection<XmlSuite> s1 =
Expand Down

0 comments on commit 39f8fa5

Please sign in to comment.