mirror of
https://github.com/bitwarden/android.git
synced 2024-11-24 02:15:53 +03:00
Add BaseComposeTest for facilitating compose-layer testing (#14)
This commit is contained in:
parent
b337fbfd20
commit
17d5475d0f
2 changed files with 25 additions and 16 deletions
|
@ -1,30 +1,17 @@
|
|||
package com.x8bit.bitwarden.example
|
||||
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onRoot
|
||||
import androidx.compose.ui.test.performClick
|
||||
import dagger.hilt.android.testing.HiltTestApplication
|
||||
import com.x8bit.bitwarden.example.ui.BaseComposeTest
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
/**
|
||||
* Example showing that Compose tests using "junit" imports and Roboelectric work.
|
||||
* Example showing that Compose tests using "junit" imports and Robolectric work.
|
||||
*/
|
||||
@Config(
|
||||
application = HiltTestApplication::class,
|
||||
sdk = [Config.NEWEST_SDK],
|
||||
)
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class ExampleComposeTest {
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
|
||||
class ExampleComposeTest : BaseComposeTest() {
|
||||
@Test
|
||||
fun `the onClick callback should be correctly triggered when performing a click`() {
|
||||
var isClicked = false
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.x8bit.bitwarden.example.ui
|
||||
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import dagger.hilt.android.testing.HiltTestApplication
|
||||
import org.junit.Rule
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
/**
|
||||
* A base class that can be used for performing Compose-layer testing using Robolectric, Compose
|
||||
* Testing, and JUnit 4.
|
||||
*/
|
||||
@Config(
|
||||
application = HiltTestApplication::class,
|
||||
sdk = [Config.NEWEST_SDK],
|
||||
)
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
abstract class BaseComposeTest {
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
}
|
Loading…
Reference in a new issue