Goal: Development Android Project with Test Project
– Init with Eclipse
– Development with Eclipse
– TDD
– Under Version Control
– CI
Directory Structure
EDITED(2011-07-05 23:26)More recommended: When you create new project from existing source, test directory also imported. And it does not act as a test project.
-ECLIPSE_WORKSPACE
-SpinnerActivity
-SpinnerActivityTest
-SCM_WORKSPACE
-spinner
-SpinnerActivity
-SpinnerActivityTest
EDITED(2011-07-05 7:03) recommended structure: Testing Fundamentals | Android Developers
MyProject/
AndroidManifest.xml
res/
... (resources for main application)
src/
... (source code for main application) ...
tests/
AndroidManifest.xml
res/
... (resources for tests)
src/
... (source code for tests)
Create scm workspace and init
I’m eclipse newbie. So I don’t understand how to use EGit. So I use cli git command.
mkdir -p SCM_WORKSPACE/spinner
cd SCM_WORKSPACE/spinner
git init
touch .gitkeep
git add .
git commit -v
Create New Project from existing source
/usr/local/Cellar/android-sdk/r11/samples/android-12/Spinner/
File -> New -> Project -> Android -> Android Project
– Create project from existing source
In my Indigo version(mac os x 10.6.8) does not work next and create test. So I do separate.
ECLIPSE_WORKSPACE/SpinnerActivity completed.
Copy to scm dir and commit
cd SCM_WORKSPACE/spinner
EDITED(2011-07-06 7:10) cp -r option drops dot files.
cp -r ECLIPSE_WORKSPACE/SpinnerActivity .
cp -a ECLIPSE_WORKSPACE/SpinnerActivity .
curl -L https://raw.github.com/github/gitignore/master/Android.gitignore -o SpinnerActivity/.gitignore
git add SpinnerActivity/
git commit -v
Create New Test Project SpinnerActivityTest
File -> New -> Project -> Android -> Android Test Project
Test Target
An Existing Android Project: SpinnerActivity
If then error occurs, you will fix it. You can run SpinnerActivity and SpinnerActivityTest.
Copy to scm dir and commit
cd SCM_WORKSPACE/spinner
EDITED(2011-07-06 7:10) cp -r option drops dot files.
cp -r ECLIPSE_WORKSPACE/SpinnerActivityTest .
cp -a ECLIPSE_WORKSPACE/SpinnerActivityTest .
curl -L https://raw.github.com/github/gitignore/master/Android.gitignore -o SpinnerActivityTest/.gitignore
git add SpinnerActivityTest/
git commit -v
CLI building SpinnerActivity
CI use CLI build, ant. You need “build.xml”. Managing Projects from the Command Line | Android Developers
cd SCM_WORKSPACE/spinner/SpinnerActivity
android update project --name SpinnerActivity --target 5 --path .
git add .
git commit -v
cd ..
ant -f SpinnerActivity/build.xml debug
CLI building SpinnerActivityTest
Test project needs cli building too.
cd SCM_WORKSPACE/spinner/SpinnerActivityTest
android update test-project -p . -m ../SpinnerActivity
git add .
git commit -v
cd ..
ant -f SpinnerActivityTest/build.xml run-tests
This is half way. It’s crazy bad know-how.
Cleanup ECLIPSE_WORKSPACE
Select SpinnerActivity project and Delete. You must check-off “delete project content on disk”. if you check this, then you delete “android-sdk/r11/samples/android-12/Spinner/”.
Select SpinnerActivityTest project and Delete. You must check-on “delete project content on disk”.
Move and Clone, it is just other developer’s setting way
cd SCM_WORKSPACE
mv spinner spinner_origin
git clone spinner_origin/.git spinner
Create New Project from existing source again
SCM_WORKSPACE/spinner/SpinnerActivity
File -> New -> Project -> Android -> Android Project
– Create project from existing source
In my Indigo version(mac os x 10.6.8) does not work next and create test. So I do separate.
ECLIPSE_WORKSPACE/SpinnerActivity completed.
Import Test Project
Eclipse does not have a way to create test project from existing source. So I use import.
File -> Import -> General -> Existing Project into Workspace
SCM_WORKSPACE/spinner/SpinnerActivityTest
EDITED(2011-07-05 6:32):
You *must* check-off copy project into workspace.
Then you must Clean Up and Reflesh.
Finally, you can work TDD and CI. Happy Android Development!