Skip to content

Commit

Permalink
Add the logic about history cleaning before runing the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaoyuang committed Sep 19, 2023
1 parent e86aca9 commit b83586c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b83586c

Please sign in to comment.