But how does subclassing solve the problem of covering a large surface of API? If you need a library with fakes, you can make a library with factories producing these fakes with mocking...
On Tuesday, 3 February 2015 22:32:05 UTC-8, Jake Wharton wrote: > > 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.
