I am implementing simple microservice using Kotlin, Spring and Spek. I want to test my repository but I wonder how can I inject repo into spek test case. Every example or tutorial base on creating new reference like this:
object SampleTest : Spek({
describe("a calculator") {
val calculator = SampleCalculator()
it("should return the result of adding the first number to the second number") {
val sum = calculator.sum(2, 4)
assertEquals(6, sum)
}
it("should return the result of subtracting the second number from the first number") {
val subtract = calculator.subtract(4, 2)
assertEquals(2, subtract)
}
}
})
To summup I dont want to do sth like this:
val calculator = SampleCalculator()
I want to achieve this
@Autowired
val calculator: SampleCalculator
but I cant to that becasue I cant autowire service into local variable.. Any solutions ? I am new in kotlin and spek.
Aucun commentaire:
Enregistrer un commentaire