Initial project setup (BIT-61) (#7)

This commit is contained in:
Brian Yencho
2023-08-22 16:03:42 -05:00
committed by GitHub
parent 67fd9d30b6
commit de2eed7c24
53 changed files with 1869 additions and 18 deletions

View File

@@ -0,0 +1,45 @@
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 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.
*/
@Config(
application = HiltTestApplication::class,
sdk = [Config.NEWEST_SDK],
)
@RunWith(RobolectricTestRunner::class)
class ExampleComposeTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun `the onClick callback should be correctly triggered when performing a click`() {
var isClicked = false
composeTestRule.setContent {
Button(
onClick = { isClicked = true },
) {
// Empty
}
}
assertFalse(isClicked)
composeTestRule.onRoot().performClick()
assertTrue(isClicked)
}
}

View File

@@ -0,0 +1,18 @@
package com.x8bit.bitwarden.example
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
/**
* Example showing that JUnit5 tests using "jupiter" imports work.
*/
class ExampleJUnit5Test {
@Nested
inner class NestedSample {
@Test
fun `an empty listOf should be the same as emptyList`() {
assertEquals(listOf<Any>(), emptyList<Any>())
}
}
}