From 646a1a4cb31822c22b8cb775ae707427edd3ae6b Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Mon, 10 Oct 2022 14:29:15 +0100 Subject: [PATCH] Remove Kotest from Micronaut-test (#657) * Remove Kotest from Micronaut-test For 4.0.0 we only will support Kotest 5, so remove the tests for Kotest They were failing anyway, as we had removed the kotest4 dependencies from the build * Disable PTS for kotest * Fix japicmp * Add snapshot repo to main build for coverage --- build.gradle | 5 + settings.gradle | 1 - test-bom/build.gradle | 6 + test-kotest/build.gradle | 52 ------- .../kotest/MicronautKotestContext.kt | 98 -------------- .../kotest/MicronautKotestExtension.kt | 127 ------------------ .../kotest/annotation/MicronautTest.kt | 96 ------------- .../test/kotest/ApplicationRunAnotherTest.kt | 63 --------- .../kotlin/io/micronaut/test/kotest/Book.kt | 16 --- .../test/kotest/ConstructorPropertyTest.kt | 22 --- .../io/micronaut/test/kotest/DbProperties.kt | 14 -- .../test/kotest/DefaultTestService.kt | 12 -- .../kotest/DisableEmbeddedApplicationTest.kt | 23 ---- .../test/kotest/EmptyConstructorTest.kt | 19 --- .../test/kotest/JpaNoRollbackTest.kt | 62 --------- .../micronaut/test/kotest/JpaRollbackTest.kt | 46 ------- .../test/kotest/MathCollaboratorTest.kt | 49 ------- .../micronaut/test/kotest/MathController.kt | 15 --- .../test/kotest/MathInnerService2Test.kt | 38 ------ .../test/kotest/MathMockService2Test.kt | 29 ---- .../test/kotest/MathMockServiceTest.kt | 42 ------ .../io/micronaut/test/kotest/MathService.kt | 8 -- .../micronaut/test/kotest/MathServiceImpl.kt | 12 -- .../micronaut/test/kotest/MathServiceTest.kt | 29 ---- .../kotest/MathServiceTestSimilarNameTest.kt | 35 ----- .../test/kotest/NewAnnotationTest.kt | 28 ---- .../test/kotest/NonTransactionalTest.kt | 24 ---- .../io/micronaut/test/kotest/ProjectConfig.kt | 10 -- .../test/kotest/PropertySourceTest.kt | 24 ---- .../test/kotest/PropertyValueRequiresTest.kt | 45 ------- .../test/kotest/PropertyValueTest.kt | 32 ----- .../io/micronaut/test/kotest/RequiresTest.kt | 17 --- .../io/micronaut/test/kotest/SimpleTest.kt | 15 --- .../micronaut/test/kotest/TestController.kt | 14 -- .../test/kotest/TestPropertiesProviderTest.kt | 27 ---- .../io/micronaut/test/kotest/TestService.kt | 7 - .../test/kotest/TransactionalTest.kt | 24 ---- .../micronaut/test/kotest/myprops.properties | 17 --- test-kotest/src/test/resources/logback.xml | 16 --- test-kotest5/build.gradle | 7 +- 40 files changed, 17 insertions(+), 1209 deletions(-) delete mode 100644 test-kotest/build.gradle delete mode 100644 test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestContext.kt delete mode 100644 test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestExtension.kt delete mode 100644 test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/annotation/MicronautTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/ApplicationRunAnotherTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/Book.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/ConstructorPropertyTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/DbProperties.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/DefaultTestService.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/DisableEmbeddedApplicationTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/EmptyConstructorTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaNoRollbackTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaRollbackTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathCollaboratorTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathController.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathInnerService2Test.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockService2Test.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockServiceTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathService.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceImpl.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTestSimilarNameTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/NewAnnotationTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/NonTransactionalTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/ProjectConfig.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertySourceTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueRequiresTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/RequiresTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/SimpleTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestController.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestPropertiesProviderTest.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestService.kt delete mode 100644 test-kotest/src/test/kotlin/io/micronaut/test/kotest/TransactionalTest.kt delete mode 100644 test-kotest/src/test/resources/io/micronaut/test/kotest/myprops.properties delete mode 100644 test-kotest/src/test/resources/logback.xml diff --git a/build.gradle b/build.gradle index e97ee10fa..a3304bf2e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,3 +3,8 @@ plugins { id("io.micronaut.build.internal.dependency-updates") id("io.micronaut.build.internal.quality-reporting") } + +repositories { + mavenCentral() + maven { url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } +} diff --git a/settings.gradle b/settings.gradle index 8c97d8274..62655dee1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -25,6 +25,5 @@ include 'test-bom' include 'test-core' include "test-spock" include "test-junit5" -include "test-kotest" include "test-kotest5" include "test-rest-assured" diff --git a/test-bom/build.gradle b/test-bom/build.gradle index af06f50f5..dd0e4ad8f 100644 --- a/test-bom/build.gradle +++ b/test-bom/build.gradle @@ -1,3 +1,9 @@ plugins { id "io.micronaut.build.internal.bom" } + +micronautBom { + suppressions { + acceptedLibraryRegressions.add("micronaut-test-kotest") + } +} diff --git a/test-kotest/build.gradle b/test-kotest/build.gradle deleted file mode 100644 index 464ee6d24..000000000 --- a/test-kotest/build.gradle +++ /dev/null @@ -1,52 +0,0 @@ -plugins { - id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" - id "org.jetbrains.kotlin.kapt" version "$kotlinVersion" - id "io.micronaut.build.internal.module" -} - -repositories { - mavenCentral() - maven { url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } -} - -dependencies { - api project(":test-core") - api(mn.micronaut.runtime) - api(libs.managed.kotest.runner.junit5.jvm) - - implementation(mn.micronaut.inject) - implementation project(":test-junit5") - implementation(libs.kotlin.stdlib.jdk8) - implementation(libs.kotlin.reflect) - - compileOnly(libs.jakarta.inject.api) - - testCompileOnly(libs.jakarta.inject.api) - - kaptTest(platform(mn.micronaut.bom)) - kaptTest(mn.micronaut.inject.java) - - testImplementation(libs.managed.mockk) - - testImplementation(mn.micronaut.http.server.netty) - testImplementation(mn.micronaut.http.client) - - testImplementation(mn.micronaut.data.tx) - testImplementation(mn.micronaut.data.hibernate.jpa) - - testRuntimeOnly(mn.micronaut.jdbc.tomcat) - testRuntimeOnly(libs.h2) - - testImplementation(libs.managed.kotest.assertions.core.jvm) -} - -test { - useJUnitPlatform() -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = '1.8' - javaParameters = true - } -} diff --git a/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestContext.kt b/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestContext.kt deleted file mode 100644 index b0cd46986..000000000 --- a/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestContext.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.micronaut.test.extensions.kotest - -import io.kotest.core.spec.Spec -import io.kotest.core.test.TestCase -import io.kotest.core.test.TestResult -import io.micronaut.context.annotation.Property -import io.micronaut.test.annotation.MicronautTestValue -import io.micronaut.test.context.TestContext -import io.micronaut.test.extensions.AbstractMicronautExtension -import io.micronaut.test.support.TestPropertyProvider -import kotlin.reflect.full.memberFunctions - -class MicronautKotestContext(private val testClass: Class, - private val micronautTestValue: MicronautTestValue, - private val createBean: Boolean) : AbstractMicronautExtension() { - - override fun resolveTestProperties(context: Spec?, testAnnotationValue: MicronautTestValue, testProperties: MutableMap?) { - if (context is TestPropertyProvider) { - testProperties?.putAll(context.properties) - } - } - - val bean : Spec? - - init { - bean = if (createBean) { - beforeClass(null, testClass, micronautTestValue) - applicationContext.findBean(testClass).orElse(null) as Spec? - } else { - null - } - } - - override fun alignMocks(context: Spec?, instance: Any) { - } - - fun beforeSpecClass(spec: Spec) { - if (!createBean) { - beforeClass(spec, testClass, micronautTestValue) - applicationContext.inject(spec) - } - beforeTestClass(buildContext(spec)) - } - - fun afterSpecClass(spec: Spec) { - afterTestClass(buildContext(spec)) - afterClass(spec) - } - - @Suppress("UNCHECKED_CAST") - fun beforeTest(testCase: TestCase) { - val filter = testCase.spec::class.memberFunctions.filter { it.name == testCase.description.name.name } - var propertyAnnotations: List? = emptyList() - if (filter.isNotEmpty()) { - propertyAnnotations = filter.first().annotations.filter { it is Property } as? List - } - beforeEach(testCase.spec, testCase.spec, testCase.test.javaClass, propertyAnnotations) - beforeTestMethod(buildContext(testCase, null)) - } - - fun afterTest(testCase: TestCase, result: TestResult) { - afterTestMethod(buildContext(testCase, result)) - } - - fun beforeInvocation(testCase: TestCase) { - beforeTestExecution(buildContext(testCase, null)) - } - - fun afterInvocation(testCase: TestCase) { - afterTestExecution(buildContext(testCase, null)) - } - - fun getSpecDefinition() = specDefinition - - fun buildContext(spec: Spec): TestContext { - return TestContext(applicationContext, spec.javaClass, null, spec, null) - } - - fun buildContext(testCase: TestCase, result: TestResult?): TestContext { - return TestContext(applicationContext, testCase.spec.javaClass, testCase.test.javaClass, testCase.spec, result?.error) - } - -} diff --git a/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestExtension.kt b/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestExtension.kt deleted file mode 100644 index 1c6edb221..000000000 --- a/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/MicronautKotestExtension.kt +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.micronaut.test.extensions.kotest - -import io.kotest.core.extensions.ConstructorExtension -import io.kotest.core.extensions.TestCaseExtension -import io.kotest.core.listeners.TestListener -import io.kotest.core.spec.Spec -import io.kotest.core.test.TestCase -import io.kotest.core.test.TestResult -import io.micronaut.aop.InterceptedProxy -import io.micronaut.test.annotation.AnnotationUtils -import io.micronaut.test.annotation.MicronautTestValue -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import kotlin.reflect.KClass -import kotlin.reflect.full.primaryConstructor - -object MicronautKotestExtension: TestListener, ConstructorExtension, TestCaseExtension { - - override suspend fun intercept( - testCase: TestCase, - execute: suspend (TestCase) -> TestResult - ): TestResult { - val context = contexts[testCase.spec.javaClass.name] - return if(context != null && context.getSpecDefinition() == null) { - // It's a MicronautTest test where the bean doesn't exist - TestResult.Ignored - } else { - // Not a MicronautTest test or the bean exists - execute(testCase) - } - } - - val contexts: MutableMap = mutableMapOf() - - override suspend fun beforeSpec(spec: Spec) { - contexts[spec.javaClass.name]?.beforeSpecClass(spec) - } - - override suspend fun afterSpec(spec: Spec) { - contexts[spec.javaClass.name]?.afterSpecClass(spec) - } - - override suspend fun beforeTest(testCase: TestCase) { - contexts[testCase.spec.javaClass.name]?.beforeTest(testCase) - } - - override suspend fun afterTest(testCase: TestCase, result: TestResult) { - contexts[testCase.spec.javaClass.name]?.afterTest(testCase, result) - } - - override suspend fun beforeInvocation(testCase: TestCase, iteration: Int) { - contexts[testCase.spec.javaClass.name]?.beforeInvocation(testCase) - } - - override suspend fun afterInvocation(testCase: TestCase, iteration: Int) { - contexts[testCase.spec.javaClass.name]?.afterInvocation(testCase) - } - - override suspend fun beforeContainer(testCase: TestCase) { - contexts[testCase.spec.javaClass.name]?.beforeInvocation(testCase) - } - - override suspend fun afterContainer(testCase: TestCase, result: TestResult) { - contexts[testCase.spec.javaClass.name]?.afterInvocation(testCase) - } - - @Suppress("UNCHECKED_CAST") - override fun instantiate(clazz: KClass): Spec? { - val constructor = clazz.primaryConstructor - val testClass: Class = clazz.java as Class - var micronautTestValue = testClass - .annotations - .filterIsInstance() - .map { micronautTest -> buildValueObject(micronautTest) } - .firstOrNull() - return if (micronautTestValue == null) { - null - } else { - val createBean = constructor != null && constructor.parameters.isNotEmpty() - val context = MicronautKotestContext(testClass, micronautTestValue, createBean) - contexts[testClass.name] = context - if (createBean) { - context.bean - } else { - null - } - } - } - - private fun buildValueObject(micronautTest: MicronautTest): MicronautTestValue { - return MicronautTestValue( - micronautTest.application.java, - micronautTest.environments, - micronautTest.packages, - micronautTest.propertySources, - micronautTest.rollback, - micronautTest.transactional, - micronautTest.rebuildContext, - micronautTest.contextBuilder.map { kClass -> kClass.java }.toTypedArray(), - micronautTest.transactionMode, - micronautTest.startApplication - ) - } - - @Suppress("UNCHECKED_CAST") - fun Spec.getMock(obj: T): T { - return if (obj is InterceptedProxy<*>) { - obj.interceptedTarget() as T - } else { - obj - } - } -} diff --git a/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/annotation/MicronautTest.kt b/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/annotation/MicronautTest.kt deleted file mode 100644 index e86a6357c..000000000 --- a/test-kotest/src/main/kotlin/io/micronaut/test/extensions/kotest/annotation/MicronautTest.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.micronaut.test.extensions.kotest.annotation - -import io.micronaut.context.ApplicationContextBuilder -import io.micronaut.context.annotation.Factory -import io.micronaut.context.annotation.Requires -import io.micronaut.test.annotation.TransactionMode -import io.micronaut.test.condition.TestActiveCondition -import io.micronaut.test.extensions.junit5.MicronautJunit5Extension -import org.junit.jupiter.api.extension.ExtendWith -import java.lang.annotation.Inherited -import kotlin.reflect.KClass - -/** - * Annotation that can be applied to any Kotest test to make it a Micronaut test. - * - * @author graemerocher - * @author Álvaro Sánchez-Mariscal - * @since 2.1.0 - */ -@Retention(AnnotationRetention.RUNTIME) -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS) -@ExtendWith(MicronautJunit5Extension::class) -@Factory -@Inherited -@Requires(condition = TestActiveCondition::class) -annotation class MicronautTest( - /** - * @return The application class of the application - */ - val application: KClass<*> = Unit::class, - /** - * @return The environments to use. - */ - val environments: Array = [], - /** - * @return The packages to consider for scanning. - */ - val packages: Array = [], - /** - * One or many references to classpath. For example: "classpath:mytest.yml" - * - * @return The property sources - */ - val propertySources: Array = [], - /** - * Whether to rollback (if possible) any data access code between each test execution. - * - * @return True if changes should be rolled back - */ - val rollback: Boolean = true, - /** - * Allow disabling or enabling of automatic transaction wrapping. - * @return Whether to wrap a test in a transaction. - */ - val transactional: Boolean = true, - /** - * Whether to rebuild the application context before each test method. - * @return true if the application context should be rebuilt for each test method - */ - val rebuildContext: Boolean = false, - /** - * The application context builder to use to construct the context. - * @return The builder - */ - val contextBuilder: Array> = [], - /** - * The transaction mode describing how transactions should be handled for each test. - * @return The transaction mode - */ - val transactionMode: TransactionMode = TransactionMode.SEPARATE_TRANSACTIONS, - /** - * - * Whether to start [io.micronaut.runtime.EmbeddedApplication]. - * - * - * When false, only the application context will be started. - * This can be used to disable [io.micronaut.runtime.server.EmbeddedServer]. - * - * @return true if [io.micronaut.runtime.EmbeddedApplication] should be started - */ - val startApplication: Boolean = true) diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ApplicationRunAnotherTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ApplicationRunAnotherTest.kt deleted file mode 100644 index 3e2355683..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ApplicationRunAnotherTest.kt +++ /dev/null @@ -1,63 +0,0 @@ - -package io.micronaut.test.kotest; - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.http.HttpRequest -import io.micronaut.http.client.HttpClient -import io.micronaut.http.client.annotation.Client -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.test.annotation.MockBean -import io.micronaut.test.extensions.kotest.MicronautKotestExtension.getMock -import io.mockk.every -import io.mockk.mockk -import io.mockk.verify - -@MicronautTest -class ApplicationRunAnotherTest( - @Client("/") private val client: HttpClient, - private val testService: TestService): BehaviorSpec({ - - val specName = javaClass.simpleName - - given("testPingServer") { - `when`("the mock is setup") { - val mock = getMock(testService) - - every { mock.doStuff() } returns "mocked by $specName" - - val response = client.toBlocking().retrieve( - HttpRequest.GET("/test"), String::class.java) - - then("the response comes from the mock") { - response shouldBe "mocked by ApplicationRunAnotherTest" - verify { - mock.doStuff() - } - } - } - - `when`("the mock is changed") { - val mock = getMock(testService) - - every { mock.doStuff() } returns "changed by $specName" - - val response = client.toBlocking().retrieve( - HttpRequest.GET("/test"), String::class.java) - - then("the mock was changed") { - response shouldBe "changed by ApplicationRunAnotherTest" - verify { - mock.doStuff() - } - } - } - } - -}) { - - @MockBean(DefaultTestService::class) - fun testService(): TestService { - return mockk() - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/Book.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/Book.kt deleted file mode 100644 index 94424f93e..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/Book.kt +++ /dev/null @@ -1,16 +0,0 @@ - -package io.micronaut.test.kotest - -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id - -@Entity -class Book { - - @GeneratedValue - @Id - var id: Long? = null - - var title: String? = null -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ConstructorPropertyTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ConstructorPropertyTest.kt deleted file mode 100644 index 969f623f8..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ConstructorPropertyTest.kt +++ /dev/null @@ -1,22 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe -import io.micronaut.context.annotation.Property -import io.micronaut.context.annotation.Value -import io.micronaut.test.extensions.kotest.annotation.MicronautTest - -@MicronautTest -@Property(name = "foo.bar", value = "3") -class ConstructorPropertyTest( - @Value("\${foo.bar}") private val value: Int, - @Property(name = "foo.bar") private val property: Int -): StringSpec({ - - "test the values are injected"() { - value shouldBe 3 - property shouldBe 3 - } - -}) diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DbProperties.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DbProperties.kt deleted file mode 100644 index 058dd9ae4..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DbProperties.kt +++ /dev/null @@ -1,14 +0,0 @@ - -package io.micronaut.test.kotest - -import io.micronaut.context.annotation.Property -import io.micronaut.context.annotation.PropertySource - -@Retention(AnnotationRetention.RUNTIME) -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FILE) -@MustBeDocumented -@PropertySource( - Property(name = "datasources.default.name", value = "testdb"), - Property(name = "jpa.default.properties.hibernate.hbm2ddl.auto", value = "update") -) -annotation class DbProperties diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DefaultTestService.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DefaultTestService.kt deleted file mode 100644 index 89c07b205..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DefaultTestService.kt +++ /dev/null @@ -1,12 +0,0 @@ - -package io.micronaut.test.kotest - -import jakarta.inject.Singleton - -@Singleton -class DefaultTestService : TestService { - - override fun doStuff(): String { - return "original" - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DisableEmbeddedApplicationTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DisableEmbeddedApplicationTest.kt deleted file mode 100644 index 6268aa343..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/DisableEmbeddedApplicationTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe -import io.micronaut.runtime.EmbeddedApplication -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import jakarta.inject.Inject - -@MicronautTest(startApplication = false, rebuildContext = true) -internal class DisableEmbeddedApplicationTest: StringSpec() { - - @Inject lateinit var embeddedApplication: EmbeddedApplication<*> - - init { - "test embedded server is not started"() { - embeddedApplication.isRunning shouldBe false - } - - "test embedded server is not started after context rebuild"() { - embeddedApplication.isRunning shouldBe false - } - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/EmptyConstructorTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/EmptyConstructorTest.kt deleted file mode 100644 index 1607e2810..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/EmptyConstructorTest.kt +++ /dev/null @@ -1,19 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import jakarta.inject.Inject - -@MicronautTest -class EmptyConstructorTest: StringSpec() { - - @Inject lateinit var mathService: MathService - - init { - "test should be called" { - mathService.compute(1) shouldBe 4 - } - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaNoRollbackTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaNoRollbackTest.kt deleted file mode 100644 index a4524e85c..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaNoRollbackTest.kt +++ /dev/null @@ -1,62 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.Spec -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.kotest.matchers.shouldNotBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.transaction.SynchronousTransactionManager -import io.micronaut.transaction.support.DefaultTransactionDefinition -import javax.persistence.EntityManager - -@MicronautTest(rollback = false) -@DbProperties -class JpaNoRollbackTest( - private val entityManager: EntityManager, - private val transactionManager: SynchronousTransactionManager -) : BehaviorSpec() { - - init { - given("no rollback between tests") { - `when`("test persist one") { - val book = Book() - book.title = "The Stand" - entityManager.persist(book) - - then("the book is persisted") { - entityManager.find(Book::class.java, book.id) shouldNotBe null - - val query = entityManager.criteriaBuilder.createQuery(Book::class.java) - query.from(Book::class.java) - entityManager.createQuery(query).resultList.size shouldBe 1 - } - } - } - - given("a new transaction") { - `when`("test persist two") { - val book = Book() - book.title = "The Shining" - entityManager.persist(book) - - then("the book is persisted") { - entityManager.find(Book::class.java, book.id) shouldNotBe null - - val query = entityManager.criteriaBuilder.createQuery(Book::class.java) - query.from(Book::class.java) - entityManager.createQuery(query).resultList.size shouldBe 2 - } - } - } - } - - override fun afterSpec(spec: Spec) { - val tx = transactionManager.getTransaction(DefaultTransactionDefinition()) - val criteriaBuilder = entityManager.criteriaBuilder - val delete = criteriaBuilder.createCriteriaDelete(Book::class.java) - delete.from(Book::class.java) - entityManager.createQuery(delete).executeUpdate() - transactionManager.commit(tx) - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaRollbackTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaRollbackTest.kt deleted file mode 100644 index 549028a1b..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/JpaRollbackTest.kt +++ /dev/null @@ -1,46 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.kotest.matchers.shouldNotBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest - -import javax.persistence.EntityManager - -@MicronautTest -@DbProperties -class JpaRollbackTest(private val entityManager: EntityManager): BehaviorSpec({ - - given("rollback between tests") { - `when`("test persist one") { - val book = Book() - book.title = "The Stand" - entityManager.persist(book) - - then("the book is persisted") { - entityManager.find(Book::class.java, book.id) shouldNotBe null - - val query = entityManager.criteriaBuilder.createQuery(Book::class.java) - query.from(Book::class.java) - entityManager.createQuery(query).resultList.size shouldBe 1 - } - } - } - - given("a new transaction") { - `when`("test persist two") { - val book = Book() - book.title = "The Shining" - entityManager.persist(book) - - then("the book is persisted") { - entityManager.find(Book::class.java, book.id) shouldNotBe null - - val query = entityManager.criteriaBuilder.createQuery(Book::class.java) - query.from(Book::class.java) - entityManager.createQuery(query).resultList.size shouldBe 1 - } - } - } -}) diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathCollaboratorTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathCollaboratorTest.kt deleted file mode 100644 index 388eb4ec8..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathCollaboratorTest.kt +++ /dev/null @@ -1,49 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.StringSpec -import io.kotest.data.blocking.forAll -import io.kotest.data.row -import io.kotest.matchers.shouldBe -import io.micronaut.http.client.HttpClient -import io.micronaut.http.client.annotation.Client -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.test.annotation.MockBean -import io.micronaut.test.extensions.kotest.MicronautKotestExtension.getMock -import io.mockk.every -import io.mockk.mockk -import io.mockk.verify -import kotlin.math.pow -import kotlin.math.roundToInt - -@MicronautTest -class MathCollaboratorTest( - private val mathService: MathService, - @Client("/") private val client: HttpClient // <2> -) : StringSpec({ - - "test compute num to square" { - val mock = getMock(mathService) - - every { mock.compute(any()) } answers { - firstArg().toDouble().pow(2).roundToInt() - } - - forAll( - row(2, 4), - row(3, 9) - ) { a: Int, b: Int -> - val result = client.toBlocking().retrieve("/math/compute/$a", Int::class.java) // <3> - result shouldBe b - verify { mock.compute(a) } // <4> - } - - } - -}) { - - @MockBean(MathServiceImpl::class) // <1> - fun mathService(): MathService { - return mockk() - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathController.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathController.kt deleted file mode 100644 index 51dfef637..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathController.kt +++ /dev/null @@ -1,15 +0,0 @@ - -package io.micronaut.test.kotest - -import io.micronaut.http.MediaType -import io.micronaut.http.annotation.Controller -import io.micronaut.http.annotation.Get - -@Controller("/math") -class MathController internal constructor(internal var mathService: MathService) { - - @Get(uri = "/compute/{number}", processes = [MediaType.TEXT_PLAIN]) - internal fun compute(number: Int): String { - return mathService.compute(number).toString() - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathInnerService2Test.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathInnerService2Test.kt deleted file mode 100644 index 6b8f7c917..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathInnerService2Test.kt +++ /dev/null @@ -1,38 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.test.annotation.MockBean - -@MicronautTest -class MathInnerService2Test( - private val mathService: MathService, - private val services: Array -) : BehaviorSpec({ - - given("an inner class mock") { - - `when`("the mock is called") { - val result = mathService.compute(10) - - then("the mock is used") { - result shouldBe 50 - mathService is MyService - services.size shouldBe 1 - } - - } - } - -}) { - - @MockBean(MathServiceImpl::class) - open class MyService : MathService { - - override fun compute(num: Int): Int { - return num * 5 - } - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockService2Test.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockService2Test.kt deleted file mode 100644 index 2b316753f..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockService2Test.kt +++ /dev/null @@ -1,29 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.test.annotation.MockBean -import io.mockk.mockk - -@MicronautTest -class MathMockService2Test( - private val mathServices: Array -) : BehaviorSpec({ - - given("an array of services") { - `when`("the services are injected") { - then("the array contains a single service") { - mathServices.size shouldBe 1 - } - } - } - -}) { - - @MockBean(MathServiceImpl::class) - fun mathService(): MathService { - return mockk() - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockServiceTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockServiceTest.kt deleted file mode 100644 index a326299ba..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathMockServiceTest.kt +++ /dev/null @@ -1,42 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.test.annotation.MockBean -import io.micronaut.test.extensions.kotest.MicronautKotestExtension.getMock -import io.mockk.every -import io.mockk.mockk -import io.mockk.verify - -import kotlin.math.pow -import kotlin.math.roundToInt - -@MicronautTest -class MathMockServiceTest( - private val mathService: MathService // <3> -) : BehaviorSpec({ - - given("test compute num to square") { - - `when`("the mock is provided") { - val mock = getMock(mathService) // <4> - every { mock.compute(any()) } answers { - firstArg().toDouble().pow(2).roundToInt() - } - - then("the mock implementation is used") { - mock.compute(3) shouldBe 9 - verify { mock.compute(3) } // <5> - } - } - } - -}) { - - @MockBean(MathServiceImpl::class) // <1> - fun mathService(): MathService { - return mockk() // <2> - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathService.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathService.kt deleted file mode 100644 index ef3a8a8aa..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathService.kt +++ /dev/null @@ -1,8 +0,0 @@ - -package io.micronaut.test.kotest - -interface MathService { - - fun compute(num: Int): Int -} - diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceImpl.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceImpl.kt deleted file mode 100644 index 40e0982b5..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ - -package io.micronaut.test.kotest - -import jakarta.inject.Singleton - -@Singleton -internal class MathServiceImpl : MathService { - - override fun compute(num: Int): Int { - return num * 4 - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTest.kt deleted file mode 100644 index 869fa2d76..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTest.kt +++ /dev/null @@ -1,29 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest - -@MicronautTest // <1> -class MathServiceTest( - private val mathService: MathService // <2> -) : BehaviorSpec({ - - given("the math service") { - - `when`("the service is called with 2") { - val result = mathService.compute(2) // <3> - then("the result is 8") { - result shouldBe 8 - } - } - - `when`("the service is called with 3") { - val result = mathService.compute(3) - then("the result is 12") { - result shouldBe 12 - } - } - } -}) diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTestSimilarNameTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTestSimilarNameTest.kt deleted file mode 100644 index e0b2152c4..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/MathServiceTestSimilarNameTest.kt +++ /dev/null @@ -1,35 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.test.annotation.MockBean -import io.micronaut.test.extensions.kotest.MicronautKotestExtension.getMock -import io.mockk.every -import io.mockk.mockk -import io.mockk.verify - -@MicronautTest -class MathServiceTestSimilarNameTest(private val mathService: MathService) : BehaviorSpec({ - - given("test similarly named test suites dont leak mocks") { - - `when`("the mock is provided") { - val mock = getMock(mathService) - every { mock.compute(10) } returns 20 - - then("the mock is used") { - mock.compute(10) shouldBe 20 - verify { mock.compute(10) } - } - } - } - -}) { - - @MockBean(MathServiceImpl::class) - fun mathService(): MathService { - return mockk() - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/NewAnnotationTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/NewAnnotationTest.kt deleted file mode 100644 index c405f1446..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/NewAnnotationTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.test.extensions.kotest.annotation.MicronautTest - -@MicronautTest -class NewAnnotationTest( - private val mathService: MathService -) : BehaviorSpec({ - - given("the math service") { - - `when`("the service is called with 2") { - val result = mathService.compute(2) - then("the result is 8") { - result shouldBe 8 - } - } - - `when`("the service is called with 3") { - val result = mathService.compute(3) - then("the result is 12") { - result shouldBe 12 - } - } - } -}) \ No newline at end of file diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/NonTransactionalTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/NonTransactionalTest.kt deleted file mode 100644 index 0704bb44c..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/NonTransactionalTest.kt +++ /dev/null @@ -1,24 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.context.ApplicationContext -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.transaction.test.DefaultTestTransactionExecutionListener - -@MicronautTest(transactional = false) -@DbProperties -class NonTransactionalTest( - private val applicationContext: ApplicationContext) : BehaviorSpec({ - - given("a test") { - `when`("the test is not transactional") { - then("the SpringTransactionTestExecutionListener does not exist") { - applicationContext.containsBean(DefaultTestTransactionExecutionListener::class.java) shouldBe false - } - } - } - -}) - diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ProjectConfig.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ProjectConfig.kt deleted file mode 100644 index 07b3f30d6..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/ProjectConfig.kt +++ /dev/null @@ -1,10 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.config.AbstractProjectConfig -import io.micronaut.test.extensions.kotest.MicronautKotestExtension - -object ProjectConfig : AbstractProjectConfig() { - override fun listeners() = listOf(MicronautKotestExtension) - override fun extensions() = listOf(MicronautKotestExtension) -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertySourceTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertySourceTest.kt deleted file mode 100644 index bc3ec16de..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertySourceTest.kt +++ /dev/null @@ -1,24 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.context.annotation.Property -import io.micronaut.test.extensions.kotest.annotation.MicronautTest - -@MicronautTest(propertySources = ["myprops.properties"]) -@Property(name = "supplied.value", value = "hello") -class PropertySourceTest(@Property(name = "foo.bar") val value: String, - @Property(name = "supplied.value") val suppliedValue: String) : BehaviorSpec({ - - given("a property source") { - `when`("the value is injected") { - then("the correct value is injected") { - value shouldBe "foo" - suppliedValue shouldBe "hello" - } - } - } - -}) - diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueRequiresTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueRequiresTest.kt deleted file mode 100644 index b51444545..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueRequiresTest.kt +++ /dev/null @@ -1,45 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.AnnotationSpec -import io.kotest.matchers.types.shouldBeInstanceOf -import io.micronaut.context.annotation.Property -import io.micronaut.context.annotation.Requires -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import jakarta.inject.Inject -import jakarta.inject.Singleton - -@MicronautTest(rebuildContext = true) -@Property(name = "foo.bar", value = "stuff") -class PropertyValueRequiresTest: AnnotationSpec() { - - @Inject - lateinit var myService: MyService - - @Test - fun testInitialValue() { - myService.shouldBeInstanceOf() - } - - @Property(name = "foo.bar", value = "changed") - @Test - fun testValueChanged() { - myService.shouldBeInstanceOf() - } - - @Test - fun testValueRestored() { - myService.shouldBeInstanceOf() - } -} - -interface MyService - -@Singleton -@Requires(property = "foo.bar", value = "stuff") -open class MyServiceStuff : MyService - - -@Singleton -@Requires(property = "foo.bar", value = "changed") -open class MyServiceChanged : MyService diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueTest.kt deleted file mode 100644 index 8e5f4ff06..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/PropertyValueTest.kt +++ /dev/null @@ -1,32 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.AnnotationSpec -import io.kotest.matchers.shouldBe -import io.micronaut.context.annotation.Property -import io.micronaut.context.annotation.Value -import io.micronaut.test.extensions.kotest.annotation.MicronautTest - -@MicronautTest -@Property(name = "foo.bar", value = "stuff") -class PropertyValueTest: AnnotationSpec() { - - @Value("\${foo.bar}") - lateinit var value: String - - @Test - fun testInitialValue() { - value shouldBe "stuff" - } - - @Property(name = "foo.bar", value = "changed") - @Test - fun testValueChanged() { - value shouldBe "changed" - } - - @Test - fun testValueRestored() { - value shouldBe "stuff" - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/RequiresTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/RequiresTest.kt deleted file mode 100644 index 71023386f..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/RequiresTest.kt +++ /dev/null @@ -1,17 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.assertions.fail -import io.kotest.core.spec.style.BehaviorSpec -import io.micronaut.context.annotation.Requires -import io.micronaut.test.extensions.kotest.annotation.MicronautTest - -@MicronautTest -@Requires(property = "does.not.exist") -class RequiresTest: BehaviorSpec({ - - given("a test with requires") { - fail("Should never be executed") - } - -}) diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/SimpleTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/SimpleTest.kt deleted file mode 100644 index 2603a7af5..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/SimpleTest.kt +++ /dev/null @@ -1,15 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe - - -class SimpleTest: StringSpec() { - - init { - "test should be called"() { - 1 shouldBe 1 - } - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestController.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestController.kt deleted file mode 100644 index 01c57e8cc..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestController.kt +++ /dev/null @@ -1,14 +0,0 @@ - -package io.micronaut.test.kotest - -import io.micronaut.http.annotation.Controller -import io.micronaut.http.annotation.Get - -@Controller("/test") -class TestController constructor(private val testService: TestService) { - - @Get - fun index(): String { - return testService.doStuff() - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestPropertiesProviderTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestPropertiesProviderTest.kt deleted file mode 100644 index b6842c56e..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestPropertiesProviderTest.kt +++ /dev/null @@ -1,27 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.StringSpec -import io.kotest.matchers.shouldBe -import io.micronaut.context.annotation.Property -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.test.support.TestPropertyProvider -import jakarta.inject.Inject - -@MicronautTest -class TestPropertiesProviderTest: StringSpec(), TestPropertyProvider { - - override fun getProperties(): MutableMap { - return mutableMapOf("foo.bar" to "3") - } - - @set:Inject - @setparam:Property(name = "foo.bar") - var property: Int = 0 - - init { - "test the property was injected"() { - property shouldBe 3 - } - } -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestService.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestService.kt deleted file mode 100644 index b306362b6..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TestService.kt +++ /dev/null @@ -1,7 +0,0 @@ - -package io.micronaut.test.kotest - -interface TestService { - - fun doStuff(): String -} diff --git a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TransactionalTest.kt b/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TransactionalTest.kt deleted file mode 100644 index 3a13e7ccd..000000000 --- a/test-kotest/src/test/kotlin/io/micronaut/test/kotest/TransactionalTest.kt +++ /dev/null @@ -1,24 +0,0 @@ - -package io.micronaut.test.kotest - -import io.kotest.core.spec.style.BehaviorSpec -import io.kotest.matchers.shouldBe -import io.micronaut.context.ApplicationContext -import io.micronaut.test.extensions.kotest.annotation.MicronautTest -import io.micronaut.transaction.test.DefaultTestTransactionExecutionListener - -@MicronautTest(transactional = true) -@DbProperties -class TransactionalTest( - private val applicationContext: ApplicationContext) : BehaviorSpec({ - - given("a test") { - `when`("the test is transactional") { - then("the SpringTransactionTestExecutionListener does exist") { - applicationContext.containsBean(DefaultTestTransactionExecutionListener::class.java) shouldBe true - } - } - } - -}) - diff --git a/test-kotest/src/test/resources/io/micronaut/test/kotest/myprops.properties b/test-kotest/src/test/resources/io/micronaut/test/kotest/myprops.properties deleted file mode 100644 index 411ec64ee..000000000 --- a/test-kotest/src/test/resources/io/micronaut/test/kotest/myprops.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2017-2020 original authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -foo.bar=foo \ No newline at end of file diff --git a/test-kotest/src/test/resources/logback.xml b/test-kotest/src/test/resources/logback.xml deleted file mode 100644 index a0d26b4c4..000000000 --- a/test-kotest/src/test/resources/logback.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - \ No newline at end of file diff --git a/test-kotest5/build.gradle b/test-kotest5/build.gradle index 048861ade..3cd949e3f 100644 --- a/test-kotest5/build.gradle +++ b/test-kotest5/build.gradle @@ -36,7 +36,7 @@ dependencies { testRuntimeOnly(mn.micronaut.jdbc.tomcat) testRuntimeOnly(libs.h2) - + testImplementation(mn.snakeyaml) testImplementation(libs.managed.kotest.assertions.core.jvm) } @@ -44,6 +44,11 @@ test { useJUnitPlatform() } +// PTS just skips Kotest tests silently... +tasks.withType(Test).configureEach { + predictiveSelection.enabled = false +} + compileTestKotlin { kotlinOptions { jvmTarget = '1.8'