简体   繁体   English

Maven 测试在 Azure DevOps 中失败。 java.io.FileNotFoundException: TestSuiteList.xls(没有这样的文件或目录)

[英]Maven tests failing in Azure DevOps. java.io.FileNotFoundException: TestSuiteList.xls (No such file or directory)

I'm trying to lunch release pipeline in Azure DevOps for Maven tests automation and I keep getting this error:我正在尝试在 Azure DevOps 中为 Maven 测试自动化提供午餐发布管道,但我不断收到此错误:

2020-03-13T16:12:59.0792106Z java.io.FileNotFoundException: TestSuiteList.xls (No such file or directory) 2020-03-13T16:12:59.0792106Z java.io.FileNotFoundException:TestSuiteList.xls(没有这样的文件或目录)

Location of the file is correct, but maybe there is a problem with path.文件位置正确,但路径可能有问题。 I have tried:我试过了:

public static final String currentDir = System.getProperty("user.dir");
public static String cloudbrokerBase = "http://localhost:9000/Cloudbroker";

public static WebDriver /*void*/ init() throws IOException{
    //To Initialize logger service.
    Add_Log = Logger.getLogger("rootLogger");

    if (System.getProperty("cloudbrokerBase", null) != null ){
        cloudbrokerBase = System.getProperty("cloudbrokerBase");
    }

    String basePath = "";
    if (Platform.getCurrent().toString().equalsIgnoreCase("MAC")) {
        basePath = currentDir + "//src//test//java//resources//";
    } else if (Platform.getCurrent().toString().contains("WIN")) {
        basePath = currentDir + "\\src\\test\\java\\resources\\";
    }

OR或者

public static final String currentDir = System.getProperty("user.dir");
public static String cloudbrokerBase = "http://localhost:9000/Cloudbroker";

public static WebDriver /*void*/ init() throws IOException{
    //To Initialize logger service.
    Add_Log = Logger.getLogger("rootLogger");

    if (System.getProperty("cloudbrokerBase", null) != null ){
        cloudbrokerBase = System.getProperty("cloudbrokerBase");
    }

    String basePath = "";
    if (Platform.getCurrent().toString().equalsIgnoreCase("MAC")) {
        basePath = currentDir + File.separator + "src" + File.separator + "test" + File.separator + "java" + File.separator +"resources" + File.separator;
    } else if (Platform.getCurrent().toString().contains("WIN")) {
        basePath = currentDir + File.separator + "src" + File.separator + "test" + File.separator + "java" + File.separator +"resources" + File.separator;
    }

Both works locally on my Windows 10, but when I use Linux Agent on DevOps I get the error.两者都在我的 Windows 10 上本地运行,但是当我在 DevOps 上使用 Linux 代理时,我收到错误消息。 I need it to work on any machine.我需要它在任何机器上工作。

String basePath = "";
if (Platform.getCurrent().toString().equalsIgnoreCase("MAC")) {
    basePath = currentDir + File.separator + "src" + File.separator + "test" + File.separator + "java" + File.separator +"resources" + File.separator;
} else if (Platform.getCurrent().toString().contains("WIN")) {
    basePath = currentDir + File.separator + "src" + File.separator + "test" + File.separator + "java" + File.separator +"resources" + File.separator;
}

Here basePath will have value of empty String if Platform.getCurrent().toString() is not WIN nor MAC , and the empty base path means that the application will look for the file in the current directory.如果Platform.getCurrent().toString()既不是WIN也不是MAC ,则basePath值为空字符串,空基路径意味着应用程序将在当前目录中查找文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.io.FileNotFoundException:..(无此类文件或目录) - java.io.FileNotFoundException: .. (No such file or directory) java.io.FileNotFoundException:没有这样的文件或目录错误 - java.io.FileNotFoundException: No such file or directory Error java.io.FileNotFoundException:[文件路径](没有这样的文件或目录) - java.io.FileNotFoundException: [filepath] (No such file or directory) java.io.FileNotFoundException(是一个目录) - java.io.FileNotFoundException (Is a directory) java.io.IOException:java.io.FileNotFoundException :(无此类文件或目录) - java.io.IOException: java.io.FileNotFoundException:(No such file or directory) java.io.FileNotFoundException没有此类文件或目录错误,但目录存在 - java.io.FileNotFoundException No such file or directory error but directory exists Linux java没有此类文件或目录,java.io.FileNotFoundException: - Linux java No such file or directory, java.io.FileNotFoundException: Java FileWriter 类 - java.io.FileNotFoundException: * 没有这样的文件或目录 -Ubuntu - Java FileWriter class - java.io.FileNotFoundException: * no such file or directory -Ubuntu java.io.FileNotFoundException(没有这样的文件或目录) - 下载文件 - java.io.FileNotFoundException (No such file or directory) - Download File java.io.FileNotFoundException:(无此类文件或目录)-使用servlet - java.io.FileNotFoundException: (No such file or directory) - Working with servlets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM