From b83586cd27112bdc02d568b9266e3f959da368b9 Mon Sep 17 00:00:00 2001 From: qiaoyuang Date: Tue, 19 Sep 2023 16:48:37 +0800 Subject: [PATCH] Add the logic about history cleaning before runing the unit tests --- .../kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt | 7 +++++++ .../kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt | 1 - .../src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt | 6 ++++++ .../nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt b/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt index 4e2347d..d83bfed 100644 --- a/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt +++ b/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt @@ -22,6 +22,7 @@ import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner import androidx.test.platform.app.InstrumentationRegistry import com.ctrip.sqllin.driver.toDatabasePath import org.junit.After +import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -67,6 +68,12 @@ class AndroidTest { @Test fun testJoinClause() = commonTest.testJoinClause() + @Before + fun setUp() { + val context = InstrumentationRegistry.getInstrumentation().targetContext + context.deleteDatabase(CommonBasicTest.DATABASE_NAME) + } + @After fun setDown() { val context = InstrumentationRegistry.getInstrumentation().targetContext diff --git a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt index 68d79c8..a56257a 100644 --- a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt +++ b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt @@ -345,7 +345,6 @@ class CommonBasicTest(private val path: DatabasePath) { name = DATABASE_NAME, path = path, version = 1, - inMemory = true, create = { it.execSQL(SQL_CREATE_BOOK) it.execSQL(SQL_CREATE_CATEGORY) diff --git a/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt b/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt index 002157d..bf3f9da 100644 --- a/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt +++ b/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt @@ -19,6 +19,7 @@ package com.ctrip.sqllin.dsl import com.ctrip.sqllin.driver.deleteDatabase import com.ctrip.sqllin.driver.toDatabasePath import kotlin.test.AfterTest +import kotlin.test.BeforeTest import kotlin.test.Test /** @@ -61,6 +62,11 @@ class JvmTest { @Test fun testJoinClause() = commonTest.testJoinClause() + @BeforeTest + fun setUp() { + deleteDatabase(path, CommonBasicTest.DATABASE_NAME) + } + @AfterTest fun setDown() { deleteDatabase(path, CommonBasicTest.DATABASE_NAME) diff --git a/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt b/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt index 45d54aa..6045d1f 100644 --- a/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt +++ b/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt @@ -19,6 +19,7 @@ package com.ctrip.sqllin.dsl import com.ctrip.sqllin.driver.deleteDatabase import com.ctrip.sqllin.driver.toDatabasePath import kotlin.test.AfterTest +import kotlin.test.BeforeTest import kotlin.test.Test /** @@ -61,6 +62,11 @@ class NativeTest { @Test fun testJoinClause() = commonTest.testJoinClause() + @BeforeTest + fun setUp() { + deleteDatabase(path, CommonBasicTest.DATABASE_NAME) + } + @AfterTest fun setDown() { deleteDatabase(path, CommonBasicTest.DATABASE_NAME)