Skip to content

Commit

Permalink
Migrate tests from DynaTest to JUnit5
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Jan 31, 2025
1 parent 9d55a57 commit ad5c4bc
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 543 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dependencies {
testImplementation(libs.bundles.hibernate.validator)

// tests
testImplementation(libs.dynatest)
testImplementation(kotlin("test"))
testImplementation(libs.junit.jupiter.engine)
testImplementation(libs.bundles.gson)
Expand Down
7 changes: 2 additions & 5 deletions src/test/kotlin/com/github/vokorm/AbstractDbDaoTests.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.github.vokorm

import com.github.mvysny.dynatest.DynaNodeGroup
import com.github.mvysny.dynatest.DynaTestDsl
import com.github.mvysny.dynatest.expectThrows
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import java.time.Instant
Expand Down Expand Up @@ -105,14 +102,14 @@ abstract class AbstractDbDaoTests {

@Test fun `fails if there are two matching entities`() {
repeat(2) { Person(name = "Albedo", age = 131).save() }
expectThrows(IllegalStateException::class, "too many rows matching Person: '(Test.name) = ") {
expectThrows<IllegalStateException>("too many rows matching Person: '(Test.name) = ") {
Person.findSingleBy { Person::name eq "Albedo" }
}
}

@Test fun `fails if there are ten matching entities`() {
repeat(10) { Person(name = "Albedo", age = 132).save() }
expectThrows(IllegalStateException::class, "too many rows matching Person: '(Test.name) = ") {
expectThrows<IllegalStateException>("too many rows matching Person: '(Test.name) = ") {
Person.findSingleBy { Person::name eq "Albedo" }
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/kotlin/com/github/vokorm/AbstractDbMappingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package com.github.vokorm

import com.github.mvysny.dynatest.*
import org.jdbi.v3.core.mapper.reflect.FieldMapper
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -59,7 +58,7 @@ abstract class AbstractDbMappingTests() {
}
@Test fun `updating non-existing row fails`() {
val p = Person(id = 15, name = "Zaphod", age = 20, created = Date(1000), modified = Instant.ofEpochMilli(120398123))
expectThrows(IllegalStateException::class, "We expected to update only one row but we updated 0 - perhaps there is no row with id 15?") {
expectThrows<IllegalStateException>("We expected to update only one row but we updated 0 - perhaps there is no row with id 15?") {
p.save()
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/kotlin/com/github/vokorm/ConditionBuilderTest.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.github.vokorm

import com.github.mvysny.dynatest.DynaTest
import org.junit.jupiter.api.Test
import kotlin.test.expect

class ConditionBuilderTest : DynaTest({
test("smoke API tests") {
class ConditionBuilderTest {
@Test fun `smoke API tests`() {
buildCondition { Person::name eq "foo" }
buildCondition { !(Person::name eq "foo") }
buildCondition { (Person::name eq "foo") and (Person::id gt 25)}
buildCondition { (Person::name eq "foo") or (Person::id gt 25)}
}
test("produced condition") {
@Test fun `produced condition`() {
expect("Person.name = foo") {
buildCondition { Person::name eq "foo" } .toString()
}
Expand All @@ -24,4 +24,4 @@ class ConditionBuilderTest : DynaTest({
buildCondition { (Person::name eq "foo") or (Person::id gt 25)} .toString()
}
}
})
}
233 changes: 0 additions & 233 deletions src/test/kotlin/com/github/vokorm/DaoTest.kt

This file was deleted.

Loading

0 comments on commit ad5c4bc

Please sign in to comment.