Visitar URL original
[EPIC] Tests refactoring · Issue #4063 · owncloud/android · GitHub
Skip to content

[EPIC] Tests refactoring #4063

Open
Open

Description

@jesmrec

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

  • Check migration tests and remove them if not useful
    Answer:
  • Check why authentication.datasources.implementation is instrumented
    Answer: it needs the context, so we need the test to be instrumented to get it
  • Move providers to another package called providers?
    Answer: yes, they will be moved

UI tests

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

Things to discuss

  • Naming of the tests: which format should we follow? testSomethingReturnsFoo or something - ok - returns foo
    Answer: for the moment, we decided to follow the convention: {name of the method} returns {foo} when {conditions or environment}
  • Are tests which expect exceptions necessary?
    Answer: if they just make a mock throw an exception, without the method being tested catching it and doing something with it, they are not necessary since we're not testing real code

Related issues

Activity

  1. changed the title [-]Test review[/-] [+][EPIC] Test refactort[/+] on Jun 13, 2023
  2. changed the title [-][EPIC] Test refactort[/-] [+][EPIC] Tests refactoring[/+] on Jun 13, 2023
  3. JuancaG05 commented on Nov 23, 2023

    @JuancaG05
    Contributor

    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)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCRemoteAppRegistryDataSource:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCLocalAuthenticationDataSource:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    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)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCRemoteCapabilitiesDataSource:
    No verify in the test method

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCFolderBackupLocalDataSource:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCSharedPreferencesProvider:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCRemoteServerInfoDataSource:

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCLocalSpacesDataSource:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCRemoteSpacesDataSource:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    ScopedStorageProvider:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCLocalTransferDataSource:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCRemoteWebFingerDatasource:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes
  4. JuancaG05 commented on Nov 24, 2023

    @JuancaG05
    Contributor

    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)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCFolderBackupRepository:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCOAuthRepository:
    Some tests don't have asserts

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCSpacesRepository:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCTransferRepository:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

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

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes

    OCWebFingerRepository:
    (No tests for this class currently)

    • Check that every method returns the expected result
    • Verify that every method calls the corresponding methods of other classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions