나는 Kotlin에서 Spek 테스트를 쓰고 싶다. 테스트는 src/test/resources
폴더에서 HTML 파일을 읽어야합니다. 그것을하는 방법?Kotlin의 리소스에서 텍스트 파일을 읽는 방법은 무엇입니까?
class MySpec : Spek({
describe("blah blah") {
given("blah blah") {
var fileContent : String = ""
beforeEachTest {
// How to read the file file.html in src/test/resources/html
fileContent = ...
}
it("should blah blah") {
...
}
}
}
})
이 날이 작동하지 않았다 들어 나는이'으로 변경했다 : : class.java.classLoader.getResource ("/ html/file.html"). readText()' – pk1914
나를 위해이 두 가지 옵션은 안드로이드 애플 리케이션에서 작동했다. html은 다른 곳에서 삭제되어야한다) :'this :: class.java.getResource ("/ html/file.html"). readText()'and this :: class.java.classLoader.getResource ("html/file.html "). readText()' – Franco