Refactor the PackageBackwardCompatibilityTest
An upcoming change will add another library that needs to be added for backwards compatibility. Merging the tests for those into the existing test class makes it much harder to see and the tests start to overlap, i.e. some tests will test more than one aspect which makes maintenance more difficult and debugging more complex. This splits the test methods in PackageBackwardCompatibilityTest out into separate tests for the different PackageSharedLibraryUpdater implementations into their own classes and simply tests that the PackageBackwardCompatibility class uses the correct implementations. This allows each PackageSharedLibraryUpdater to provide comprehensive tests for their own behavior without affecting tests for the other classes. The OrgApacheHttpLegacyUpdaterTest only runs if the OrgApacheHttpLegacyUpdater class is on the classpath. That is done using OptionalClassRunner which is a custom JUnit Runner that runs the tests in a class iff a specific class is present. Otherwise, it behaves as if the class had a single test that made an invalid assumption. Tested by building with and without REMOVE_OAHL_FROM_BCP=true and then running the following: adb install -r -g out/target/product/marlin/testcases/FrameworksCoreTests/FrameworksCoreTests.apk && adb shell am instrument -w -e class android.content.pm.PackageBackwardCompatibilityTest,android.content.pm.AndroidTestRunnerSplitUpdaterTest,android.content.pm.OrgApacheHttpLegacyUpdaterTest,android.content.pm.RemoveUnnecessaryOrgApacheHttpLegacyLibraryTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner Bug: 18027885 Test: as above Change-Id: Idd1a343d234a57d518010c5a79030cbd7682e0c1
Loading
Please register or sign in to comment