Tuesday, 9 December 2014

Android test projects - little tweak to run it on Jenkins

For big tests, instead have the test in the same project as the original one, it is better to have a separated project. It will make the code more clean and easy to read.

To do it so, just do the follow on eclipse:
1. Click on File -> new project -> Android Test project
2. Enter the test project name and click on next
3. Select the existent project which the tests should run and click on next
4. Select the Build target and click on Finish

But this is not good enough to run in the Jenkins. Two more steps should be done.
1. Create the ant files
1.1 Go to the sdk directly of Android and in the directory tool, run the command android as the follow one to create the proper files for the test

./android update test-project -m <path-to-project-to-be-tested> -p <path-to-test-project>

Replace the <path-to-project-to-be-tested> and <path-to-test-project> with your own path. It could be like this

./android update test-project -m /User/jiahaoliuliu/projects/coolProject -p /User/jiahaoliuliu/projects/coolProjectTest

This command will create the follow files in the test project directory:
- ant.properties
- build.xml
- local.properties

2. Update the relative path
2.1 Go to the directory of the test project
2.2 Open the ant.properties file
2.3 Check the path in there is relative and not absolute. The relative path starts with one dot(.) or two dots(..). The absolute path starts with slash(/). If it is the absolute path, change it to the relative path.

For more information

No comments:

Post a Comment