从Android的版本不包括单元测试项目 [英] Excluding Unit Testing project from Android build
问题描述
综观单元测试我跑过这一建议...
Android的文档您可以在文件系统中的任何地方创建一个测试项目,但最好的方法是增加测试项目,这样它的根目录测试/是在同一水平作为主应用程序的项目的src /目录下。这可以帮助你找到与应用程序相关的测试。例如,如果你的应用项目的根目录是MyProject的,那么你应该使用下面的目录结构:
MyProject的/
AndroidManifest.xml中
RES /
...(资源主要应用)
SRC /
...(来源$ C $ C为主要应用)...
测试/
AndroidManifest.xml中
RES /
...(资源测试)
SRC /
...(来源$ C $下测试)
我的问题是,我怎么能排除我测试项目中的测试的目录,当我建立生产?否则,我只是有一堆额外的code列入,这将永远不会用于任何的.apk文件。
您使用Android Ant构建以建立您的可分配APK?如果是这样,你不应该有测试code显示出来,你会不会有SRC code以同样的方式显示出来。
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.
这篇关于从Android的版本不包括单元测试项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!