无法开始执行通过Java API动态创建的功能文件
我正在使用以下java代码以编程方式创建一个功能文件无法开始执行通过Java API动态创建的功能文件,java,web-services,selenium,cucumber,Java,Web Services,Selenium,Cucumber,我正在使用以下java代码以编程方式创建一个功能文件 // This method will be invoked by 'constructFeatureFile()' public static void createFeatureFile(String strFeatureFilePath, String strFeatureFileContent, String runnableFile) { try { if (strFeatureFilePath.tr
// This method will be invoked by 'constructFeatureFile()'
public static void createFeatureFile(String strFeatureFilePath, String strFeatureFileContent, String runnableFile)
{
try
{
if (strFeatureFilePath.trim().length() > 0 && strFeatureFileContent.trim().length() > 0)
{
// First time file creation
if (!Files.exists(Paths.get(strFeatureFilePath)))
{
FileWriter fw = new FileWriter(new File(strFeatureFilePath));
Writer wr = new BufferedWriter(fw);
wr.write(strFeatureFileContent);
wr.close();
} //If the exists, delete that file and create with fresh data
else if(Files.exists(Paths.get(strFeatureFilePath)))
{
Files.delete(Paths.get(strFeatureFilePath));
FileWriter fw = new FileWriter(new File(strFeatureFilePath));
Writer wr = new BufferedWriter(fw);
wr.write(strFeatureFileContent);
wr.close();
}
// Call Runner to run feature file
runner(runnableFile);
}
}
catch(Exception e)
{
System.out.print(e);
}
}
// Invoke feature file to execute
public static void runner(String runnableFile)
{
Map<String, Object> args = new HashMap<String,Object>();
args.put("name", "API Testing");
Map<String, Object> getResponse = CucumberRunner.runClasspathFeature(runnableFile, args, true);
getResponse = null;
}
但是,在重新设计文件夹(创建该功能文件的地方)并重新运行相同的脚本之后,它可以使用相同的功能文件完美地执行
我不明白为什么会发生这种情况,我在这里犯了什么错误,请任何人提供建议
谢谢 createFeatureFile()似乎正忙于写入strFeatureFilePath,但随后调用runner(runnableFile)。未向runnableFile写入任何内容?是否有任何更新?:(当我运行“调试模式”时,它可以工作,但当我执行run As-JUnit Test选项时,它会引发一个异常。我正在删除空手道标记,因为这不是空手道问题。如果它在调试模式下工作,则可能会出现计时问题。请尝试在调用runner方法之前进入睡眠状态。您好,Grasshopper,您的建议帮助了我…谢谢:)谢谢你的回复。在“runnableFile”变量中,我将传递类似“country//getMembersDetails.feature”的功能文件类路径。实际的功能文件位置是“D:\Workspace\karatedemo\src\test\java\country\getMembersDetails.feature”
java.lang.RuntimeException: file not found: country//getMembersDetails.feature