如何在 AWS Device Farm 中使用 运行 maven 命令
How to run maven command in AWS Device Farm
我正在尝试使用 Maven 运行 我的 java 设备农场中的移动项目。
当我 运行 在本地机器上的正确目录中执行此命令时:
mvn test -D "cucumber.options="src/test/java/cucumber/features" --glue
cucumber.steps --tags @InstallApp"
我将此命令放在 aws 设备场中的 yaml 文件中,但它不起作用。
这是我得到的错误:
[DeviceFarm] echo "Start Appium TestNG test"
Start Appium TestNG test
[DeviceFarm] mvn test -D
"cucumber.options="src/test/java/cucumber/features" --glue
cucumber.steps
--tags @InstallApp"
[INFO] Scanning for projects...
[INFO] BUILD FAILURE
[ERROR] The goal you specified requires a project to execute but there
is
no POM in this directory (/tmp/scratchncneoU.scratch/test-
packageO6o8s7).
Please verify you invoked Maven from the correct directory. -> [Help 1]
如何 运行 device farm 中的这个 maven 命令? pom 在哪里?
谢谢
在 yaml 文件中键入此命令后:
[DeviceFarm] java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH -D"cucumber.options="classpath:features" --glue cucumber.steps --tags @InstallApp" org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10
我得到一个错误:在 jar 文件中找不到 testng.xml 尽管我的 pom 中有这个:
<directory>${project.basedir}/src/test/java/cucumber</directory>
</testResource>
</testResources>
它可以是什么?
mvn
命令失败,因为您的部署包不包含整个项目。从当前部署包的声音来看,你应该能够用这个命令做你想做的事:
- java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH -D"cucumber.options="src/test/java/cucumber/features" --glue cucumber.steps
--tags @InstallApp" org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10
否则,如果您想使用 Maven,则需要压缩整个项目并将其包含在 pom.xml
中。因此,例如使用 sample cucumber java tests
git clone https://github.com/aws-samples/aws-device-farm-appium-cucumber-tests-for-sample-app.git
zip -r deployment_package.zip aws-device-farm-appium-cucumber-tests-for-sample-app
那么你应该可以在testspec.yml
文件中使用maven了。例如,我可以 运行 示例的以下命令:mvn clean test
在转到项目目录之后,然后为了获得结果,我必须导出目标目录。
test:
commands:
# Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH so we first change directory to that path.
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH/aws-device-farm-appium-cucumber-tests-for-sample-app
- mvn clean test
...
artifacts:
# By default, Device Farm will collect your artifacts from following directories
- $DEVICEFARM_TEST_PACKAGE_PATH/aws-device-farm-appium-cucumber-tests-for-sample-app/target
- $DEVICEFARM_LOG_DIR
但是,您需要将 zip 文件作为 APPIUM_NODE
测试类型上传,以避免那里的测试包解析器。
HTH
-詹姆斯
我正在尝试使用 Maven 运行 我的 java 设备农场中的移动项目。 当我 运行 在本地机器上的正确目录中执行此命令时:
mvn test -D "cucumber.options="src/test/java/cucumber/features" --glue
cucumber.steps --tags @InstallApp"
我将此命令放在 aws 设备场中的 yaml 文件中,但它不起作用。 这是我得到的错误:
[DeviceFarm] echo "Start Appium TestNG test"
Start Appium TestNG test
[DeviceFarm] mvn test -D
"cucumber.options="src/test/java/cucumber/features" --glue
cucumber.steps
--tags @InstallApp"
[INFO] Scanning for projects...
[INFO] BUILD FAILURE
[ERROR] The goal you specified requires a project to execute but there
is
no POM in this directory (/tmp/scratchncneoU.scratch/test-
packageO6o8s7).
Please verify you invoked Maven from the correct directory. -> [Help 1]
如何 运行 device farm 中的这个 maven 命令? pom 在哪里?
谢谢
在 yaml 文件中键入此命令后: [DeviceFarm] java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH -D"cucumber.options="classpath:features" --glue cucumber.steps --tags @InstallApp" org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10
我得到一个错误:在 jar 文件中找不到 testng.xml 尽管我的 pom 中有这个:
<directory>${project.basedir}/src/test/java/cucumber</directory>
</testResource>
</testResources>
它可以是什么?
mvn
命令失败,因为您的部署包不包含整个项目。从当前部署包的声音来看,你应该能够用这个命令做你想做的事:
- java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH -D"cucumber.options="src/test/java/cucumber/features" --glue cucumber.steps
--tags @InstallApp" org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10
否则,如果您想使用 Maven,则需要压缩整个项目并将其包含在 pom.xml
中。因此,例如使用 sample cucumber java tests
git clone https://github.com/aws-samples/aws-device-farm-appium-cucumber-tests-for-sample-app.git
zip -r deployment_package.zip aws-device-farm-appium-cucumber-tests-for-sample-app
那么你应该可以在testspec.yml
文件中使用maven了。例如,我可以 运行 示例的以下命令:mvn clean test
在转到项目目录之后,然后为了获得结果,我必须导出目标目录。
test:
commands:
# Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH so we first change directory to that path.
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH/aws-device-farm-appium-cucumber-tests-for-sample-app
- mvn clean test
...
artifacts:
# By default, Device Farm will collect your artifacts from following directories
- $DEVICEFARM_TEST_PACKAGE_PATH/aws-device-farm-appium-cucumber-tests-for-sample-app/target
- $DEVICEFARM_LOG_DIR
但是,您需要将 zip 文件作为 APPIUM_NODE
测试类型上传,以避免那里的测试包解析器。
HTH
-詹姆斯