开发者

Android and JUnit: Create a JUnit Project or a test source folder

开发者 https://www.devze.com 2022-12-22 08:16 出处:网络
There is an option to create an Android JUnit Project. As far as I am aware the other way is to create a folder in the same project called test which contains the same package name as the existing pr

There is an option to create an Android JUnit Project.

As far as I am aware the other way is to create a folder in the same project called test which contains the same package name as the existing project.

What are the differences be开发者_StackOverflowtween these two methods.


When I develop in Java, I usually create a separate /test folder in the same project as my source, with the identical package structure underneath it.

I keep the two separate so that the /test contents don't get packaged up and deployed with the source code. No sense deploying tests or the 3rd party JARs on which they depend.


Create a separate project. There's a number of reasons to do that, among others your tests won't be included in you final APK, you may need a different AndroidManifext.xml for your main project and for your tests and because it's a common practice and your project will be more understandable by others.


option1: separate Android test project
option2: "A project within a project", the "tests" folder

option2
should provide better eclipse speed, overview, and less maintenance,
is promoted by Google in the documentation
BUT currently has flaky ADT wizard tool support.

I presently view option1 as current de facto standard,
and it has good ADT support.

Keep your eyes open though, because ADT versions are almost released monthly,
so option2 may soon become the de facto instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号