GithubHelp home page GithubHelp logo

keydocz's Introduction

How do I include a testng.xml file in the root of the tests.jar file for Device Farm?

Issue

To apply the testng.xml file to the Appium TestNG test package for AWS Device Farm, I need to add the testng.xml file to the root of the *-tests.jar file. How do I do that?

Short Description

With the introduction of Custom Test Environment, TestNG XML will be the used to run the tests inside the project test code. For that purpose, this XML has to be present inside the Testing Jar which is created as part of the test code compilation.

Users can configure their test code to package this XML into the Testing Jar as part of the maven build.

Note: In Device Farm's standard environment only a subset of features are supported for the testng.xml file. If priority, the include tag, the exclude tag, complex grouping, or using parameters from the testng.xml file are required for the project, then use the custom environments.

Resolution

To achieve this, following things are required to be taken care of: -

  1. User has to make sure to place his test code inside the root test folder i.e. –

    SP4 - <project_root>/testresources/TestNG/

    Before SP4 - <project_root>/test/TestNG/

    Note – User should make sure his/her pom.xml resides under this directory.

  2. User has to write a TestNG XML as per user preference and place it at the following location

    <root_test_folder>/src/test/resources

  3. After the files are in place, user has to include testresources tags in the pom.xml to explicitly reference the directory:

<testResources>

<testResource>

<directory>${project.basedir}/<root_test_folder>/src/test/resources</directory>

</testResource>

</testResources>

  1. Next step is to modify the pom.xml to include the surefire plugin to reference the TestNG XML file for local executions:

<plugin>

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

<artifactId>maven-surefire-plugin</artifactId>

<version>2.12.4</version>

<configuration>

<suiteXmlFiles> <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile></suiteXmlFiles>

</configuration>

</plugin>

Please note, for more than one TestNG XML multiple < suiteXmlFile > tags have to be used.

  1. To check on local, user can build the test code to create a dependencies zip which contains the Testing JAR. Zip with the dependencies will be present inside <root_test_folder>/target directory.

    Package the tests using maven clean and package commands at the test root folder. The -DskipTests=true option specifies that the build shouldn’t run the unit tests.

mvn clean package -DskipTests=true

  1. Extract the zip, use xf command to extract the jar to verify that TestNG XML file is present at the desired location (root, by default):

jar xf nameOfTheProjectFromPom-1.0-SNAPSHOT-tests.jar

Alternatively, the unzip command can also extract the contents of the jar:

unzip nameOfTheProjectFromPom-1.0-SNAPSHOT-tests.jar -d sampletestsjarcontents

If the XML is in place, the target folder has to be removed and the code has to be checked-in into a branch in Git. Now, the user can run his/her tests on AppFactory in the Custom Test Environment.

Please note, that steps 3 and 4 are only for verification and tests will be compiled by AppFactory during runtime unless the zip with dependencies is directly provided via build parameters.
For more information on this, please visit AWS Documentation.

keydocz's People

Contributors

konydocs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.