dave08
08/12/2024, 7:14 AMgetFromResource(name: String): String
?CLOVIS
08/12/2024, 7:37 AMcompat-filesystem
. What kind of things do you do with the resources once you read them?dave08
08/12/2024, 7:48 AMdave08
08/12/2024, 7:51 AMCLOVIS
08/12/2024, 7:56 AMdave08
08/12/2024, 7:59 AMinline fun <reified T> preparedApproval() = prepared {
val name = T::class.java.simpleName + "-" + environment.testName
Approver(name, Sources.`in`(File("src/test/kotlin"), T::class.java.`package`))
}
val approver by preparedApproval<PodcastRssImporterSpec>()
Example for resources:
fun getContentFromResources(path: String) =
SomeSpec::class.java.classLoader.getResourceAsStream(path)?.let {
it.bufferedReader().use { reader -> reader.readText() }
}
val rssExtractor by prepared {
RssExtractor(getContentFromResources("somefeedInResources.xml"))
}
Improved:
val rssExtractor by prepared {
// getResource would be in the TestDsl and use the current test class's resources
RssExtractor(getResource("somefeedInResources.xml"))
}
dave08
08/12/2024, 8:01 AMCLOVIS
08/12/2024, 8:32 AMdave08
08/12/2024, 8:50 AMdave08
08/12/2024, 8:51 AMCLOVIS
08/12/2024, 8:56 AMI'm not sure if the best thing is to generate those approval files in the resources folderWhere else would you expect to find them?
CLOVIS
08/12/2024, 8:57 AMdave08
08/12/2024, 8:57 AMBoth frameworks I currently know about use the test's folder and name the file according the the test class and the current test.
CLOVIS
08/12/2024, 8:57 AMdave08
08/12/2024, 8:58 AMdave08
08/12/2024, 8:58 AMCLOVIS
08/12/2024, 8:59 AMdave08
08/12/2024, 8:59 AMCLOVIS
08/12/2024, 9:00 AMdave08
08/12/2024, 9:02 AM