如何使用Azure VSTS管道中的Appcenter任务正确配置和执行测试用例。
在存储库中,父目录中有两个目录{source,testcase}。该构建在由VSTS pipleline触发的托管Mac OS中执行。
在第一个任务中,从源目录中创建.apk文件并复制到工件暂存目录。 在第二个任务中,使用Appcenter任务“使用Visual Studio App Center进行测试”运行自动化测试用例。
我无法理解appium的工作原理,并使其通过VSTS管道工作。
在第一种方法中,.apk构建之后,然后想使用Appcenter和Appium执行测试用例。但由于我的测试用例文件之一具有如下所示的硬编码值,因此未成功。 有一个文件/src/test/java/company/domain/com/util/android/UtilSetup.java,其文件具有如下硬编码的值。由于硬编码的值,它一直在寻找appium并引发连接问题。因此继续使用第二种方法来使管道正常工作。
public class UtilSetupAndroid {
public static EnhancedAndroidDriver<MobileElement> driverAndroid;
public static void setupAndroid() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, Platform.ANDROID);
caps.setCapability("platformVersion", "7.0");
caps.setCapability("deviceName", "hexa-decimal-value-here");
caps.setCapability("udid", "same-hexa-decimal-value-here");
caps.setCapability("appPackage", "cl.company.transformacion.appcompanymobile");
caps.setCapability("appActivity",
"cl.company.transformacion.appcompanymobile.enrolamiento.activity.CargaInicialActivity");
caps.setCapability("app", "/home/directory/Appium-test/project.apk");
caps.setCapability("unicodeKeyboard", true);
caps.setCapability("resetKeyboard", true);
URL url = new URL("http://localhost:4723/wd/hub");
driverAndroid = Factory.createAndroidDriver(url, caps);
driverAndroid.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
}
在第二种方法中,进行了本地构建(MVN测试),并生成了测试用例的* .class文件。在测试用例build目录中提交了“ test-classes”目录,并在Appium配置部分中引用了该目录。我认为提交* .class文件不是正确的方法,但是为了使管道正常工作,是这样做的。 然后,构建管道开始执行Appium,但以未解决的依赖性错误结束。我遇到了同样的问题,并且为了解决该问题,添加了公司nexus存储库以直接从Nexus下载。但仍然会发生错误。
pom.xml has dependencies like below:
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.appcenter</groupId>
<artifactId>appium-test-extension</artifactId>
<version>1.0</version>
</dependency>
build section like below:
<profiles>
<profile>
<id>prepare-for-upload</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/upload/dependency-jars/</outputDirectory>
<useRepositoryLayout>true</useRepositoryLayout>
<copyPom>true</copyPom>
<addParentPoms>true</addParentPoms>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>generate-pom</id>
<phase>package</phase>
<goals>
<goal>effective-pom</goal>
</goals>
<configuration>
<output>${project.build.directory}/upload/pom.xml</output>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-testclasses</id>
<phase>package</phase>
<goals>
<goal>testResources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/upload/test-classes</outputDirectory>
<resources>
<resource>
<directory>${project.build.testOutputDirectory}</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
</plugins>
</reporting>
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
</profile>
</profiles>
<repositories>
<repository>
<id>COMPAY_NAME.cl</id>
<url>http://maven.COMPANY_NAME.cl/nexus/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>COMPANY_NAME.cl</id>
<url>http://maven.COMPANY_NAME.cl/nexus/content/repositories/public/</url>
</repository>
</distributionManagement>
错误消息:
Reason: [INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building run-test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.microsoft.appcenter:appium-test-extension:jar:1.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.958 s
[INFO] Finished at: 2019-06-19T01:45:22+02:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project run-test: Could not resolve dependencies for project com.xamarin.appium:run-test:jar:1.0-SNAPSHOT: Could not find artifact com.microsoft.appcenter:appium-test-extension:jar:1.0 in cache1 (http://cache1:6081/maven2) -> [Help 1]
[编辑] 其他信息,我的pom.xml在“ com.xamarin.appium”中没有该项目。似乎来自App Center的错误。同样,输出中的Maven仓库不是我的Maven仓库。
从appcenter-cli到App Center的REST调用返回的前几次调用的状态为2xx,最后引发错误。
[command]/usr/local/bin/appcenter test prepare appium --artifacts-dir /Users/vsts/agent/2.153.2/work/1/a/AppCenterTest --build-dir /Users/vsts/agent/2.153.2/work/1/s/Test/test_case --debug --quiet
Using appcenter-cli version: 1.1.18
Preparing tests... done.
Tests are ready to run. Manifest file was written to /Users/vsts/agent/2.153.2/work/1/a/AppCenterTest/manifest.json
[command]/usr/local/bin/appcenter test run manifest --manifest-path /Users/vsts/agent/2.153.2/work/1/a/AppCenterTest/manifest.json --app-path /Users/vsts/agent/2.153.2/work/1/a/AppCOMPMobile.apk --app COMPchile/AppAndroid --devices COMPchile/set-pruebas-vsts --test-series pruebas --locale en_US --debug --quiet --token ***
Using appcenter-cli version: 1.1.18
Preparing tests... done.
(truncated)
Response status code: 200
Body: {"message":["Tests completed. Processing data."],"wait_time":10,"exit_code":null}
Current test status: Tests completed. Processing data.
logFilter, request: {
"rawResponse": false,
"queryString": {},
"url": "https://api.appcenter.ms/v0.1/apps/COMPchile/COMPAppAndroid/test_runs/b8b88f0f-226c-4564-98b5-dc582cca81c8/state",
"method": "GET",
"headers": {
"Content-Type": "application/json; charset=utf-8",
"user-agent": "appcenterCli/1.1.18 NodeJS/v6.17.0 darwin/18.6.0",
"x-api-token": ***
},
"body": null
}
Response status code: 200
Body: {"message":["Failed!","Reason: [INFO] Scanning for projects...\n[INFO] \n[INFO] ------------------------------------------------------------------------\n[INFO] Building run-test 1.0-SNAPSHOT\n[INFO] ------------------------------------------------------------------------\n[WARNING] The POM for com.microsoft.appcenter:appium-test-extension:jar:1.5 is missing, no dependency information available\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD FAILURE\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 2.132 s\n[INFO] Finished at: 2019-06-21T19:23:12+02:00\n[INFO] Final Memory: 10M/309M\n[INFO] ------------------------------------------------------------------------\n[ERROR] Failed to execute goal on project run-test: Could not resolve dependencies for project com.xamarin.appium:run-test:jar:1.0-SNAPSHOT: Could not find artifact com.microsoft.appcenter:appium-test-extension:jar:1.5 in cache1 (http://cache1:6081/maven2) -\u003e [Help 1]\n[ERROR] \n[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\n[ERROR] Re-run Maven using the -X switch to enable full debug logging.\n[ERROR] \n[ERROR] For more information about the errors and possible solutions, please read the following articles:\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException\n"],"wait_time":10,"exit_code":2}