mirror of
https://github.com/ysoftdevs/Theatrical-Players-Refactoring-Kata.git
synced 2026-04-26 18:59:04 +02:00
Use approval testing framework for statement printer test
It's better to store the expected text in a separate file instead of mixed in together with the kotlin test code. This is for several reasons - it is easier to read when the expected value is on several lines - it is easier to update using a diff merge tool - it is easier to read the VCS history since it will probably change more frequently than the rest of the test code
This commit is contained in:
@@ -17,6 +17,7 @@ dependencies {
|
|||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
|
||||||
testCompile("org.junit.jupiter:junit-jupiter-params:5.4.2")
|
testCompile("org.junit.jupiter:junit-jupiter-params:5.4.2")
|
||||||
|
testCompile 'com.approvaltests:approvaltests:3.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
#Tue Sep 10 10:36:28 CEST 2019
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Statement for BigCo
|
||||||
|
Hamlet: $650.00 (55 seats)
|
||||||
|
As You Like It: $580.00 (35 seats)
|
||||||
|
Othello: $500.00 (40 seats)
|
||||||
|
Amount owed is $1,730.00
|
||||||
|
You earned 47 credits
|
||||||
@@ -1,17 +1,12 @@
|
|||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
|
||||||
import org.junit.jupiter.api.Assertions.assertThrows
|
import org.junit.jupiter.api.Assertions.assertThrows
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.approvaltests.Approvals.verify
|
||||||
|
|
||||||
class StatementPrinterTests {
|
class StatementPrinterTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
internal fun exampleStatement() {
|
internal fun exampleStatement() {
|
||||||
val expected = "Statement for BigCo\n" +
|
|
||||||
" Hamlet: \$650.00 (55 seats)\n" +
|
|
||||||
" As You Like It: \$580.00 (35 seats)\n" +
|
|
||||||
" Othello: \$500.00 (40 seats)\n" +
|
|
||||||
"Amount owed is \$1,730.00\n" +
|
|
||||||
"You earned 47 credits\n"
|
|
||||||
|
|
||||||
val plays = mapOf(
|
val plays = mapOf(
|
||||||
"hamlet" to Play("Hamlet", "tragedy"),
|
"hamlet" to Play("Hamlet", "tragedy"),
|
||||||
@@ -30,7 +25,7 @@ class StatementPrinterTests {
|
|||||||
val statementPrinter = StatementPrinter()
|
val statementPrinter = StatementPrinter()
|
||||||
val result = statementPrinter.print(invoice, plays)
|
val result = statementPrinter.print(invoice, plays)
|
||||||
|
|
||||||
assertEquals(expected, result)
|
verify(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user