When writing tests, use the following naming conventions:
- Name the object under test as `testSubject` (not "sut" or other abbreviations)
- Name fake implementations with a "Fake" prefix (e.g., `FakeDataRepository`)
- Use descriptive variable names that clearly indicate their purpose
### ✅ Assertions
Use [AssertK](https://github.com/willowtreeapps/assertk) for assertions in tests:
```kotlin
@Test
fun`exampletest`(){
// Arrange
vallist=listOf("apple","banana")
// Act
valresult=list.contains("apple")
// Assert
assertThat(result).isTrue()
assertThat(list).contains("banana")
}
```
Note: You'll need to import the appropriate [AssertK](https://github.com/willowtreeapps/assertk) assertions:
-`assertk.assertThat` for the base assertion function
- Functions from the `assertk.assertions` namespace for specific assertion types (e.g., `import assertk.assertions.isEqualTo`, `import assertk.assertions.contains`, `import assertk.assertions.isTrue`, etc.)
## 🧩 Test Types
This section describes the different types of tests we use in the project. Each type serves a specific purpose in our testing strategy, and together they help ensure the quality and reliability of our codebase.
### 🔬 Unit Tests
> **Unit tests verify that individual components work correctly in isolation.**
**What to Test:**
- Single units of functionality
- Individual methods or functions
- Classes in isolation
- Business logic
- Edge cases and error handling
**Key Characteristics:**
- Independent (no external dependencies)
- No reliance on external resources
- Uses fake implementations for dependencies
**Frameworks:**
- JUnit 4
-[AssertK](https://github.com/willowtreeapps/assertk) for assertions
- Full system tests verifying complete user journeys
- Tests across multiple screens and features
- Validates entire application workflows
**Performance Tests** ⚡
- Measures startup time, memory usage, responsiveness
- Validates app performance under various conditions
- Identifies performance bottlenecks
**Accessibility Tests** ♿
- Verifies proper content descriptions
- Checks contrast ratios and keyboard navigation
- Ensures app is usable by people with disabilities
**Localization Tests** 🌐
- Verifies correct translation display
- Tests right-to-left language support
- Validates date, time, and number formatting
**Manual Test Scripts** 📝
- Manual testing by QA team for exploratory testing
- Ensures repeatable test execution
- Documents expected behavior for manual tests
## 🏃 Running Tests
> **Quick commands to run tests in the project.**
Run all tests:
```bash
./gradlew test
```
Run tests for a specific module:
```bash
./gradlew :module-name:test
```
Run Android instrumentation tests:
```bash
./gradlew connectedAndroidTest
```
Run tests with coverage:
```bash
./gradlew testDebugUnitTestCoverage
```
## 📊 Code Coverage
> **⚠️ Work in Progress ⚠️**
>
> This section is currently under development and will be updated with specific code coverage rules and guidelines.
Code coverage helps us understand how much of our codebase is being tested. While we don't currently have strict requirements, we aim for high coverage in critical components.
**Current Approach:**
- Focus on critical business logic
- Prioritize user-facing features
- No strict percentage requirements
- Quality of tests over quantity
**Future Guidelines (Coming Soon):**
- Code coverage targets by component type
- Coverage report generation instructions
- Interpretation guidelines
- Exemptions for generated/simple code
- CI/CD integration details
**Remember:** High code coverage doesn't guarantee high-quality tests. Focus on writing meaningful tests that verify correct behavior, not just increasing coverage numbers.