반응형

앞에 설명한 것에 이어서  인제 앞에서 짠것과 같은 코드를 DeviceFarm에 올리는 방법에 대해 설명하겠다. 그냥 지금 프로젝트를 압축해서 올리면 DeviceFarm에서는 돌아가지 않는다. Maven 프로젝트로 만들어줘야 한다. Maven을 잘 모르더라도 겁먹을 필요는 없다. 그냥 설명하는 대로 잘 따라하면 제대로 동작한다. 


그리고 아직 AWS DeviceFarm에 대해 더 자세히 알고 싶으면 http://docs.aws.amazon.com/devicefarm/latest/developerguide/devicefarm-dg.pdf 

에 접속해서 저 PDF를 꼼꼼히 읽어보길 바란다. 

여기서는 Working with Appium Java TestNG for Android and Device Farm 이부분만을 보면된다. 

혹시라도 완성된 다른코드를 보고 싶으면 사람을 위해 

https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app

이 코드를 보고 참고해서 만들면 된다. 


우선 Maven 프로젝트를 만들어준다. 툴을 Eclipse이다. 





빨간색 표시된 곳을 눌러 MavenProject를 만들어 준다. 

그리고 그냥 다 Next를 눌러 완성 시킨 후 pom.xml을 우선 셋팅해준다. 



<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>


<groupId>com.acme</groupId>

<artifactId>acme-android-appium</artifactId>

<version>1.0-SNAPSHOT</version>

<packaging>jar</packaging>


<dependencies>

<dependency>

<groupId>org.testng</groupId>

<artifactId>testng</artifactId>

<version>6.8.8</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>io.appium</groupId>

<artifactId>java-client</artifactId>

<version>3.1.0</version>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-jar-plugin</artifactId>

<version>2.6</version>

<executions>

<execution>

<phase>package</phase>

<goals>

<goal>test-jar</goal>

</goals>

</execution>

</executions>

</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}/dependency-jars/</outputDirectory>

</configuration>

</execution>

</executions>

</plugin>

<plugin>

<artifactId>maven-assembly-plugin</artifactId>

<version>2.5.4</version>

<executions>

<execution>

<phase>package</phase>

<goals>

<goal>single</goal>

</goals>

<configuration>

<finalName>zip-with-dependencies</finalName>

<appendAssemblyId>false</appendAssemblyId>

<descriptors>

<descriptor>src/main/assembly/zip.xml</descriptor>

</descriptors>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>


 

</project>



위와 같이 설정을 해준 후 src안에 main 과 test패키지를 만들어준다. 그 이후 main 안에는 assembly안에 zip.xml파일을 만들어준다. 


zip.xml의 내용은 

<assembly

    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0http://maven.apache.org/xsd/assembly-1.1.0.xsd">

  <id>zip</id>

  <formats>

    <format>zip</format>

  </formats>

  <includeBaseDirectory>false</includeBaseDirectory>

  <fileSets>

    <fileSet>

      <directory>${project.build.directory}</directory>

      <outputDirectory>./</outputDirectory>

      <includes>

        <include>*.jar</include>

      </includes>

    </fileSet>

    <fileSet>

      <directory>${project.build.directory}</directory>

      <outputDirectory>./</outputDirectory>

      <includes>

        <include>/dependency-jars/</include>

      </includes>

    </fileSet>

  </fileSets>

 

</assembly>

와 같다. 


 



위와 같은 구조로 만들어 준 후 page, 와 test는 테스트 코드들이다. 저것과 꼭 똑같이 할필요는 없다. 그냥 테스트 코드를 저 위치에 test패키지안에 넣어주면 된다. 주의할점은 selenium의 라이브러리 값들을 maven이 가져오는 depedency들에게 맞춰서 다시 임포트 해줘야한다. 


이후에는 cmd 창에가서 mvn package install 를 해주면 target에 pom에 설정해두었던 대로 폴더들이 생성된다. 

 


여기서 중요한 것은 zip-with-depedencies 파일이다. 이것을 deviceFarm에 올려주면 된다. 

DeviceFarm에 테스트를 설정하는 것은 매우 간단하므로 굳이 설명하지 않겠다. 


이것보다 더 나은 방법도 있을 수 있다. 그러나 나처럼 삽질하시는 분들이 없으면 하는 마음에 포스트를 작성해보았다. 그나마 삽질하시는 분들에게 조금이나마 도움이되었으면한다. 


반응형

+ Recent posts