Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse 创建目录失败_Eclipse_Cucumber_Pom.xml_File Permissions - Fatal编程技术网

Eclipse 创建目录失败

Eclipse 创建目录失败,eclipse,cucumber,pom.xml,file-permissions,Eclipse,Cucumber,Pom.xml,File Permissions,当我运行MainRunner类作为响应时,我在控制台中得到错误消息,如下所示。我确实设置了文件夹的权限 这是我的step课程: 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 na

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

这是我的step课程:

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");

}

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

这是我的Pom.xml

我还尝试了以下方法:

正在运行:Eclipse菜单项目>清理

但是没有快乐。有人知道这是什么原因吗


当名为输出目录(
target/cucumber
)的文件已经存在时,会发生异常
cucumber.runtime.CucumberException:java.io.IOException:无法创建目录…

假设以下结构

src/test/java/runner/TestRunner.java
pom.xml
pom.xml依赖项

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <version.cucumber>2.0.0</version.cucumber>
</properties>
<dependencies>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${version.cucumber}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${version.cucumber}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
复制步骤

$ mvn clean test-compile
$ echo "some text" > target/cucumber
现在,由于文件
target/cumber
存在,运行测试

$ mvn test
它失败了

Caused by: cucumber.runtime.CucumberException: java.io.IOException: Failed to create directory /tmp/cuke.test/target/cucumber
    at cucumber.runtime.formatter.HTMLFormatter.createReportFileOutputStream(HTMLFormatter.java:520)
    at cucumber.runtime.formatter.HTMLFormatter.createJsOut(HTMLFormatter.java:510)
    at cucumber.runtime.formatter.HTMLFormatter.<init>(HTMLFormatter.java:123)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
注意:在OP的代码中,插件的顺序不是
json-html
,而是
html-json
。因此,上面的代码片段只使用了
html
插件,并在运行测试之前创建了文件
target/cucumber

按照OP屏幕截图中显示的相同顺序使用插件会引发不同的异常

@CucumberOptions(plugin = {"html:target/cucumber", "json:target/cucumber"})
cucumber.runtime.CucumberException: java.io.FileNotFoundException: \
    target/cucumber (Is a directory)
根据用于再现冲突的步骤,插件顺序和屏幕截图中的异常不匹配


很可能更改json插件的输出文件名(
“json:target/cucumber.json”
)就能解决这个问题。

根据我的发现,
插件
对象似乎正在尝试创建两个名为“cucumber”的目录当您希望对象创建一个名为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文件放在其中,而不是其他报告工件


希望这有帮助

能否检查
target/cucumber
是否不是文件?能否提供此问题的解决方案?Thanks@Ryan我添加了更详细的解释和最可能的解决方案。
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
}