Add tests for new build stats utilities
Is your feature request related to a problem? Please describe. #4092 introduced several new utilities and a new script to help report build stats for PRs. These require unit tests for behavior regression verification.
Describe the solution you'd like Each of the new, untested classes in the PR need tests to cover their main behaviors. Below are the new classes and minimum tests to add (more are likely needed, these are just a first pass):
-
[x] Add tests for Aapt2Client (suggest using the command locally to get an idea on the sort of output that the class will encounter)
- testDumpPermissions_nonExistentApk_failsWithError
- testDumpPermissions_invalidApk_failsWithError
- testDumpPermissions_apkWithNoPermissions_returnsEmptyList
- testDumpPermissions_apkWithSomePermissions_returnsListOfQualifiedPermissionNames
- testDumpResources_nonExistentApk_failsWithError
- testDumpResources_invalidApk_failsWithError
- testDumpResources_apkWithNoResources_returnsEmptyList
- testDumpResources_apkWithOnlyStrings_returnsListWithResourcesWithTypesAndIds
- testDumpResources_apkWithOnlyDrawables_returnsListWithResourcesWithTypesAndIds
- testDumpResources_apkWithOnlyLayouts_returnsListWithResourcesWithTypesAndIds
- testDumpResources_apkWithManyResources_returnsListWithResourcesWithTypesAndIds
- testDumpBadging_nonExistentApk_failsWithError
- testDumpBadging_invalidApk_failsWithError
- testDumpBadging_apkWithNoExtraBadgingInfo_returnsPackageAndGenericInfo
- testDumpBadging_apkWithOnlyUsesFeatures_returnsBadgingInfo
- testDumpBadging_apkWithOnlyUsesImpliedFeatures_returnsBadgingInfo
- testDumpBadging_apkWithOnlyUsesFeaturesNotRequired_returnsBadgingInfo
- testDumpBadging_apkWithOnlyUsesPermission_returnsBadgingInfo
- testDumpBadging_apkWithAllOppiaLikeBadgingInfo_returnsBadgingInfo
-
[x] Add tests for ApkAnalyzerClient (suggest using the
apkanalyzercommand locally to get an idea on the sort of output that the class will encounter since this utility interacts with apkanalyzer through its internal library)- testComputeFileSize_nonExistentApk_failsWithError
- testComputeFileSize_invalidApk_failsWithError
- testComputeFileSize_apkWithSomeClassesAndResources_returnsCorrectRawApkSize
- testComputeFileSize_apkWithMoreClassesAndResources_returnsCorrectRawApkSize
- testComputeDownloadSize_nonExistentApk_failsWithError
- testComputeDownloadSize_invalidApk_failsWithError
- testComputeDownloadSize_apkWithSomeClassesResources_returnsEstDownloadSize
- testComputeDownloadSize_apkWithMoreSomeClassesResources_returnsEstDownloadSize
- testComputeFeatures_nonExistentApk_failsWithError
- testComputeFeatures_invalidApk_failsWithError
- testComputeFeatures_apkWithNoFeatures_returnsEmptyList
- testComputeFeatures_apkWithSomeFeatures_returnsListOfFeatures
- testCompare_firstApk_isNonExistent_failsWithError
- testCompare_secondApk_isNonExistent_failsWithError
- testCompare_firstApk_isInvalid_failsWithError
- testCompare_secondApk_isInvalid_failsWithError
- testCompare_complexApks_firstSecondAreSame_returnsEmptyList
- testCompare_twoDifferentComplexApks_returnsListOfDifferences
- testComputeDexReferencesList_nonExistentApk_failsWithError
- testComputeDexReferencesList_invalidApk_failsWithError
- testComputeDexReferencesList_apkWithoutDexFiles_returnsEmptyMap
- testComputeDexReferencesList_apkWithOneSmallDexFile_returnsMapWithRefCount
- testComputeDexReferencesList_apkWithOneLargeDexFile_returnsMapWithRefCount
- testComputeDexReferencesList_apkWithMultipleDexFiles_returnsMapWithRefCounts
-
[x] Add tests for BundleToolClient (suggest using the
bundletoolutility locally to get an idea on the sort of output that the class will encounter--you can download it using the instructions at: https://developer.android.com/tools/bundletool)- testBuildApks_nonExistentInputAab_failsWithError
- testBuildApks_invalidInputAab_failsWithError
- testBuildApks_aabWithOneConfiguration_returnsListWithSingleApkFile
- testBuildApks_aabWithMultipleConfigurations_returnsListWithAllApkFiles
- testBuildUniversalApk_nonExistentInputAab_failsWithError
- testBuildUniversalApk_invalidInputAab_failsWithError
- testBuildUniversalApk_aabWithOneConfiguration_returnsValidUniversalApkFile
- testBuildUniversalApk_aabWithMultipleConfigurations_returnsValidUniversalApkFile
-
[ ] Add tests for ComputeAabDifferences (suggest running the script locally on Oppia AABs to get an idea of the kinds of output it can produce in different circumstances)
- testMain_noArguments_failsWithError
- testMain_oneArgument_failsWithError
- testMain_twoArguments_failsWithError
- testMain_threeArguments_failsWithError
- testMain_fourArguments_failsWithError
- testMain_sixArguments_failsWithError
- testMain_sevenArguments_failsWithError
- testMain_fiveArguments_invalidBeforeAab_failsWithError
- testMain_fiveArguments_invalidAfterAab_failsWithError
- testMain_eightArguments_invalidBeforeAabForConfig2_failsWithError
- testMain_eightArguments_invalidAfterAabForConfig2_failsWithError
- testMain_fiveArguments_validAabs_generatesShortAndLongSummariesForOneConfig
- testMain_eightArguments_validAabs_generatesShortAndLongSummariesForTwoConfigs
- testComputeBuildStats_zeroProfiles_returnsEmptyBuildStats
- testComputeBuildStats_oneProfile_invalidBeforeAab_throwsException
- testComputeBuildStats_oneProfile_invalidAfterAab_throwsException
- testComputeBuildStats_oneProfile_sameAab_returnsCorrectAabStatsWithNoDiffs
- testComputeBuildStats_oneProfile_diffAabs_returnsCorrectConfigAndDiffStats
- testComputeBuildStats_twoProfiles_sameAabs_returnsCorrectAabStatsWithNoDiffsForEach
- testComputeBuildStats_twoProfiles_diffAabs_returnsCorrectConfigAndDiffStatsForEach
- testAabStats_writeSummaryTo_emptyStats_printsMinimalOutput
- testAabStats_writeSummaryTo_statsAndDiffs_lowItemLimit_reducesOutput
- testAabStats_writeSummaryTo_statsAndDiffs_longSummaryOff_reducesOutput
- testAabStats_writeSummaryTo_statsAndDiffs_longSummaryOn_withItemLimit_printsLimitedDetails
- testAabStats_writeSummaryTo_statsAndDiffs_longSummaryOn_withLimit_printsExtensiveDetails
- testEntireScript_usingMain_forOneProfile_generatesCorrectShortSummary
- testEntireScript_usingMain_forOneProfile_generatesCorrectLongSummary
- testEntireScript_usingMain_forTwoProfiles_generatesCorrectShortSummary
- testEntireScript_usingMain_forTwoProfiles_generatesCorrectLongSummary
Describe alternatives you've considered N/A -- All utilities require tests.
Additional context Each of the utilities above already have existing placeholder test suites that are ready for new tests to be added, and should already build, run, and pass.
All other script & script utility tests are good to reference when building these. Note that these tests can only be run with Bazel and syntax highlighting/auto completion won't work in Android Studio unless using the Bazel plugin.
Note also that these tests often require creating real test data (such as APKs) to verify their functionality. This should be done without needing to permanently check in any binary files to the repository (prefer generating the files at runtime during the test run, instead).
Hi @theMr17, would it be possible for me to work on a section of this issue that you’re not currently working on?
Hey @manas-yu, thanks for checking in. I had initially started with ComputeAabDifferences, but I'm not actively working on it at the moment. Feel free to assign yourself and proceed with the other sections.
Remaining tests are the ComputeAabDifferences tests that are NOT greyed out. 1-13.