How do I create an Android Test project in Eclipse in the target project’s /test directory?
Note: I’m just doing my own Q+A for people according to the Stackoverflow FAQ on answering your own question.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I am using Helios with the latest current version of Android (10.0.1)
The Android Testing fundamentals recommends you
place the tests in the same project folder as your
srcfolder. Some people have recommended that you create a new test project in its own folder so it doesn’t get packaged into the apk.I looked inside my apk and I don’t think the test stuff was included (but I could be wrong). I like having it in the same directory as its more convenient for revision control – you don’t need to sync two projects each time.
Assume we want to create a test suite for the
MyAndroidAppprojectGoto File.. New.. Other.. Android…Android Test Project
MyAndroidAppTestMyAndroidApptestsdirectoryWhen it is being created, if you get a
An internal error occurred during: "Refreshing workspace".error (or other errors) just ignore it. Click OK.-Clean the
MyAndroidAppprojectEven though the project is in the
<workspace path>/MyAndroidApp/testsdirectory it will appear as a normal Eclipse project in the package explorer.Clean the
MyAndroidAppTestproject.This worked for me.
EDIT
If you upload to SVN in Eclipse (by syncing the
MyAndroidAppproject, not theMyAndroidAppTestproject) you need to do a little more (I’ve just done it now).So when you update your other working copy it will pull down the
/testsdirectory.The
MyAndroidAppTestproject does not automatically show up in the Package Explorer.So you need to go to File.. Import…Existing Projects into Workspace….
Then select the root directory by browsing to your
<workspace path>/MyAndroidApp/testsdirectory and click Finish.