Skip to content

Commit

Permalink
Merge pull request #233 from Nexters/ci
Browse files Browse the repository at this point in the history
Kotest를 이용한 자동 테스트
  • Loading branch information
HamBP authored Apr 20, 2024
2 parents 0c7c430 + 82774dc commit adf7996
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 5 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Android Pull Request CI

on:
pull_request:
branches: [ develop ]

jobs:
unit_test:
runs-on: ubuntu-latest

steps:
- name: Checkout the code
uses: actions/checkout@v3

- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'

- name: set up Android SDK
uses: android-actions/setup-android@v2

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run unit tests
env:
DEBUG_KEYSTORE: ${{ secrets.DEBUG_KEYSTORE }}
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
echo "$KEYSTORE" | base64 -d > ./app/boolti-keystore.keystore
echo "$KEYSTORE_PROPERTIES" > keystore.properties
echo "$LOCAL_PROPERTIES" > local.properties
echo "$GOOGLE_SERVICES" | base64 -d > ./app/google-services.json
./gradlew test --stacktrace
- name: Publish Test Results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "**/test-results/**/*.xml"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ google-services.json
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ plugins {
task("clean", Delete::class) {
delete = setOf(rootProject.buildDir)
}

task("btTest") {
dependsOn(":domain:test", ":data:testDebugUnitTest", ":presentation:testDebugUnitTest")
}
8 changes: 8 additions & 0 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

tasks.getByName<Test>("test") {
useJUnitPlatform()
reports {
junitXml.required.set(false)
}
systemProperty("gradle.build.dir", project.buildDir)
}

dependencies {
implementation(libs.javax.inject)
implementation(libs.kotlinx.coroutines.core)
Expand Down
16 changes: 16 additions & 0 deletions domain/src/test/java/com/nexters/boolti/domain/KotestConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.nexters.boolti.domain

import io.kotest.core.config.AbstractProjectConfig
import io.kotest.core.extensions.Extension
import io.kotest.extensions.junitxml.JunitXmlReporter

class KotestConfig : AbstractProjectConfig() {

override fun extensions(): List<Extension> = listOf(
JunitXmlReporter(
includeContainers = false,
useTestPathAsName = true,
outputDir = "../build/test-results"
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.time.LocalDateTime
class ShowTest : BehaviorSpec() {
private val now = LocalDate.now()
private val standardShow = Show(
id = 1,
id = "1",
name = "",
date = LocalDateTime.MAX,
salesStartDate = LocalDate.MIN,
Expand Down Expand Up @@ -96,4 +96,4 @@ class ShowTest : BehaviorSpec() {
}
}
}
}
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ hilt-android-gradle-plugin = { module = "com.google.dagger:hilt-android-gradle-p
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
javax-inject = { module = "javax.inject:javax.inject", version.ref = "javax-inject" }
junit = { module = "junit:junit", version.ref = "junit" }
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
kotest-runner-junit5-jvm = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" }
kotest-extentions-junitxml = { group = "io.kotest", name = "kotest-extensions-junitxml", version.ref = "kotest"}
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "coroutines" }
Expand Down Expand Up @@ -129,6 +129,6 @@ android-test = ["junit", "androidx-junit", "androidx-espresso-core", "kotlinx-co
network = ["retrofit", "logging-interceptor"]
db = ["androidx-datastore", "androidx-datastore-preferences-core", "androidx-room-runtime", "androidx-room-ktx"]
firebase = ["firebase-analytics-ktx", "firebase-crashlytics-ktx", "firebase-messaging-ktx", "firebase-dynamic-links"]
kotest = ["kotest-assertions-core", "kotest-property", "kotest-runner-junit5"]
kotest = ["kotest-property", "kotest-runner-junit5", "kotest-extentions-junitxml"]
coil = ["coil", "coil-compose"]
compose = ["androidx-activity-compose", "androidx-navigation-compose", "androidx-material3-android", "androidx-compose-ui-ui", "androidx-compose-ui-ui-graphics", "androidx-compose-ui-tooling-preview", "androidx-compose-ui-ui-util", "androidx-lifecycle-runtime-compose"]
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.

0 comments on commit adf7996

Please sign in to comment.