My Appium + JUnit tests works perfectly fine locally, but on aws it can not find properties files. My tests are placed under src/test/java
and properties file
Here is what I did and it seemed to work:
/**
* Rigourous Test :-)
*/
public void testApp()
{
//taken from https://www.mkyong.com/java/java-properties-file-examples/
//create properties object
Properties prop = new Properties();
InputStream input = null;
//load in the properties file from src/test/resources
try {
input = Thread.currentThread().getContextClassLoader().getResourceAsStream("myproperties.properties");
// load a properties file
prop.load(input);
// get the property value and print it out
System.out.println(prop.getProperty("devicefarm"));
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Here is my java output from device farm:
[TestNG] Running:
Command line suite
helloWorld
and here is the contents of my properties file:
devicefarm=helloWorld
In my local test it seemed to work too:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.devicefarm.www.AppTest
helloWorld
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.018 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
It would appear that after the properties file is package we can not reference it in java the same way we do locally through maven. If we try to make the test-jar executable and run the jar I think the same thing would happen.
Edit: see this SO post for difference between the class loader and the thread loader.
https://stackoverflow.com/a/22653795/4358385
Regarding exporting the tmp directory, on this page we can tell device farm to export whatever directories we want
Then when the test is finished we can click on the customer artifacts link and get a zip of that export.