Skip to content

Commit

Permalink
Added tests and changes as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
speedythesnail committed Nov 23, 2022
1 parent d7e9058 commit 21a52ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions testng-core/src/main/java/org/testng/internal/YamlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public XmlSuite parse(String filePath, InputStream is, boolean loadClasses)

@Override
public boolean accept(String fileName) {
return Parser.hasFileScheme(fileName) && fileName.endsWith(".yaml")
|| fileName.endsWith(".yml");
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
Original file line number Diff line number Diff line change
@@ -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 21a52ff

Please sign in to comment.