Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use kotlin.test instead of JUnit #5220

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")

// tests
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:$mockitoVersion")
testImplementation("org.mockito:mockito-inline:$mockitoVersion")
testImplementation("org.assertj:assertj-core:3.23.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package de.westnordost.streetcomplete.data

import android.database.sqlite.SQLiteOpenHelper
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.After
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertNotNull

open class ApplicationDbTestCase {
protected lateinit var dbHelper: SQLiteOpenHelper
protected lateinit var database: Database

@Before fun setUpHelper() {
@BeforeTest fun setUpHelper() {
dbHelper = StreetCompleteSQLiteOpenHelper(
InstrumentationRegistry.getInstrumentation().targetContext,
DATABASE_NAME
Expand All @@ -20,10 +20,10 @@ open class ApplicationDbTestCase {
}

@Test fun databaseAvailable() {
Assert.assertNotNull(dbHelper.readableDatabase)
assertNotNull(dbHelper.readableDatabase)
}

@After fun tearDownHelper() {
@AfterTest fun tearDownHelper() {
dbHelper.close()
InstrumentationRegistry.getInstrumentation().targetContext
.deleteDatabase(DATABASE_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package de.westnordost.streetcomplete.data.download.tiles
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class DownloadedTilesDaoTest : ApplicationDbTestCase() {
private lateinit var dao: DownloadedTilesDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = DownloadedTilesDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package de.westnordost.streetcomplete.data.meta

import androidx.test.platform.app.InstrumentationRegistry
import de.westnordost.streetcomplete.osm.opening_hours.model.Weekdays.Companion.getWeekdayIndex
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Test
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue

class CountryInfosTest {
private val validWeekdays = listOf("Mo", "Tu", "We", "Th", "Fr", "Sa", "Su")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package de.westnordost.streetcomplete.data.osm.created_elements
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.data.osm.mapdata.ElementKey
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class CreatedElementsDaoTest : ApplicationDbTestCase() {
private lateinit var dao: CreatedElementsDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = CreatedElementsDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.data.osm.mapdata.ElementKey
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import kotlin.test.*
import kotlin.test.BeforeTest
import kotlin.test.Test

class EditElementsDaoTest : ApplicationDbTestCase() {
private lateinit var dao: EditElementsDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = EditElementsDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ import de.westnordost.streetcomplete.data.quest.QuestTypeRegistry
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement
import de.westnordost.streetcomplete.overlays.Overlay
import de.westnordost.streetcomplete.overlays.Style
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

class ElementEditsDaoTest : ApplicationDbTestCase() {
private lateinit var dao: ElementEditsDao

@Before fun createDao() {
@BeforeTest fun createDao() {
val list = listOf(1 to TEST_QUEST_TYPE, 2 to TEST_QUEST_TYPE2)
val list2 = listOf(1 to TestOverlay)
dao = ElementEditsDao(database, QuestTypeRegistry(list), OverlayRegistry(list2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.data.osm.mapdata.ElementIdUpdate
import de.westnordost.streetcomplete.data.osm.mapdata.ElementKey
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue

class ElementIdProviderDaoTest : ApplicationDbTestCase() {
private lateinit var dao: ElementIdProviderDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = ElementIdProviderDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package de.westnordost.streetcomplete.data.osm.edits.upload.changesets

import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue

class OpenChangesetsDaoTest : ApplicationDbTestCase() {
private lateinit var dao: OpenChangesetsDao
Expand All @@ -15,7 +15,7 @@ class OpenChangesetsDaoTest : ApplicationDbTestCase() {
private val P = "Brasliweks"
private val SOURCE = "test"

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = OpenChangesetsDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
import de.westnordost.streetcomplete.data.osm.mapdata.Node
import de.westnordost.streetcomplete.data.osm.mapdata.NodeDao
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

class ElementGeometryDaoTest : ApplicationDbTestCase() {
private lateinit var dao: ElementGeometryDao
private lateinit var nodeDao: NodeDao

@Before fun createDao() {
@BeforeTest fun createDao() {
nodeDao = NodeDao(database)
val relationGeometryDao = RelationGeometryDao(database, PolylinesSerializer())
val wayGeometryDao = WayGeometryDao(database, PolylinesSerializer())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType
import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

class RelationGeometryDaoTest : ApplicationDbTestCase() {
private lateinit var dao: RelationGeometryDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = RelationGeometryDao(database, PolylinesSerializer())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType
import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

class WayGeometryDaoTest : ApplicationDbTestCase() {
private lateinit var dao: WayGeometryDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = WayGeometryDao(database, PolylinesSerializer())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package de.westnordost.streetcomplete.data.osm.mapdata
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

class NodeDaoTest : ApplicationDbTestCase() {
private lateinit var dao: NodeDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = NodeDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.RELATION
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.WAY
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

class RelationDaoTest : ApplicationDbTestCase() {
private lateinit var dao: RelationDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = RelationDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package de.westnordost.streetcomplete.data.osm.mapdata
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

class WayDaoTest : ApplicationDbTestCase() {
private lateinit var dao: WayDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = WayDao(database)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import de.westnordost.streetcomplete.data.osm.mapdata.ElementKey
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType
import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue

class OsmQuestDaoTest : ApplicationDbTestCase() {
private lateinit var dao: OsmQuestDao

@Before fun createDao() {
@BeforeTest fun createDao() {
dao = OsmQuestDao(database)
}

Expand Down
Loading