Could you please tell me how these JUnit files were generated?
Akhil
March 13, 2019, 3:59pm
3
Hi @devalex88 ,
I’m using runner class to generate Junit reports. Please check Example 4 in link: https://docs.katalon.com/katalon-studio/docs/running-cucumber-features-file.html#in-test-cases .
Code:
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith (Cucumber.class)
@CucumberOptions (features=“Your_Folder_Path”, glue="", plugin = [“pretty”,
“junit:Folder_Name/cucumber.xml”,
“html:Folder_Name”,
“json:Folder_Name/cucumber.json”])
public class MyCucumberRunner {
}
Hi, I have found a workaround for this.
We can replace the name attribute “cucumber.runtime.formatter.JUnitFormattter” in the xml file with the name you want as the report name.
I have tried with a custom keyword to replace the name in the xml and calling that in the test listener with @AfterTestcase . It worked fine for me.
Here is the Keyword to replace the name attribute in xml:
@Keyword
def getXmlFiles(){
String pathToFolder = RunConfiguration.getProjectDir() + '<Path to your custom report folder>'
List<File> aList = new ArrayList<File>();
File dir = new File(pathToFolder);
File[] dirContents = dir.listFiles();
for (File xmlfname : dirContents) {
if (xmlfname.isFile() && getFileExtensionName(xmlfname).indexOf("xml") != -1) {
aList.add(xmlfname);
}
}
aList= aList.toArray(new File[aList.size()]);
println aList
for(int i=0;i<aList.size;i++){
String fpath = aList[i]
println fpath
modifyFile(fpath,"cucumber.runtime.formatter.JUnitFormatter","MyCustomReport")
}
}
Akhil
May 10, 2019, 12:44pm
5
Thank you @srilakshmi it’s working fine