From 17e4064ffb9b1578bffc24f742d5fc05ceadc0d6 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Wed, 5 Oct 2022 12:27:21 +0600 Subject: [PATCH 1/2] Configured CI to run Unit test --- .gitlab-ci.yml | 15 +++++++++++++++ app/build.gradle | 1 + .../java/foundation/e/apps/OpenForTesting.kt | 4 ++-- .../java/foundation/e/apps/OpenForTesting.kt | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3bd0414f..7d81cfc95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlew + # Debug build related jobs buildDebug: stage: debug @@ -17,6 +18,20 @@ buildDebug: paths: - app/build/outputs/apk/debug/ +test: + allow_failure: true + stage: debug + script: + - ls /usr/lib/jvm/ + - ./gradlew test -PtestAccountName="$testAccountName" -PtestAccountPwd="$testAccountPwd" -PtestServerUrl="$testServerUrl" + artifacts: + when: always + paths: + - app/build/test-results/*/TEST-*.xml + - app/build/reports/tests/* + reports: + junit: app/build/test-results/*/TEST-*.xml + # Default lint configuration for debug builds # Manual as we don't want to run them generally for debug builds .lintDebugDefault: diff --git a/app/build.gradle b/app/build.gradle index 79c8acd73..97ac3b43b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -106,6 +106,7 @@ kapt { allOpen { // allows mocking for classes w/o directly opening them for release builds annotation 'foundation.e.apps.OpenClass' + annotation 'foundation.e.apps.OpenForTesting' } dependencies { diff --git a/app/src/debug/java/foundation/e/apps/OpenForTesting.kt b/app/src/debug/java/foundation/e/apps/OpenForTesting.kt index d7facea95..cea56ce8a 100644 --- a/app/src/debug/java/foundation/e/apps/OpenForTesting.kt +++ b/app/src/debug/java/foundation/e/apps/OpenForTesting.kt @@ -21,12 +21,12 @@ package foundation.e.apps * This annotation allows us to open some classes for mocking purposes while they are final in * release builds. */ -@Target(AnnotationTarget.ANNOTATION_CLASS) +@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS]) annotation class OpenClass /** * Annotate a class with [OpenForTesting] if you want it to be extendable in debug builds. */ @OpenClass -@Target(AnnotationTarget.CLASS) +@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS]) annotation class OpenForTesting diff --git a/app/src/release/java/foundation/e/apps/OpenForTesting.kt b/app/src/release/java/foundation/e/apps/OpenForTesting.kt index 372dc732d..eef9a7fd7 100644 --- a/app/src/release/java/foundation/e/apps/OpenForTesting.kt +++ b/app/src/release/java/foundation/e/apps/OpenForTesting.kt @@ -17,5 +17,5 @@ package foundation.e.apps -@Target(AnnotationTarget.CLASS) +@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS]) annotation class OpenForTesting -- GitLab From dfc6379909f0fad60f5b38b6bb4988259dd8ef6b Mon Sep 17 00:00:00 2001 From: hasibprince Date: Wed, 12 Oct 2022 16:27:53 +0600 Subject: [PATCH 2/2] unncessary command is removed --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7d81cfc95..61c5e2e3a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,6 @@ test: allow_failure: true stage: debug script: - - ls /usr/lib/jvm/ - ./gradlew test -PtestAccountName="$testAccountName" -PtestAccountPwd="$testAccountPwd" -PtestServerUrl="$testServerUrl" artifacts: when: always -- GitLab