owncloud / android

:phone: The ownCloud Android App
GNU General Public License v2.0
3.82k stars 3.05k forks source link

[EPIC] Tests refactoring #4063

Open jesmrec opened 1 year ago

jesmrec commented 1 year ago

Current status of tests in ownCloud Android app

We're in the process of refactoring some of the tests or the way we test in the app. We have 2 types of tests in code: unit tests and UI tests.

Unit tests

We want to create unit tests for classes that on the one hand check that their methods return the expected result and on the other hand verify that their methods call the corresponding inner methods:

owncloudData module:

Things to discuss

UI tests

👷🏼‍♂️ (We'll discuss about this and update this section...)

Things to discuss

Related issues

JuancaG05 commented 10 months ago

Datasources classes

When they are not like that, we should move the datasources implementations to a package called datasources.implementation, and make the test classes in the same corresponding package.

OCLocalAppRegistryDataSource: (No tests for this class currently)

OCRemoteAppRegistryDataSource: (No tests for this class currently)

OCLocalAuthenticationDataSource: (No tests for this class currently)

OCRemoteAuthenticationDataSource: This class cannot be tested because we cannot access from the test the objects used inside the methods (they are created internally) (No tests for this class currently)

OCLocalCapabilitiesDataSource: Only insert method test has a verify and delete method has no tests

OCRemoteCapabilitiesDataSource: No verify in the test method

OCLocalFileDataSource: The tests that are currently done check the result and verify the calls, but we don't have tests for getFileByIdAsFlow, getFileByRemoteId, getSearchFolderContent, getSearchAvailableOfflineFolderContent, getSearchSharedByLinkFolderContent, getFolderContentWithSyncInfoAsFlow, getSharedByLinkWithSyncInfoForAccountAsFlow, getFilesWithSyncInfoAvailableOfflineFromAccountAsFlow, getFilesAvailableOfflineFromAccount, getFilesAvailableOfflineFromEveryAccount, moveFile, saveFilesInFolderAndReturnThem, saveFile, saveConflict, cleanConflict, deleteFilesForAccount, renameFile, disableThumbnailsForFile, updateAvailableOfflineStatusForFile, updateDownloadedFilesStorageDirectoryInStoragePath, saveDownloadWorkerUuid, and cleanWorkersUuid

OCRemoteFileDataSource: The tests that are currently done check the result and verify the calls, but we don't have tests for copyFile, moveFile, readFile, refreshFolder, deleteFile, and renameFile

OCFolderBackupLocalDataSource: (No tests for this class currently)

OCRemoteOAuthDataSource: We check the result but we don't verify the calls to other methods

OCSharedPreferencesProvider: (No tests for this class currently)

OCRemoteServerInfoDataSource:

OCRemoteShareeDataSource: We check the result but we don't verify the calls to other methods

OCLocalShareDataSource: Current tests don't have verify, and we don't have tests for insert (receiving a list of shares) and deleteShares

OCRemoteShareDataSource: We check the result but we don't verify the calls to other methods

OCLocalSpacesDataSource: (No tests for this class currently)

OCRemoteSpacesDataSource: (No tests for this class currently)

ScopedStorageProvider: (No tests for this class currently)

OCLocalTransferDataSource: (No tests for this class currently)

OCLocalUserDataSource: Current tests don't have verify, and we don't have tests for getAllUserQuotas and deleteQuotaForAccount

OCRemoteUserDataSource: We check the result but we don't verify the calls to other methods

OCRemoteWebFingerDatasource: (No tests for this class currently)

JuancaG05 commented 10 months ago

Repository classes

When they are not like that, we should move the repository implementations to a package called repository, and make the test classes in the same corresponding package.

OCAppRegistryRepository: (No tests for this class currently)

OCAuthenticationRepository: Rename test methods to follow the convention, and place asserts before verify

OCCapabilityRepository: Some tests don't have verify, and they have to be reordered to keep the order of the implementation

OCFileRepository: We don't have tests for copyFile, getFileByIdAsFlow, getPersonalRootFolderForAccount, getSharesRootFolderForAccount, getSearchFolderContent, getFolderContentWithSyncInfoAsFlow, getSharedByLinkWithSyncInfoForAccountAsFlow, getFilesWithSyncInfoAvailableOfflineFromAccountAsFlow, getFilesAvailableOfflineFromAccount, getFilesAvailableOfflineFromEveryAccount, moveFile, readFile, renameFile, saveConflict, cleanConflict, saveDownloadWorkerUuid, cleanWorkersUuid, disableThumbnailsForFile, updateFileWithNewAvailableOfflineStatus, updateDownloadedFilesStorageDirectoryInStoragePath, and updateFileWithLastUsage

OCFolderBackupRepository: (No tests for this class currently)

OCOAuthRepository: Some tests don't have asserts

OCServerInfoRepository: The current test doesn't explore all the alternatives of the method tested, we need to add some more tests for that method

OCShareeRepository: Rename test methods to follow the convention, and add asserts

OCShareRepository: Rename test methods to follow the convention, reorder them and add verify

OCSpacesRepository: (No tests for this class currently)

OCTransferRepository: (No tests for this class currently)

OCUserRepository: Current tests don't have asserts, and we don't have tests for getAllUserQuotas

OCWebFingerRepository: (No tests for this class currently)