Skip to content

Commit

Permalink
feat: Add unit testing dependencies
Browse files Browse the repository at this point in the history
Add Junit 5 and Mockk test dependencies with simple test
  • Loading branch information
albendz committed Oct 11, 2024
1 parent 0ce5921 commit e6adbce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ plugins {
id("org.jmailen.kotlinter")
id("io.gitlab.arturbosch.detekt")
id("com.google.devtools.ksp") version "2.0.0-1.0.22" apply true
id("de.mannodermaus.android-junit5") version "1.11.2.0"
}

val kotlinVersion by extra("2.0.0")
val junit5Version by extra("5.11.2")
val mockkVersion by extra("1.13.13")

android {
compileSdk = 34
Expand Down Expand Up @@ -87,6 +91,7 @@ android {
buildUponDefaultConfig = true
allRules = false
config = rootProject.files("detekt.yml")

}

kotlinter {
Expand Down Expand Up @@ -115,6 +120,10 @@ dependencies {
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.viewpager2:viewpager2:1.1.0")

testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version")
testImplementation("io.mockk:mockk:$mockkVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit5Version")

api("joda-time:joda-time:2.10.13")
api("com.github.tibbi:RecyclerView-FastScroller:e7d3e150c4")
api("com.github.tibbi:reprint:2cb206415d")
Expand Down
18 changes: 18 additions & 0 deletions app/src/test/kotlin/helpers/AlphanumericComparatorTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package helpers

import be.scri.helpers.AlphanumericComparator
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

class AlphanumericComparatorTest {
private val subject = AlphanumericComparator()

@Test
fun testCompare() {
assertEquals(-1, subject.compare("IMG_10.png", "IMG_11.png"))

assertEquals(0, subject.compare("IMG_10.png", "IMG_10.png"))

assertEquals(1, subject.compare("IMG_11.png", "IMG_10.png"))
}
}

0 comments on commit e6adbce

Please sign in to comment.