Skip to content

Commit b83586c

Browse files
committed
Add the logic about history cleaning before runing the unit tests
1 parent e86aca9 commit b83586c

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
2222
import androidx.test.platform.app.InstrumentationRegistry
2323
import com.ctrip.sqllin.driver.toDatabasePath
2424
import org.junit.After
25+
import org.junit.Before
2526
import org.junit.Test
2627
import org.junit.runner.RunWith
2728

@@ -67,6 +68,12 @@ class AndroidTest {
6768
@Test
6869
fun testJoinClause() = commonTest.testJoinClause()
6970

71+
@Before
72+
fun setUp() {
73+
val context = InstrumentationRegistry.getInstrumentation().targetContext
74+
context.deleteDatabase(CommonBasicTest.DATABASE_NAME)
75+
}
76+
7077
@After
7178
fun setDown() {
7279
val context = InstrumentationRegistry.getInstrumentation().targetContext

sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt

-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ class CommonBasicTest(private val path: DatabasePath) {
345345
name = DATABASE_NAME,
346346
path = path,
347347
version = 1,
348-
inMemory = true,
349348
create = {
350349
it.execSQL(SQL_CREATE_BOOK)
351350
it.execSQL(SQL_CREATE_CATEGORY)

sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.ctrip.sqllin.dsl
1919
import com.ctrip.sqllin.driver.deleteDatabase
2020
import com.ctrip.sqllin.driver.toDatabasePath
2121
import kotlin.test.AfterTest
22+
import kotlin.test.BeforeTest
2223
import kotlin.test.Test
2324

2425
/**
@@ -61,6 +62,11 @@ class JvmTest {
6162
@Test
6263
fun testJoinClause() = commonTest.testJoinClause()
6364

65+
@BeforeTest
66+
fun setUp() {
67+
deleteDatabase(path, CommonBasicTest.DATABASE_NAME)
68+
}
69+
6470
@AfterTest
6571
fun setDown() {
6672
deleteDatabase(path, CommonBasicTest.DATABASE_NAME)

sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.ctrip.sqllin.dsl
1919
import com.ctrip.sqllin.driver.deleteDatabase
2020
import com.ctrip.sqllin.driver.toDatabasePath
2121
import kotlin.test.AfterTest
22+
import kotlin.test.BeforeTest
2223
import kotlin.test.Test
2324

2425
/**
@@ -61,6 +62,11 @@ class NativeTest {
6162
@Test
6263
fun testJoinClause() = commonTest.testJoinClause()
6364

65+
@BeforeTest
66+
fun setUp() {
67+
deleteDatabase(path, CommonBasicTest.DATABASE_NAME)
68+
}
69+
6470
@AfterTest
6571
fun setDown() {
6672
deleteDatabase(path, CommonBasicTest.DATABASE_NAME)

0 commit comments

Comments
 (0)