mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-15 18:43:53 +00:00
setup approval tests with golden master using scalatest
This commit is contained in:
1 parent
5904431bde
commit
ced0cf4c31
3 files changed
+406
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package com.gildedrose
|
||||
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
|
||||
import java.io.{File, FileOutputStream}
|
||||
import scala.io.Source
|
||||
|
||||
class GildedRoseApprovalTest extends AnyFlatSpec with Matchers {
|
||||
it should "return the result of the golden master" in {
|
||||
val fileWithTestResult = new File("approvaltests/gildedrose.testresult.txt")
|
||||
val outputStream = new FileOutputStream(fileWithTestResult)
|
||||
Console.withOut(outputStream) {
|
||||
|
||||
TexttestFixture.main(Array("30"))
|
||||
}
|
||||
|
||||
val approvedFile = "approvaltests/gildedrose.approved.txt"
|
||||
val sourceForTestResults = Source.fromFile(fileWithTestResult)
|
||||
val sourceForApprovedFile = Source.fromFile(approvedFile)
|
||||
|
||||
val resultingOutput =
|
||||
try sourceForTestResults.getLines().toVector
|
||||
finally sourceForTestResults.close()
|
||||
val approvedOutput =
|
||||
try sourceForApprovedFile.getLines().toVector
|
||||
finally sourceForTestResults.close()
|
||||
|
||||
resultingOutput should equal(approvedOutput)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user