Since test classes are compiled against the platform jar, we are unable to subclass some of the platform types which have final methods, are final classes, or have non-visible constructors. The jar that is on the classpath at test execution time does not have these restrictions.
Because of this fact, mocking is the only approach that currently works for common classes like Uri and Parcel. While doable, it's extremely annoying due to the large surface area of these API and others like it. A possibility to alleviate some of this pain would be to allow library projects to compile against the test version of the platform jar. With this, fakes could be written and compiled as libraries without the normal restrictions (albeit with fair warning that this represents a deviation from the normal understood stability of platform public APIs). These test-only libraries could then be added as testCompile dependencies which would not be subject to the compilation problems of the regular platform jar but correctly apply at execution time to the test platform jar. Thoughts? -- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
