diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index 8052bb3..fdda620 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -1,37 +1,40 @@ name: cute-cat-gallery-ci-pipeline on: pull_request: - branches: [main, develop] + branches: [ main, develop ] push: - branches: [main, develop] + branches: [ main, develop ] jobs: build: runs-on: ubuntu-latest steps: + - name: Checkout uses: actions/checkout@v4.1.0 + - name: Setup Java JDK uses: actions/setup-java@v3.13.0 with: java-version: '17' distribution: 'adopt' - - name: Make gradlew executable - run: chmod +x ./gradlew - - name: Gradle Build Action - uses: gradle/gradle-build-action@v2.9.0 - with: - arguments: build - gradle-version: 7.6 - - name: Run KLint + + - name: Setup Gradle uses: gradle/gradle-build-action@v2.9.0 with: - arguments: ktlintCheck - gradle-version: 7.6 + gradle-version: 8.1.1 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Build + run: ./gradlew assembleDebug + + - name: Run Lint + run: ./gradlew ktlintCheck + - name: Run Tests - uses: gradle/gradle-build-action@v2.9.0 - with: - arguments: test - gradle-version: 7.6 + run: ./gradlew testDebugUnitTest + - name: Upload a Build Artifact uses: actions/upload-artifact@v3.1.3 with: diff --git a/.gitignore b/.gitignore index 276b709..eb75477 100644 --- a/.gitignore +++ b/.gitignore @@ -180,8 +180,7 @@ crashlytics-build.properties fabric.properties ### AndroidStudio Patch ### - -!/gradle/wrapper/gradle-wrapper.jar +!gradle/wrapper/gradle-wrapper.jar ### Intellij ### # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm diff --git a/app/build.gradle b/app/build.gradle index fdfa34a..dbdc9d7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,9 @@ plugins { android { compileSdk 34 - + packagingOptions { + exclude 'META-INF/INDEX.LIST' + } defaultConfig { applicationId "com.luishenrique.cutecatsgallery" minSdkVersion 21 @@ -61,6 +63,8 @@ dependencies { implementation "androidx.compose.material:material-android:1.5.3" implementation "io.coil-kt:coil-compose:2.4.0" implementation "androidx.navigation:navigation-compose:2.7.4" + testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' + testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" androidTestImplementation platform("androidx.compose:compose-bom:2023.10.00") @@ -68,6 +72,8 @@ dependencies { implementation 'com.google.accompanist:accompanist-swiperefresh:0.32.0' + implementation 'com.google.guava:guava:27.0.1-android' + // progressbar cat implementation "com.roger.catloadinglibrary:catloadinglibrary:1.0.9" @@ -83,10 +89,16 @@ dependencies { // viewModel implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2" + // Testng + implementation "org.testng:testng:$testng_version" + + // Mockk + testImplementation "io.mockk:mockk:$mockk_version" + implementation "androidx.core:core-ktx:1.12.0" implementation "com.google.android.material:material:1.10.0" implementation "androidx.appcompat:appcompat:1.6.1" - testImplementation "junit:junit:4.13.2" + testImplementation "junit:junit:*" androidTestImplementation "androidx.test.ext:junit:1.1.5" androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1" } \ No newline at end of file diff --git a/app/src/main/kotlin/com/luishenrique/cutecatsgallery/home/presentation/HomeViewModelTest.kt b/app/src/main/kotlin/com/luishenrique/cutecatsgallery/home/presentation/HomeViewModelTest.kt new file mode 100644 index 0000000..fab9ea4 --- /dev/null +++ b/app/src/main/kotlin/com/luishenrique/cutecatsgallery/home/presentation/HomeViewModelTest.kt @@ -0,0 +1,19 @@ +package com.luishenrique.cutecatsgallery.home.presentation + +import org.junit.Before +import org.junit.Test + +class HomeViewModelTest { + +// private lateinit var viewModel: HomeViewModel + + @Before + fun before() { +// viewModel = null + } + +// @Test +// fun `given getCats method when call it then cancel job`() { +//// viewModel.getCats() +// } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 655b133..648273f 100644 --- a/build.gradle +++ b/build.gradle @@ -10,6 +10,8 @@ buildscript { klint_version = "9.2.1" compose_version = "1.5.3" compose_compiler_version = "1.4.3" + mockk_version = "1.13.8" + testng_version = "7.3.0" } repositories { google() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c85a1f..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..aeb74cb 100644 --- a/gradlew +++ b/gradlew @@ -85,9 +85,6 @@ done APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -144,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in