hongbosb wrote: > > If test cases are put in the same package, then release version will > contain test project. This isn't customer want to see. >
That's not true. You want the unit tests (it's important to distinguish what kind of test we're discussing!) in the same package as the classes they test. And no, that doesn't mean the release version will contain the test code. That's false. If you set up your project correctly it's false, of course. Anyone can screw up anything. Put the test code in its own source tree, duh. <project>/ | |---- src/ | |--- test/ > And you should only test public interface. Because other module can only > use the method declared public. If > Again, not true. More is exposed that 'public'; you also have to test 'protected', and if the type is 'Serializable' then you have to test the serialization/deserialization. It isn't the public interface that you must test, it's the exposed interface. Package-private is different - you use package-private for methods that you want the test to override for greater control and mocking behavior. There's no need to unit-test private methods (except as they affect serialization). > you insist on testing method other than pubic, you can consider to use the > reflection of java [sic] to test even private method. But it violate common > sense of TDD. > No. No reflection needed or advisable. Ray Tayek 写道: > >> having the test cases in a different package make it hard to test methods >> and classes with protected or the default visibility. >> > You don't test package-private, you use package-private to make testing possible. > >> is there some reason why the test cases are put into a separate package? >> > No good one. > >> placing them in the same package seems to work ok. >> >> am going to run into trouble by doing this? >> > Not if you do it right. -- Lew -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

