Browse Source

Add some Konsist test.

pull/1526/head
Benoit Marty 12 months ago
parent
commit
6e5caebc60
  1. 1
      .idea/dictionaries/shared.xml
  2. 1
      app/build.gradle.kts
  3. 49
      app/src/test/kotlin/io/element/android/app/KonsistTest.kt
  4. 1
      gradle/libs.versions.toml

1
.idea/dictionaries/shared.xml

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
<w>backstack</w>
<w>ftue</w>
<w>homeserver</w>
<w>konsist</w>
<w>kover</w>
<w>measurables</w>
<w>onboarding</w>

1
app/build.gradle.kts

@ -230,6 +230,7 @@ dependencies { @@ -230,6 +230,7 @@ dependencies {
testImplementation(libs.test.truth)
testImplementation(libs.test.turbine)
testImplementation(projects.libraries.matrix.test)
testImplementation(libs.test.konsist)
ksp(libs.showkase.processor)
}

49
app/src/test/kotlin/io/element/android/app/KonsistTest.kt

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* 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.
*/
package io.element.android.app
import com.lemonappdev.konsist.api.Konsist
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
import com.lemonappdev.konsist.api.ext.list.withAllParentsOf
import com.lemonappdev.konsist.api.verify.assertTrue
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import org.junit.Test
class KonsistTest {
@Test
fun `classes extending 'Presenter' should have 'Presenter' suffix`() {
Konsist.scopeFromProject()
.classes()
.withAllParentsOf(Presenter::class)
.assertTrue { it.name.endsWith("Presenter") }
}
@Test
fun `function with '@PreviewsDayNight' annotation should have 'Preview' suffix`() {
Konsist
.scopeFromProject()
.functions()
.withAllAnnotationsOf(PreviewsDayNight::class)
.assertTrue {
it.hasNameEndingWith("Preview") &&
it.hasNameEndingWith("LightPreview").not() &&
it.hasNameEndingWith("DarkPreview").not()
}
}
}

1
gradle/libs.versions.toml

@ -130,6 +130,7 @@ test_uiautomator = "androidx.test.uiautomator:uiautomator:2.2.0" @@ -130,6 +130,7 @@ test_uiautomator = "androidx.test.uiautomator:uiautomator:2.2.0"
test_junitext = "androidx.test.ext:junit:1.1.5"
test_mockk = "io.mockk:mockk:1.13.8"
test_barista = "com.adevinta.android:barista:4.3.0"
test_konsist = "com.lemonappdev:konsist:0.13.0"
test_hamcrest = "org.hamcrest:hamcrest:2.2"
test_orchestrator = "androidx.test:orchestrator:1.4.2"
test_turbine = "app.cash.turbine:turbine:1.0.0"

Loading…
Cancel
Save