https://kotlinlang.org logo
#kotless
Title
# kotless
l

LeoColman

07/19/2020, 3:58 AM
How to write a Ktor test that runs from within Kotless?
Copy code
withTestApplication { 
    handleRequest(Get, "/xx").response.content shouldContain "yyy"
}
doesn't seem to work for
Copy code
class Server : Kotless() {
    
    override fun prepare(app: Application) {
        app.routing { 
            static("/") {
                resource("/xx", "yy.html")
            }
        }
    }
}
What am I missing?
I got it by
Copy code
withTestApplication {
    Server().prepare(this.application)
    handleRequest(Get, "/xx").response.content shouldContain "yy"
}
is that the correct way?
t

TanVD

07/19/2020, 8:25 AM
Yep, I would say that it is ok. You should use your Kotless object to prepare test app
Once it is done test app can be used as it is just Ktor app
3 Views