Skip to content

Commit

Permalink
test(unit test): add unit test
Browse files Browse the repository at this point in the history
- simple unit test
- update app build.gradle
- run unit test and build in pipeline
  • Loading branch information
TheRealPad committed Feb 1, 2024
1 parent 381ca96 commit ad72a28
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,30 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: echo "test build"
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Build with Gradle
run: ./gradlew build

unit-test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Run unit tests
run: echo "run unit test"
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Run unit tests with Gradle
run: ./gradlew test
6 changes: 2 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ dependencies {
implementation("androidx.wear.compose:compose-foundation:1.1.2")
implementation("androidx.activity:activity-compose:1.7.2")
implementation("androidx.core:core-splashscreen:1.0.1")
testImplementation("org.testng:testng:6.9.6")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("androidx.wear:wear:1.3.0")
//implementation("androidx.compose.ui:ui:1.1.0-alpha07")
//implementation("androidx.compose.material:material:1.1.0-alpha07")
//implementation("androidx.ui:ui-tooling:1.1.0-alpha07")
}
}
20 changes: 20 additions & 0 deletions app/src/test/java/com/eipsaferoad/owl/OwlTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.eipsaferoad.owl

import org.junit.Assert.assertEquals
import org.junit.Test

class OwlTest {

@Test
fun testAddition() {
// Arrange
val number1 = 1
val number2 = 1

// Act
val sum = number1 + number2

// Assert
assertEquals(2, sum)
}
}

0 comments on commit ad72a28

Please sign in to comment.