mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix: align kotlin diagnostics and heading hierarchy
This commit is contained in:
@@ -25,7 +25,7 @@ Run these in order:
|
|||||||
./gradlew build 2>&1
|
./gradlew build 2>&1
|
||||||
./gradlew detekt 2>&1 || echo "detekt not configured"
|
./gradlew detekt 2>&1 || echo "detekt not configured"
|
||||||
./gradlew ktlintCheck 2>&1 || echo "ktlint not configured"
|
./gradlew ktlintCheck 2>&1 || echo "ktlint not configured"
|
||||||
./gradlew dependencies --configuration runtimeClasspath 2>/dev/null | head -100
|
./gradlew dependencies --configuration runtimeClasspath 2>&1 | head -100
|
||||||
```
|
```
|
||||||
|
|
||||||
## Resolution Workflow
|
## Resolution Workflow
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Use `/kotlin-build` when:
|
|||||||
./gradlew ktlintCheck 2>&1 || echo "ktlint not configured"
|
./gradlew ktlintCheck 2>&1 || echo "ktlint not configured"
|
||||||
|
|
||||||
# Dependency issues
|
# Dependency issues
|
||||||
./gradlew dependencies --configuration runtimeClasspath 2>/dev/null | head -100
|
./gradlew dependencies --configuration runtimeClasspath 2>&1 | head -100
|
||||||
|
|
||||||
# Optional deep refresh when caches or dependency metadata are suspect
|
# Optional deep refresh when caches or dependency metadata are suspect
|
||||||
./gradlew build --refresh-dependencies
|
./gradlew build --refresh-dependencies
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ The following sections contain detailed, runnable examples for each testing patt
|
|||||||
|
|
||||||
### TDD Workflow for Kotlin
|
### TDD Workflow for Kotlin
|
||||||
|
|
||||||
### The RED-GREEN-REFACTOR Cycle
|
#### The RED-GREEN-REFACTOR Cycle
|
||||||
|
|
||||||
```
|
```
|
||||||
RED -> Write a failing test first
|
RED -> Write a failing test first
|
||||||
@@ -49,7 +49,7 @@ REFACTOR -> Improve code while keeping tests green
|
|||||||
REPEAT -> Continue with next requirement
|
REPEAT -> Continue with next requirement
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step-by-Step TDD in Kotlin
|
#### Step-by-Step TDD in Kotlin
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
// Step 1: Define the interface/signature
|
// Step 1: Define the interface/signature
|
||||||
@@ -107,7 +107,7 @@ fun validateEmail(email: String): Result<String> {
|
|||||||
|
|
||||||
### Kotest Spec Styles
|
### Kotest Spec Styles
|
||||||
|
|
||||||
### StringSpec (Simplest)
|
#### StringSpec (Simplest)
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class CalculatorTest : StringSpec({
|
class CalculatorTest : StringSpec({
|
||||||
@@ -125,7 +125,7 @@ class CalculatorTest : StringSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### FunSpec (JUnit-like)
|
#### FunSpec (JUnit-like)
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class UserServiceTest : FunSpec({
|
class UserServiceTest : FunSpec({
|
||||||
@@ -151,7 +151,7 @@ class UserServiceTest : FunSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### BehaviorSpec (BDD Style)
|
#### BehaviorSpec (BDD Style)
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class OrderServiceTest : BehaviorSpec({
|
class OrderServiceTest : BehaviorSpec({
|
||||||
@@ -193,7 +193,7 @@ class OrderServiceTest : BehaviorSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### DescribeSpec (RSpec Style)
|
#### DescribeSpec (RSpec Style)
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class UserValidatorTest : DescribeSpec({
|
class UserValidatorTest : DescribeSpec({
|
||||||
@@ -224,7 +224,7 @@ class UserValidatorTest : DescribeSpec({
|
|||||||
|
|
||||||
### Kotest Matchers
|
### Kotest Matchers
|
||||||
|
|
||||||
### Core Matchers
|
#### Core Matchers
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
@@ -272,7 +272,7 @@ shouldNotThrow<Exception> {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom Matchers
|
#### Custom Matchers
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
fun beActiveUser() = object : Matcher<User> {
|
fun beActiveUser() = object : Matcher<User> {
|
||||||
@@ -289,7 +289,7 @@ user should beActiveUser()
|
|||||||
|
|
||||||
### MockK
|
### MockK
|
||||||
|
|
||||||
### Basic Mocking
|
#### Basic Mocking
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class UserServiceTest : FunSpec({
|
class UserServiceTest : FunSpec({
|
||||||
@@ -321,7 +321,7 @@ class UserServiceTest : FunSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Coroutine Mocking
|
#### Coroutine Mocking
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class AsyncUserServiceTest : FunSpec({
|
class AsyncUserServiceTest : FunSpec({
|
||||||
@@ -349,7 +349,7 @@ class AsyncUserServiceTest : FunSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Argument Capture
|
#### Argument Capture
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
test("save captures the user argument") {
|
test("save captures the user argument") {
|
||||||
@@ -364,7 +364,7 @@ test("save captures the user argument") {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Spy and Partial Mocking
|
#### Spy and Partial Mocking
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
test("spy on real object") {
|
test("spy on real object") {
|
||||||
@@ -382,7 +382,7 @@ test("spy on real object") {
|
|||||||
|
|
||||||
### Coroutine Testing
|
### Coroutine Testing
|
||||||
|
|
||||||
### runTest for Suspend Functions
|
#### runTest for Suspend Functions
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
@@ -413,7 +413,7 @@ class CoroutineServiceTest : FunSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Testing Flows
|
#### Testing Flows
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import io.kotest.matchers.collections.shouldContainInOrder
|
import io.kotest.matchers.collections.shouldContainInOrder
|
||||||
@@ -459,7 +459,7 @@ class FlowServiceTest : FunSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### TestDispatcher
|
#### TestDispatcher
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||||
@@ -487,7 +487,7 @@ class DispatcherTest : FunSpec({
|
|||||||
|
|
||||||
### Property-Based Testing
|
### Property-Based Testing
|
||||||
|
|
||||||
### Kotest Property Testing
|
#### Kotest Property Testing
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
@@ -527,7 +527,7 @@ class PropertyTest : FunSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom Generators
|
#### Custom Generators
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
val userArb: Arb<User> = Arb.bind(
|
val userArb: Arb<User> = Arb.bind(
|
||||||
@@ -553,7 +553,7 @@ val moneyArb: Arb<Money> = Arb.bind(
|
|||||||
|
|
||||||
### Data-Driven Testing
|
### Data-Driven Testing
|
||||||
|
|
||||||
### withData in Kotest
|
#### withData in Kotest
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class ParserTest : FunSpec({
|
class ParserTest : FunSpec({
|
||||||
@@ -585,7 +585,7 @@ class ParserTest : FunSpec({
|
|||||||
|
|
||||||
### Test Lifecycle and Fixtures
|
### Test Lifecycle and Fixtures
|
||||||
|
|
||||||
### BeforeTest / AfterTest
|
#### BeforeTest / AfterTest
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class DatabaseTest : FunSpec({
|
class DatabaseTest : FunSpec({
|
||||||
@@ -627,7 +627,7 @@ class DatabaseTest : FunSpec({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Kotest Extensions
|
#### Kotest Extensions
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
// Reusable test extension
|
// Reusable test extension
|
||||||
@@ -656,7 +656,7 @@ class UserRepositoryTest : FunSpec({
|
|||||||
|
|
||||||
### Kover Coverage
|
### Kover Coverage
|
||||||
|
|
||||||
### Gradle Configuration
|
#### Gradle Configuration
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
// build.gradle.kts
|
// build.gradle.kts
|
||||||
@@ -684,7 +684,7 @@ kover {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Coverage Commands
|
#### Coverage Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run tests with coverage
|
# Run tests with coverage
|
||||||
@@ -702,7 +702,7 @@ kover {
|
|||||||
# Windows: start build/reports/kover/html/index.html
|
# Windows: start build/reports/kover/html/index.html
|
||||||
```
|
```
|
||||||
|
|
||||||
### Coverage Targets
|
#### Coverage Targets
|
||||||
|
|
||||||
| Code Type | Target |
|
| Code Type | Target |
|
||||||
|-----------|--------|
|
|-----------|--------|
|
||||||
|
|||||||
Reference in New Issue
Block a user