I'm not sure exactly but I believe you should be able to place the testng.xml in a resources directory and reference it from the pom.xml .
Looks like this post shows how to reference the testng.xml from the pom.xml: How to call testng.xml file from pom.xml in Maven
When you build the project then it will be included in the jar.
The awslabs project builds it by using this mvn command
mvn clean package -DskipTests=true
[Update] I downloaded the sample project from awslabs and imported it into eclipse. I then added this plugin to the pom.xml file:
<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>
I then created the testng.xml in ./src/test/resources/
I copied and pasted the xml provided here:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default Suite">
<test name="test">
<classes>
<class name="Factory"/>
</classes>
</test>
</suite>
I then built the project using
mvn clean package -DskipTests=true
This produced a zip-with-dependencies.zip file in the target directory.
I uploaded this test package to device farm by creating a new project and selecting Appium Java Testng as the type of tests that I want to run.
I encountered this parse error:
Failed to generate the test suites[TestNG] [ERROR] Cannot find class in classpath: Factory
Which is expected since I don't have that class in my classpath, however, this proves that Device Farm did read the testng.xml.
[update]
I am able to reproduce the problem when I use the exclude tag in the testng.xml. I.E when I use this xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default Suite">
<test name="test">
<classes>
<class name="factory.TestSingleUrl">
<methods>
<exclude name="testCorrectSiteKey" />
<exclude name="testIsTagImplemented" />
<exclude name="testHttpsScheme" />
<exclude name="testCorrectTagName" />
<exclude name="testCorrectBootstrapPath" />
</methods>
</class>
</classes>
</test>
</suite>
Going to investigate further on the method tags.
[update]
Looks like this is a known issue in Device Farm: AWS Device farm seems to be ignoring TestNG annotations
Guess we will just need to wait for them to update their environment and the parser.
You might be able to run your tests on a private device. You'll need to contact aws to get one at this email:
aws-devicefarm-support@amazon.com
[Update]
Looks like they've updated the webDriverAgent. See if it works now.
Hope that helps.