I do simple microservices using Kotlin, Spring and Spek. I want to check my repository, but I am wondering how I can insert a repo into a spek test file. Each example or tutorial is based on creating a new link:
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 summarize, I don't want to do this:
val calculator = SampleCalculator()
I want to achieve this
@Autowired val calculator: SampleCalculator
but I cannot do this because I cannot use auto services in a local variable. Any solutions? I am new to kotlin and spek.
source share