首页 > 解决方案 > 黄瓜异常创建目录失败

问题描述

当我运行 MainRunner 类作为响应时,我在控制台中收到如下错误消息。我确实为文件夹设置了权限。

在此处输入图像描述

这是我的步骤类:

package CucumberFramework.steps;

import cucumber.api.java.en.Given;

import cucumber.api.java.en.Then;

import cucumber.api.java.en.When;



public class LoginSteps {

@Given("^User navigate to stackoverflow webstie$")

public void user_navigate_to_stackoverflow_webstie() throws Throwable {

   System.out.println("user_navigate_to_stackoverflow_webstie");

}



@Given("^User clicks on the login button$")

public void user_clicks_on_the_login_button() throws Throwable {

    System.out.println("user_clicks_on_the_login_button");

}



@Given("^User enters valid username$")

public void user_enters_valid_username() throws Throwable {

System.out.println("user_enters_valid_username");

}



@Given("^User enters valid password$")

public void user_enters_valid_password() throws Throwable {

System.out.println("user_enters_valid_password");

}

@When("^User clicks again on the login button$")

public void user_clicks_again_on_the_login_button() throws Throwable {

System.out.println("user_clicks_again_on_the_login_button");

}



@Then("^User should be taken to the sucsfull login page$")

public void user_should_be_taken_to_the_sucsfull_login_page() throws Throwable {

System.out.println("user_should_be_taken_to_the_sucsfull_login_page");

}

@Given("^User navigate to stackoverflow webstie(\\d+)$")

public void user_navigate_to_stackoverflow_webstie2(int arg1) throws Throwable {

System.out.println("user_navigate_to_stackoverflow_webstie2");

}



@Given("^User clicks on the login button(\\d+)$")

public void user_clicks_on_the_login_button2(int arg1) throws Throwable {

System.out.println("user_clicks_on_the_login_button2");

}



@Given("^User enters valid username(\\d+)$")

public void user_enters_valid_username2(int arg1) throws Throwable {

System.out.println("user_enters_valid_username2");

}



@Given("^User enters valid password(\\d+)$")

public void user_enters_valid_password2(int arg1) throws Throwable {

System.out.println("user_enters_valid_password2");

}



@When("^User clicks again on the login button(\\d+)$")

public void user_clicks_again_on_the_login_button2(int arg1) throws Throwable {

System.out.println("user_clicks_again_on_the_login_button2");

}



@Then("^User should be taken to the sucsfull login page(\\d+)$")

public void user_should_be_taken_to_the_sucsfull_login_page2(int arg1) throws Throwable {

System.out.println("user_should_be_taken_to_the_sucsfull_login_page2");

}

}

我还查看了目标文件夹的权限,并确保为所有用户授予权限。我使用的是 Windows 10 专业版。我也尝试在管理员模式下运行 Eclipse,但也没有帮助。

这是我的 Pom.xml https://pastebin.com/ad2qyGRH

我还尝试了以下方法:

运行:Eclipse 菜单 Project > Clean...

在此处输入图像描述

但没有喜悦。请问有谁知道是什么原因造成的?

亲切的问候

标签: eclipsecucumberpom.xmlfile-permissions

解决方案


根据我的发现,plugin当您想要对象创建一个目录和一个名为 cucumber 的文件时,该对象似乎正在尝试创建 2 个名为“cucumber”的目录。这是您的对象的样子:

plugin = {
    "pretty", 
    "html:target/cucumber", //this is telling cucumber to create a folder called cucumber
    "json:target/cucumber", //this is also telling cucumber to create a folder called cucumber 
                            //even though you just need a file called cucumber.json
    "com.cucumber.listener.ExtentCucumberFormatter: target/report.html" 
    //there is an unnecessary white space before "target" that is causing another issue
}

你想要做的是:

plugin = {
    "pretty", 
    "html:target/cucumber", //create a folder called cucumber
    "json:target/cucumber.json", 
    //Notice the corresponding file extension (.json) telling cucumber to create a file
    "com.cucumber.listener.ExtentCucumberFormatter:target/report.html"
    //Notice I remove the white space at :target/report.html
}

现在代码正在创建一个名为 cucumber 的文件夹(这将包含一个显示测试结果的基本网页)和一个名为 cucumber.json 的文件(这将是相同的测试结果,但为 json 格式)

不要忘记删除那个空白! 然后,该空白区域会创建一个名为“target”的单独文件夹(以空白开头),并将 report.html 文件放入其中,而不是与其余的报告工件一起放置。

希望这可以帮助!


推荐阅读