Kafka follows modern Android testing best practices:
Unit tests for business logic and use cases
UI tests using Compose testing framework
Integration tests for data layer
Baseline profile tests for performance optimization
While the project structure supports comprehensive testing, the current focus is on functionality. Contributions to improve test coverage are highly welcomed!
# Run all unit tests in the project./gradlew test# Run tests for a specific module./gradlew :app:test# Run tests with coverage./gradlew test jacocoTestReport
# Run all instrumented tests./gradlew connectedAndroidTest# Run on a specific device./gradlew connectedDebugAndroidTest# Run tests for a specific module./gradlew :app:connectedAndroidTest
Connect a device or start an emulator (API 31+ recommended)
2
Run Generation
# Using connected device./gradlew :baselineprofile:generateBaselineProfile# Using managed device./gradlew :baselineprofile:pixel6Api31Setup \ :baselineprofile:generateBaselineProfile
3
Review Output
Generated profiles are placed in:
app/src/main/baseline-prof.txt
Baseline profile generation requires a physical device or emulator. It cannot run on rooted devices or in CI environments without special configuration.
// Good - separate tests@Testfun download_whenStarted_showsProgress()@Testfun download_whenComplete_showsSuccess()// Bad - testing multiple behaviors@Testfun downloadWorkflow()
Mock External Dependencies
Use dependency injection to mock external dependencies:
class MyViewModelTest { private val mockRepository = mock<Repository>() private val viewModel = MyViewModel(mockRepository) @Test fun loadData_callsRepository() { viewModel.loadData() verify(mockRepository).fetchData() }}
# Run lint on debug variant./gradlew lintDebug# Run lint on all variants./gradlew lint# Generate HTML report./gradlew lintDebug# Report: app/build/reports/lint-results-debug.html