From e9a31ce1123d633a993040f6231f94d538cf7dde Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Fri, 13 Oct 2023 08:02:38 +0200 Subject: [PATCH] test: Add "test" Module --- app/build.gradle.kts | 1 + .../testapp/extension/LogExtensionTest.kt | 3 ++ .../kuksa/testapp/model/ConnectionInfoTest.kt | 3 ++ kuksa-sdk/build.gradle.kts | 2 + .../eclipse/kuksa/DataBrokerConnectionTest.kt | 4 +- .../kuksa/DataBrokerConnectorSecureTest.kt | 6 +-- .../eclipse/kuksa/DataBrokerConnectorTest.kt | 6 +-- .../pattern/listener/MultiListenerTest.kt | 2 +- .../test/databroker/DataBrokerConfig.kt | 2 +- .../databroker/DataBrokerConnectorProvider.kt | 2 +- settings.gradle.kts | 1 + test/.gitignore | 1 + test/build.gradle.kts | 46 +++++++++++++++++++ .../kuksa}/test/kotest/KotestProjectConfig.kt | 2 +- .../org/eclipse/kuksa}/test/kotest/Tag.kt | 2 +- 15 files changed, 70 insertions(+), 13 deletions(-) rename kuksa-sdk/src/test/kotlin/{ => org/eclipse/kuksa}/test/databroker/DataBrokerConfig.kt (95%) rename kuksa-sdk/src/test/kotlin/{ => org/eclipse/kuksa}/test/databroker/DataBrokerConnectorProvider.kt (98%) create mode 100644 test/.gitignore create mode 100644 test/build.gradle.kts rename {kuksa-sdk/src/test/kotlin => test/src/main/java/org/eclipse/kuksa}/test/kotest/KotestProjectConfig.kt (95%) rename {kuksa-sdk/src/test/kotlin => test/src/main/java/org/eclipse/kuksa}/test/kotest/Tag.kt (95%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 388de848..2ce006ea 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -87,6 +87,7 @@ plugins { dependencies { implementation(project(":kuksa-sdk")) + testImplementation(project(":test")) implementation(libs.androidx.appcompat) implementation(libs.androidx.lifecycle.runtime.ktx) diff --git a/app/src/test/kotlin/org/eclipse/kuksa/testapp/extension/LogExtensionTest.kt b/app/src/test/kotlin/org/eclipse/kuksa/testapp/extension/LogExtensionTest.kt index 8a2f6221..98f48567 100644 --- a/app/src/test/kotlin/org/eclipse/kuksa/testapp/extension/LogExtensionTest.kt +++ b/app/src/test/kotlin/org/eclipse/kuksa/testapp/extension/LogExtensionTest.kt @@ -20,9 +20,12 @@ package org.eclipse.kuksa.testapp.extension import io.kotest.core.spec.style.BehaviorSpec +import org.eclipse.kuksa.test.kotest.Unit import org.junit.jupiter.api.Assertions class LogExtensionTest : BehaviorSpec({ + tags(Unit) + val expectedLogTag = AnyClass::class.simpleName given("Any class") { diff --git a/app/src/test/kotlin/org/eclipse/kuksa/testapp/model/ConnectionInfoTest.kt b/app/src/test/kotlin/org/eclipse/kuksa/testapp/model/ConnectionInfoTest.kt index 74317cda..c1487746 100644 --- a/app/src/test/kotlin/org/eclipse/kuksa/testapp/model/ConnectionInfoTest.kt +++ b/app/src/test/kotlin/org/eclipse/kuksa/testapp/model/ConnectionInfoTest.kt @@ -23,10 +23,13 @@ import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import org.eclipse.kuksa.test.kotest.Unit import java.io.File import java.io.FileWriter class ConnectionInfoTest : BehaviorSpec({ + tags(Unit) + given("A custom ConnectionInfo with a custom Certificate") { // Uri is an android specific class, which does not exist in plain JUnit. Methods like Uri.parse will simply // return null due to the addition of testOptions.unitTests.isReturnDefaultValues true diff --git a/kuksa-sdk/build.gradle.kts b/kuksa-sdk/build.gradle.kts index 8579b27f..ad49c0bb 100644 --- a/kuksa-sdk/build.gradle.kts +++ b/kuksa-sdk/build.gradle.kts @@ -41,6 +41,8 @@ android { } dependencies { + testImplementation(project(":test")) + // needs to be api as long as we expose ProtoBuf specific objects api(libs.grpc.protobuf) diff --git a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectionTest.kt b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectionTest.kt index 7a13cff8..88da9627 100644 --- a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectionTest.kt +++ b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectionTest.kt @@ -29,11 +29,11 @@ import kotlinx.coroutines.runBlocking import org.eclipse.kuksa.model.Property import org.eclipse.kuksa.proto.v1.Types import org.eclipse.kuksa.proto.v1.Types.Datapoint +import org.eclipse.kuksa.test.databroker.DataBrokerConnectorProvider +import org.eclipse.kuksa.test.kotest.Integration import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue -import test.databroker.DataBrokerConnectorProvider -import test.kotest.Integration import kotlin.random.Random class DataBrokerConnectionTest : BehaviorSpec({ diff --git a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorSecureTest.kt b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorSecureTest.kt index 6caf790a..3ca0e14e 100644 --- a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorSecureTest.kt +++ b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorSecureTest.kt @@ -20,10 +20,10 @@ package org.eclipse.kuksa import io.kotest.core.spec.style.BehaviorSpec +import org.eclipse.kuksa.test.databroker.DataBrokerConnectorProvider +import org.eclipse.kuksa.test.kotest.Integration +import org.eclipse.kuksa.test.kotest.Secure import org.junit.jupiter.api.Assertions -import test.databroker.DataBrokerConnectorProvider -import test.kotest.Integration -import test.kotest.Secure class DataBrokerConnectorSecureTest : BehaviorSpec({ tags(Integration, Secure) diff --git a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorTest.kt b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorTest.kt index 46b9165b..c27a7643 100644 --- a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorTest.kt +++ b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/DataBrokerConnectorTest.kt @@ -20,10 +20,10 @@ package org.eclipse.kuksa import io.kotest.core.spec.style.BehaviorSpec +import org.eclipse.kuksa.test.databroker.DataBrokerConnectorProvider +import org.eclipse.kuksa.test.kotest.Insecure +import org.eclipse.kuksa.test.kotest.Integration import org.junit.jupiter.api.Assertions -import test.databroker.DataBrokerConnectorProvider -import test.kotest.Insecure -import test.kotest.Integration class DataBrokerConnectorTest : BehaviorSpec({ tags(Integration, Insecure) diff --git a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/pattern/listener/MultiListenerTest.kt b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/pattern/listener/MultiListenerTest.kt index 8d868068..3a04716f 100644 --- a/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/pattern/listener/MultiListenerTest.kt +++ b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/pattern/listener/MultiListenerTest.kt @@ -21,7 +21,7 @@ package org.eclipse.kuksa.pattern.listener import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe -import test.kotest.Unit +import org.eclipse.kuksa.test.kotest.Unit class MultiListenerTest : BehaviorSpec({ tags(Unit) diff --git a/kuksa-sdk/src/test/kotlin/test/databroker/DataBrokerConfig.kt b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/test/databroker/DataBrokerConfig.kt similarity index 95% rename from kuksa-sdk/src/test/kotlin/test/databroker/DataBrokerConfig.kt rename to kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/test/databroker/DataBrokerConfig.kt index ed81240a..c8e6790e 100644 --- a/kuksa-sdk/src/test/kotlin/test/databroker/DataBrokerConfig.kt +++ b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/test/databroker/DataBrokerConfig.kt @@ -17,7 +17,7 @@ * */ -package test.databroker +package org.eclipse.kuksa.test.databroker import java.util.concurrent.TimeUnit diff --git a/kuksa-sdk/src/test/kotlin/test/databroker/DataBrokerConnectorProvider.kt b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/test/databroker/DataBrokerConnectorProvider.kt similarity index 98% rename from kuksa-sdk/src/test/kotlin/test/databroker/DataBrokerConnectorProvider.kt rename to kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/test/databroker/DataBrokerConnectorProvider.kt index b23ae894..ef7362a1 100644 --- a/kuksa-sdk/src/test/kotlin/test/databroker/DataBrokerConnectorProvider.kt +++ b/kuksa-sdk/src/test/kotlin/org/eclipse/kuksa/test/databroker/DataBrokerConnectorProvider.kt @@ -17,7 +17,7 @@ * */ -package test.databroker +package org.eclipse.kuksa.test.databroker import io.grpc.ChannelCredentials import io.grpc.Grpc diff --git a/settings.gradle.kts b/settings.gradle.kts index 97455c8f..f8c48b56 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,3 +18,4 @@ dependencyResolutionManagement { include(":app") include(":kuksa-sdk") include(":samples") +include(":test") diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/test/build.gradle.kts b/test/build.gradle.kts new file mode 100644 index 00000000..02924137 --- /dev/null +++ b/test/build.gradle.kts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * 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 + * + * http://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. + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +@Suppress("DSL_SCOPE_VIOLATION") // Remove once KTIJ-19369 is fixed +plugins { + id("com.android.library") + kotlin("android") +} + +android { + namespace = "org.eclipse.kuksa.test" + compileSdk = 33 + + defaultConfig { + minSdk = 24 + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + implementation(libs.kotest) +} diff --git a/kuksa-sdk/src/test/kotlin/test/kotest/KotestProjectConfig.kt b/test/src/main/java/org/eclipse/kuksa/test/kotest/KotestProjectConfig.kt similarity index 95% rename from kuksa-sdk/src/test/kotlin/test/kotest/KotestProjectConfig.kt rename to test/src/main/java/org/eclipse/kuksa/test/kotest/KotestProjectConfig.kt index ecb944f3..3e27f46b 100644 --- a/kuksa-sdk/src/test/kotlin/test/kotest/KotestProjectConfig.kt +++ b/test/src/main/java/org/eclipse/kuksa/test/kotest/KotestProjectConfig.kt @@ -17,7 +17,7 @@ * */ -package test.kotest +package org.eclipse.kuksa.test.kotest import io.kotest.core.config.AbstractProjectConfig diff --git a/kuksa-sdk/src/test/kotlin/test/kotest/Tag.kt b/test/src/main/java/org/eclipse/kuksa/test/kotest/Tag.kt similarity index 95% rename from kuksa-sdk/src/test/kotlin/test/kotest/Tag.kt rename to test/src/main/java/org/eclipse/kuksa/test/kotest/Tag.kt index a8ad2a81..ca7cc805 100644 --- a/kuksa-sdk/src/test/kotlin/test/kotest/Tag.kt +++ b/test/src/main/java/org/eclipse/kuksa/test/kotest/Tag.kt @@ -17,7 +17,7 @@ * */ -package test.kotest +package org.eclipse.kuksa.test.kotest import io.kotest.core.NamedTag