{"id":34100,"date":"2016-05-02T14:58:10","date_gmt":"2016-05-02T09:28:10","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=34100"},"modified":"2016-12-19T15:02:53","modified_gmt":"2016-12-19T09:32:53","slug":"how-to-provide-your-testsscripts-dependencies-to-aws-device-farm","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-provide-your-testsscripts-dependencies-to-aws-device-farm\/","title":{"rendered":"How to provide your TestsScripts &amp; Dependencies to AWS Device Farm"},"content":{"rendered":"<p>If you are using Appium, TestNG &amp; Maven test frameworks and Java language for your <a title=\"automated mobile app testing\" href=\"http:\/\/www.tothenew.com\/testing\/automated-mobile-application-testing\">mobile automation<\/a> project, then it&#8217;ll help you.<\/p>\n<p>To run your Appium Java TestNG scripts,\u00a0you need to club your test-cases &amp; all the dependencies in one file and provide it to Device Farm. And to attain this,\u00a0do some modifications in the <strong>pom.xml<\/strong> file in your project.<\/p>\n<h3>i)\u00a0Set packaging as a JAR file:<\/h3>\n<p>[java]<br \/>\n&lt;groupId&gt;com.acme&lt;\/groupId&gt;<br \/>\n&lt;artifactId&gt;acme-android-appium&lt;\/artifactId&gt;<br \/>\n&lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;<br \/>\n&lt;packaging&gt;jar&lt;\/packaging&gt;<br \/>\n[\/java]<\/p>\n<h3>ii)\u00a0Include maven-jar-plugin to build your tests into a JAR file:<\/h3>\n<p>This plugin will build your test source code (anything on this path\u00a0src\/test directory) into a JAR file.<\/p>\n<p>[java]<br \/>\n&lt;plugin&gt;<br \/>\n  &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;<br \/>\n  &lt;artifactId&gt;maven-jar-plugin&lt;\/artifactId&gt;<br \/>\n  &lt;version&gt;2.6&lt;\/version&gt;<br \/>\n  &lt;executions&gt;<br \/>\n    &lt;execution&gt;<br \/>\n      &lt;goals&gt;<br \/>\n        &lt;goal&gt;test-jar&lt;\/goal&gt;<br \/>\n      &lt;\/goals&gt;<br \/>\n    &lt;\/execution&gt;<br \/>\n  &lt;\/executions&gt;<br \/>\n&lt;\/plugin&gt;<br \/>\n[\/java]<\/p>\n<p>&nbsp;<\/p>\n<h3>iii)\u00a0Use maven-dependency-plugin which will build all the dependencies as JAR files:<\/h3>\n<p>[java]<br \/>\n&lt;plugin&gt;<br \/>\n  &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;<br \/>\n  &lt;artifactId&gt;maven-dependency-plugin&lt;\/artifactId&gt;<br \/>\n  &lt;version&gt;2.10&lt;\/version&gt;<br \/>\n  &lt;executions&gt;<br \/>\n    &lt;execution&gt;<br \/>\n      &lt;id&gt;copy-dependencies&lt;\/id&gt;<br \/>\n      &lt;phase&gt;package&lt;\/phase&gt;<br \/>\n      &lt;goals&gt;<br \/>\n        &lt;goal&gt;copy-dependencies&lt;\/goal&gt;<br \/>\n      &lt;\/goals&gt;<br \/>\n      &lt;configuration&gt;<br \/>\n        &lt;outputDirectory&gt;${project.build.directory}\/dependency-jars\/&lt;\/outputDirectory&gt;<br \/>\n      &lt;\/configuration&gt;<br \/>\n    &lt;\/execution&gt;<br \/>\n  &lt;\/executions&gt;<br \/>\n&lt;\/plugin&gt;<br \/>\n[\/java]<\/p>\n<h3>iv) Now save the following XML assembly to this path (src\/main\/assembly\/zip.xml).<\/h3>\n<p>This XML is an assembly definition which will instructs Maven to build a .zip file containing everything in the root of your build output directory and the dependency-jars directory:<\/p>\n<p>[java]<br \/>\n&lt;assembly<br \/>\n    xmlns=&quot;http:\/\/maven.apache.org\/plugins\/maven-assembly-plugin\/assembly\/1.1.0&quot;<br \/>\n    xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;<br \/>\n    xsi:schemaLocation=&quot;http:\/\/maven.apache.org\/plugins\/maven-assembly-plugin\/assembly\/1.1.0 ;<br \/>\n  &lt;id&gt;zip&lt;\/id&gt;<br \/>\n  &lt;formats&gt;<br \/>\n    &lt;format&gt;zip&lt;\/format&gt;<br \/>\n  &lt;\/formats&gt;<br \/>\n  &lt;includeBaseDirectory&gt;false&lt;\/includeBaseDirectory&gt;<br \/>\n  &lt;fileSets&gt;<br \/>\n    &lt;fileSet&gt;<br \/>\n      &lt;directory&gt;${project.build.directory}&lt;\/directory&gt;<br \/>\n      &lt;outputDirectory&gt;.\/&lt;\/outputDirectory&gt;<br \/>\n      &lt;includes&gt;<br \/>\n        &lt;include&gt;*.jar&lt;\/include&gt;<br \/>\n      &lt;\/includes&gt;<br \/>\n    &lt;\/fileSet&gt;<br \/>\n    &lt;fileSet&gt;<br \/>\n      &lt;directory&gt;${project.build.directory}&lt;\/directory&gt;<br \/>\n      &lt;outputDirectory&gt;.\/&lt;\/outputDirectory&gt;<br \/>\n      &lt;includes&gt;<br \/>\n        &lt;include&gt;\/dependency-jars\/&lt;\/include&gt;<br \/>\n      &lt;\/includes&gt;<br \/>\n    &lt;\/fileSet&gt;<br \/>\n  &lt;\/fileSets&gt;<br \/>\n&lt;\/assembly&gt;<br \/>\n[\/java]<\/p>\n<p>&nbsp;<\/p>\n<h3>v)\u00a0Use maven-assembly-plugin\u00a0to club all the test cases and dependencies:<\/h3>\n<p>Now after adding the above assemble, use this plugin maven-assembly-plugin which will package all tests and dependencies into a single .zip file.<\/p>\n<p>[java]<br \/>\n&lt;plugin&gt;<br \/>\n  &lt;artifactId&gt;maven-assembly-plugin&lt;\/artifactId&gt;<br \/>\n  &lt;version&gt;2.5.4&lt;\/version&gt;<br \/>\n  &lt;executions&gt;<br \/>\n    &lt;execution&gt;<br \/>\n      &lt;phase&gt;package&lt;\/phase&gt;<br \/>\n      &lt;goals&gt;<br \/>\n        &lt;goal&gt;single&lt;\/goal&gt;<br \/>\n      &lt;\/goals&gt;<br \/>\n      &lt;configuration&gt;<br \/>\n        &lt;finalName&gt;zip-with-dependencies&lt;\/finalName&gt;<br \/>\n        &lt;appendAssemblyId&gt;false&lt;\/appendAssemblyId&gt;<br \/>\n        &lt;descriptors&gt;<br \/>\n          &lt;descriptor&gt;src\/main\/assembly\/zip.xml&lt;\/descriptor&gt;<br \/>\n        &lt;\/descriptors&gt;<br \/>\n      &lt;\/configuration&gt;<br \/>\n    &lt;\/execution&gt;<br \/>\n  &lt;\/executions&gt;<br \/>\n&lt;\/plugin&gt;<br \/>\n[\/java]<\/p>\n<p>&nbsp;<\/p>\n<h3>vi) At Last, build the package with the following command<\/h3>\n<p>In command prompt &amp; the directory should be that where pom.xml file exist:<\/p>\n<p>[java]mvn clean package -DskipTests=true[\/java]<\/p>\n<p>After successful build, you can check the\u00a0<strong>target<\/strong> folder, all your test-cases &amp; dependencies have been club in single .zip file\u00a0named <strong>zip-with-dependencies.zip<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-34101 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/04\/targetFolder.png\" alt=\"targetFolder\" width=\"570\" height=\"578\" \/><br \/>\nThen use this file to automate your test-cases on AWS\u00a0Device Farm: \u00a0on the <strong>Configure test page<\/strong>, choose <strong>Appium Java TestNG<\/strong> as test suite and <strong>Upload<\/strong>\u00a0this file\u00a0&#8216;zip-with-dependencies.zip&#8217; and Enjoy your test-suite on multiple\u00a0devices in\u00a0parallel. \ud83d\ude42<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-34102\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/05\/uploadDependencies.png\" alt=\"uploadDependencies\" width=\"1272\" height=\"624\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are using Appium, TestNG &amp; Maven test frameworks and Java language for your mobile automation project, then it&#8217;ll help you. To run your Appium Java TestNG scripts,\u00a0you need to club your test-cases &amp; all the dependencies in one file and provide it to Device Farm. And to attain this,\u00a0do some modifications in the [&hellip;]<\/p>\n","protected":false},"author":201,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":11},"categories":[518,1818,1174,1772,1816],"tags":[1978,1979,3274],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/34100"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/201"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=34100"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/34100\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=34100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=34100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=34100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}