From b96ffcc5ea2f2537fd2f08920ad5c4d1a1be4cd1 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Wed, 5 Apr 2023 23:46:40 +0200 Subject: [PATCH] Install and use kotest --- build.gradle.kts | 2 ++ .../FunctionGeneratorTest.kt | 33 +++++++------------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9d0c400..d9605e0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -75,6 +75,8 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter:5.9.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.7.20") testImplementation("org.amshove.kluent:kluent:1.68") + testImplementation("io.kotest:kotest-runner-junit5:5.5.5") + testImplementation("io.kotest:kotest-property:5.5.5") } val sourcesJar by tasks.creating(Jar::class) { diff --git a/src/test/kotlin/fr/postgresjson/functionGenerator/FunctionGeneratorTest.kt b/src/test/kotlin/fr/postgresjson/functionGenerator/FunctionGeneratorTest.kt index 6777e48..239573e 100644 --- a/src/test/kotlin/fr/postgresjson/functionGenerator/FunctionGeneratorTest.kt +++ b/src/test/kotlin/fr/postgresjson/functionGenerator/FunctionGeneratorTest.kt @@ -1,15 +1,14 @@ package fr.postgresjson.functionGenerator import fr.postgresjson.definition.Function -import kotlin.test.assertEquals -import org.junit.jupiter.api.Test +import io.kotest.core.spec.style.StringSpec +import org.amshove.kluent.`should be equal to` -class FunctionGeneratorTest { - private val functionDirectory = this::class.java.getResource("/sql/function/Test")!!.toURI() - private val generator = FunctionGenerator(functionDirectory) +class FunctionGeneratorTest : StringSpec({ + val functionDirectory = this::class.java.getResource("/sql/function/Test")!!.toURI() + val generator = FunctionGenerator(functionDirectory) - @Test - fun `generate function`() { + "generate function with input object and output object" { val functionSql = """ |create or replace function test_function_object (inout resource json) |language plpgsql @@ -34,13 +33,10 @@ class FunctionGeneratorTest { |} """.trimMargin() - val generated: String = generator.generate(Function(functionSql)) - - assertEquals(expectedGenerated, generated) + generator.generate(Function(functionSql)) `should be equal to` expectedGenerated } - @Test - fun `generate function with return void`() { + "generate function with return void" { val functionSql = """ |create or replace function test_function_void (name text default 'plop') returns void |language plpgsql @@ -63,13 +59,10 @@ class FunctionGeneratorTest { |} """.trimMargin() - val generated: String = generator.generate(Function(functionSql)) - - assertEquals(expectedGenerated, generated) + generator.generate(Function(functionSql)) `should be equal to` expectedGenerated } - @Test - fun `generate function with multiple args and defaults`() { + "generate function with multiple args and defaults" { val functionSql = """ |create or replace function test_function_multiple (name text default 'plop', in hi text default 'hello', out result json) |language plpgsql @@ -96,8 +89,6 @@ class FunctionGeneratorTest { |} """.trimMargin() - val generated: String = generator.generate(Function(functionSql)) - - assertEquals(expectedGenerated, generated) + generator.generate(Function(functionSql)) `should be equal to` expectedGenerated } -} \ No newline at end of file +}) \ No newline at end of file