From d6ee1f7ff3cf62aef3718fcd397876db9e33bc6b Mon Sep 17 00:00:00 2001 From: Andhika Yuana Date: Thu, 12 Dec 2024 15:46:46 +0700 Subject: [PATCH] Unit Test(s) Migration (#287) * chore: [test] add BRConstantsTest for unitTest and deprecated ConstantsTests inside androidTest * chore: [test] remove unused test files * chore: [test] add todo to fill the tests and change package name * chore: [test] add basic example * chore: [test] integrate with ci/cd * chore: [test][ci] fix Cannot find a definition for command named android/restore-gradle-cache * chore: [test][ci] fix Cannot find a definition for command named android/run-tests * chore: [test][ci] fix Unexpected argument(s): test-command * chore: [test][ci] fix Cannot find a definition for executor named android/android-docker * chore: [test][ci] add default for gradle.properties * chore: [test][ci] avoid breaking in build.gradle * chore: [test][ci] enable androidx and jetifier * chore: [test][ci] init submodule * chore: [test][ci] just using run command for execute unit test step * chore: [test][ci] add env for google-services.json * chore: [test][ci] add env for google-services.json * chore: [test][ci] add env for google-services.json * Major refactor of code to move classes to the ideal location - Removed cruft - Moved all tests to the unitTest directory - Remove poorly placed tests into (AndroidTest) - Commented old code into the new Kotlin class(es) - working in the first test of currency - Removed the paymentRequest method - Renamed Classes * chore: resolve CurrencyTests * Added notes --------- Co-authored-by: Kerry Washington --- .circleci/config.yml | 46 +- .gitignore | 1 + .idea/inspectionProfiles/Project_Default.xml | 3 + app/build.gradle | 1 + .../java/com/litewallet/PaperKeyTests.java | 81 -- .../litewallet/analytics/ConstantsTests.java | 79 -- .../litewallet/database/DatabaseTests.java | 160 --- .../com/litewallet/platform/KVStoreTests.java | 590 --------- .../litewallet/platform/PlatformTests.java | 92 -- .../activities/tests/MainActivityTest.java | 132 -- .../tests/CurrencyFormatterFixedTests.java | 129 -- .../tests/CurrencyFormatterTests.java | 129 -- .../litewallet/security/KeyStoreTests.java | 322 ----- .../litewallet/security/NewKeyStoreTests.java | 176 --- .../com/litewallet/wallet/WalletTests.java | 115 -- .../tools/sqlite/CurrencyDataSource.java | 1 - .../com/litewallet/currency/CurrencyTests.kt | 100 ++ .../com/litewallet/example/ExampleTest.kt | 125 ++ .../tools/database/DatabaseTests.kt | 85 ++ .../database/TransactionDataSourceTest.kt | 3 + .../tools/security/BRKeyStoreTest.kt | 1059 +++++++++++++++++ .../tools/security/NewKeyStoreTests.kt | 190 +++ .../tools/security/ReplicatedKVStoreTest.kt | 4 + .../litewallet/tools/util/BRConstantsTest.kt | 108 ++ .../litewallet/tools/util/Bip39ReaderTest.kt | 4 + .../tools/util/LocaleHelperTest.kt | 13 +- .../litewallet/tools/util/SeedWordTests.kt | 89 ++ 27 files changed, 1820 insertions(+), 2017 deletions(-) delete mode 100644 app/src/androidTest/java/com/litewallet/PaperKeyTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/analytics/ConstantsTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/database/DatabaseTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/platform/KVStoreTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/platform/PlatformTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/presenter/activities/tests/MainActivityTest.java delete mode 100644 app/src/androidTest/java/com/litewallet/presenter/currencyformatting/tests/CurrencyFormatterFixedTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/presenter/currencyformatting/tests/CurrencyFormatterTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/security/KeyStoreTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/security/NewKeyStoreTests.java delete mode 100644 app/src/androidTest/java/com/litewallet/wallet/WalletTests.java create mode 100644 app/src/test/java/com/litewallet/currency/CurrencyTests.kt create mode 100644 app/src/test/java/com/litewallet/example/ExampleTest.kt create mode 100644 app/src/test/java/com/litewallet/tools/database/DatabaseTests.kt create mode 100644 app/src/test/java/com/litewallet/tools/database/TransactionDataSourceTest.kt create mode 100644 app/src/test/java/com/litewallet/tools/security/BRKeyStoreTest.kt create mode 100644 app/src/test/java/com/litewallet/tools/security/NewKeyStoreTests.kt create mode 100644 app/src/test/java/com/litewallet/tools/security/ReplicatedKVStoreTest.kt create mode 100644 app/src/test/java/com/litewallet/tools/util/BRConstantsTest.kt create mode 100644 app/src/test/java/com/litewallet/tools/util/Bip39ReaderTest.kt rename app/src/test/java/com/{breadwallet => litewallet}/tools/util/LocaleHelperTest.kt (83%) create mode 100644 app/src/test/java/com/litewallet/tools/util/SeedWordTests.kt diff --git a/.circleci/config.yml b/.circleci/config.yml index 6554e1f4e..4685ef3ef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,25 +2,51 @@ # See: https://circleci.com/docs/2.0/configuration-reference version: 2.1 +orbs: + android: circleci/android@3.0.2 + # Define a job to be invoked later in a workflow. # See: https://circleci.com/docs/2.0/configuration-reference/#jobs jobs: - say-hello: - # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor - docker: - - image: cimg/base:stable - # Add steps to the job - # See: https://circleci.com/docs/2.0/configuration-reference/#steps + unit-test: + executor: + name: android/android_machine + resource_class: large + tag: default steps: - checkout - run: name: "Say hello" - command: "echo Hello, World!" + command: "echo Hello, World! && ls" + - run: + name: "Default for gradle.properties" + command: "echo \"RELEASE_STORE_FILE=/\nRELEASE_STORE_PASSWORD=\nRELEASE_KEY_ALIAS=\nRELEASE_KEY_PASSWORD=\nandroid.useAndroidX=true\nandroid.enableJetifier=true\" >> gradle.properties && ls && cat gradle.properties" + - run: + name: "Initialize submodule" + command: "git submodule init && git submodule update --init --recursive" + - run: + name: "Copy google-services.json" + command: echo "$GOOGLE_SERVICES_JSON" | base64 --decode > app/google-services.json + - android/restore_gradle_cache + - run: + name: "Execute Unit Test" + command: ./gradlew testLitewalletDebugUnitTest + - android/save_gradle_cache + - run: + name: Save test results + command: | + mkdir -p ~/test-results/junit/ + find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; + when: always + - store_test_results: + path: ~/test-results + - store_artifacts: + path: ~/test-results/junit + # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows workflows: - say-hello-workflow: + test-and-build: jobs: - - say-hello + - unit-test diff --git a/.gitignore b/.gitignore index 87c9c4c0e..4a1b1f202 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,4 @@ app/src/litewalletDebug/google-services.json /.idea/dictionaries/grunt.xml androidTestResultsUserPreferences.xml .idea/deploymentTargetSelector.xml +.idea/inspectionProfiles/Project_Default.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index ecd817f69..f7d4c3d75 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,6 +1,9 @@