Maven тесты не пройдены в Azure DevOps. java .io.FileNotFoundException: TestSuiteList.xls (нет такого файла или каталога) - PullRequest
0 голосов
/ 13 марта 2020

Я пытаюсь запустить конвейер выпуска в Azure DevOps для автоматизации тестов Maven, и я получаю эту ошибку:

2020-03-13T16: 12: 59.0792106Z java. io.FileNotFoundException: TestSuiteList.xls (такого файла или каталога нет)

Расположение файла правильное, но, возможно, существует проблема с путем. Я пробовал:

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\\";
    }

ИЛИ

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;
    }

Оба работают локально на моем Windows 10, но когда я использую Linux Агент на DevOps, я получаю ошибку. Мне нужно, чтобы он работал на любой машине.

1 Ответ

0 голосов
/ 13 марта 2020
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;
}

Здесь basePath будет иметь значение пустой строки, если Platform.getCurrent().toString() не равно WIN или MAC, а пустой базовый путь означает, что приложение будет искать файл в текущем каталоге.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...