mirror of
https://github.com/ysoftdevs/Theatrical-Players-Refactoring-Kata.git
synced 2026-04-01 15:23:02 +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:
@@ -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.Test
|
||||
import org.approvaltests.Approvals.verify
|
||||
|
||||
class StatementPrinterTests {
|
||||
|
||||
@Test
|
||||
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(
|
||||
"hamlet" to Play("Hamlet", "tragedy"),
|
||||
@@ -30,7 +25,7 @@ class StatementPrinterTests {
|
||||
val statementPrinter = StatementPrinter()
|
||||
val result = statementPrinter.print(invoice, plays)
|
||||
|
||||
assertEquals(expected, result)
|
||||
verify(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user