Excluding Unit Testing project from Android build
Looking through the Android docs on unit testing I ran across this recommendation...
You can create a test project anywhere in your file system, but the best approach is to add the test project so that its root directory tests/ is at the same level as the src/ directory of the main application's project. This helps you find the tests associated 开发者_如何学运维with an application. For example, if your application project's root directory is MyProject, then you should use the following directory structure:
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)
My question is, how can I exclude the "tests" directory from the project I am testing when I build for production? Otherwise, I will just have a bunch of extra code included in the .apk that will never get used for anything.
Are you using the Android Ant build to build your distributable apk? If so, you shouldn't have the tests code showing up, the same way you won't have the src code showing up.
精彩评论