This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal fun launchesScreenRobot( | |
| composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<EntryPointActivity>, EntryPointActivity>, | |
| func: LaunchesScreenRobot.() -> Unit | |
| ) = LaunchesScreenRobot(composeTestRule).also { func } | |
| internal open class LaunchesScreenRobot constructor( | |
| private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<EntryPointActivity>, EntryPointActivity> | |
| ) { | |
| // Robot definitions and functions | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun elementsVisibilityAfterOpeningTheScreen() { | |
| launchesScreenRobot(composeTestRule) { | |
| clickOnLaunchesTab() | |
| initialElementsShowed() | |
| } | |
| } | |
| @Test | |
| fun elementsVisibilityAfterOpeningTheScreen() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ExperimentalMaterialApi | |
| @RunWith(AndroidJUnit4::class) | |
| @HiltAndroidTest | |
| class LaunchesScreenKtTest : BaseScreenTest() { | |
| @Test | |
| @InternalCoroutinesApi | |
| fun visibleItemsCountAfterOpeningTheScreen() { | |
| mockWebServer.dispatcher = SuccessDispatcher() | |
| setMainContent() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val mockWebServer by lazy { MockWebServer() } | |
| @Before | |
| fun setUp() { | |
| mockWebServer.start(BuildConfig.PORT) | |
| } | |
| @After | |
| fun teardown() { | |
| mockWebServer.shutdown() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @InstallIn(SingletonComponent::class) | |
| @Module | |
| open class NetworkModule { | |
| open fun getBaseUrl () ="https://api.spacexdata.com/v3/" | |
| @Provides | |
| @BaseUrl | |
| fun provideBaseUrl() = getBaseUrl () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| @TestInstallIn( | |
| components = [SingletonComponent::class], | |
| replaces = [NetworkModule::class] | |
| ) | |
| class FakeNetworkModule : NetworkModule() { | |
| override fun getBaseUrl() = "http://127.0.0.1:${BuildConfig.PORT}" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| @InternalCoroutinesApi | |
| fun elementsVisibilityAfterTwoItemsRetrieved() { | |
| composeTestRule.apply { | |
| setContent { | |
| SpaceXTheme { | |
| LaunchesScreen( | |
| state = LaunchesContract.State( | |
| listOf( | |
| LaunchUiModel( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MockTestRunner : AndroidJUnitRunner() { | |
| override fun onCreate(arguments: Bundle?) { | |
| StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitAll().build()) | |
| super.onCreate(arguments) | |
| } | |
| override fun newApplication( | |
| cl: ClassLoader?, | |
| className: String?, | |
| context: Context? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android { | |
| defaultConfig { | |
| applicationId = "prieto.fernando.sample" | |
| testInstrumentationRunner = "prieto.fernando.sample.webmock.MockTestRunner" | |
| } | |
| buildFeatures { | |
| compose = true | |
| viewBinding = true | |
| } | |
| // rest of configuration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private val dialogFilterButton by lazy { | |
| composeTestRule.onNodeWithContentDescription("Filter Button") | |
| } | |
| @Test | |
| fun elementsVisibilityAfterOpeningTheMainScreen() { | |
| setMainContent() | |
| dialogFilterButton.assertIsDisplayed() | |
| } | |
NewerOlder