[英]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.