ashrafi / FitnessFinder

Yelp GraphQL Fitness Finder
4 stars 0 forks source link

Add Room in memory DB to testing #1

Open ashrafi opened 1 year ago

ashrafi commented 1 year ago

We should be using Room.inMemoryDatabaseBuilder

You typically use a Fake Database when you want to simulate the behavior of the real database and control the test environment, especially when testing business logic or data manipulation code. On the other hand, an in-memory Room database is more suitable when you want to test the integration between your app's code and the Room database, including the database schema, SQL queries, and data access logic.

Use Uninstall Module to tell Hilt to use the in memory DB. For this to work we must use the HiltTestRunner.

Files effected.

core-testing - TestDataBaseModule in com.test.fitnessstudios.core.testing.data.di provideTestAppDatabase to the repository.

The FakeFitnessStudioRepository If we us the inMemory DB we do not have to implement all the functions in the DB.

Used for instrumented tests

ashrafi commented 1 year ago

Need to identify all files that need the Room.inMemoryDatabaseBuilder. Should be use cases that need a repository in Android Instrument tests.

Use Cases are in core.domain - com.test.fitnessstudios.core.domain The Hilt DI provides everything needed to do composable UI testing. Do not need to call the ViewModel. Just use the UI to do the testing.

So everywhere there is a Usecase ... use DI to build it and run the composable by driving the UI.

[] place an instrument test here feature-details - com.test.fitnessstudios.feature.details.ui