mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-06 10:12:34 +00:00
Add jacoco dependency, convert TexttestFixtures to tests. Update README with results and next steps.
This commit is contained in:
parent
77b6522361
commit
cf6f9f54fe
@ -32,3 +32,14 @@ There are instructions in the [TextTest Readme](../texttests/README.md) for sett
|
||||
2. Break complex statements, make code longer and simpler
|
||||
3. understand algorithm and propose better solution
|
||||
|
||||
|
||||
### Execution
|
||||
TexttestFixtures indeed do not cover all paths, based on jacoco coverage:
|
||||

|
||||
|
||||
There are two ways to advance:
|
||||
1. manually craft extra test cases
|
||||
2. auto generate a bunch of test cases
|
||||
|
||||
I prefer to go with (2) because it seems to me to be more resilient way. I need to check if execution
|
||||
time is not bloated. Also minimize number of test cases.
|
||||
|
||||
@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.10"
|
||||
application
|
||||
jacoco
|
||||
}
|
||||
|
||||
group = "com.gildedrose"
|
||||
@ -22,6 +23,11 @@ tasks.test {
|
||||
testLogging {
|
||||
events("passed", "skipped", "failed")
|
||||
}
|
||||
finalizedBy(tasks.jacocoTestReport)
|
||||
}
|
||||
|
||||
tasks.jacocoTestReport {
|
||||
dependsOn(tasks.test)
|
||||
}
|
||||
|
||||
// config JVM target to 1.8 for kotlin compilation tasks
|
||||
|
||||
BIN
Kotlin/img.png
Normal file
BIN
Kotlin/img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
@ -2,6 +2,15 @@ package com.gildedrose
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertAll
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
import org.junit.jupiter.params.provider.Arguments.of
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource
|
||||
import java.util.stream.Stream
|
||||
|
||||
|
||||
internal class GildedRoseTest {
|
||||
|
||||
@ -10,10 +19,41 @@ internal class GildedRoseTest {
|
||||
val items = listOf(Item("foo", 0, 0))
|
||||
val app = GildedRose(items)
|
||||
app.updateQuality()
|
||||
assertEquals("fixme", app.items[0].name)
|
||||
assertEquals("foo", app.items[0].name)
|
||||
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(GildedRoseArgumentsProvider::class)
|
||||
fun `should update quality`(item: Item, expectedQuality: Int, expectedSellIn: Int) {
|
||||
val itemName = item.name
|
||||
val items = listOf(item)
|
||||
val app = GildedRose(items)
|
||||
app.updateQuality()
|
||||
assertAll(
|
||||
{ assertEquals(itemName, app.items[0].name) },
|
||||
{ assertEquals(expectedQuality, app.items[0].quality) },
|
||||
{ assertEquals(expectedSellIn, app.items[0].sellIn) }
|
||||
)
|
||||
}
|
||||
|
||||
class GildedRoseArgumentsProvider : ArgumentsProvider {
|
||||
override fun provideArguments(context: ExtensionContext): Stream<out Arguments?> {
|
||||
return Stream.of(
|
||||
of(Item("+5 Dexterity Vest", 10, 20), 19, 9),
|
||||
of(Item("Aged Brie", 2, 0), 1, 1),
|
||||
of(Item("Elixir of the Mongoose", 5, 7), 6, 4),
|
||||
of(Item("Sulfuras, Hand of Ragnaros", 0, 80), 80, 0),
|
||||
of(Item("Sulfuras, Hand of Ragnaros", -1, 80), 80, -1),
|
||||
of(Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 21, 14),
|
||||
of(Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 50, 9),
|
||||
of(Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 50, 4),
|
||||
// this conjured item does not work properly yet
|
||||
// of(Item("Conjured Mana Cake", 3, 6), 5, 2), // TODO: enabled and fix after refactor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user