mirror of https://github.com/sbt/sbt.git
[2.x] test: Add regression test for resource reading (#9552)
This commit is contained in:
parent
25445191d7
commit
380ff6b569
|
|
@ -1,3 +1,3 @@
|
|||
scalaVersion := "2.12.21"
|
||||
val specs = "org.specs2" %% "specs2-core" % "4.3.4"
|
||||
libraryDependencies += specs % Test
|
||||
scalaVersion := "3.8.4"
|
||||
val munit = "org.scalameta" %% "munit" % "1.0.4"
|
||||
libraryDependencies += munit % Test
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
import org.specs2.mutable._
|
||||
|
||||
object BasicTest extends Specification
|
||||
{
|
||||
"Test resource on test classpath" in {
|
||||
getClass.getResource("TestResource.txt") must not beNull
|
||||
}
|
||||
"Main resource on test classpath" in {
|
||||
getClass.getResource("MainResource.txt") must not beNull
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import munit.FunSuite
|
||||
|
||||
class ResourceTest extends FunSuite:
|
||||
test("Test resource on test classpath"):
|
||||
assert(getClass.getResource("TestResource.txt") != null)
|
||||
|
||||
test("Test resource with slash on test classpath"):
|
||||
assert(getClass.getResource("/TestResource.txt") != null)
|
||||
|
||||
test("Test resource contents"):
|
||||
val str = new String(
|
||||
getClass.getResourceAsStream("/TestResource.txt").readAllBytes()
|
||||
)
|
||||
assert(str == "Success")
|
||||
|
||||
test("Main resource on test classpath"):
|
||||
assert(getClass.getResource("MainResource.txt") != null)
|
||||
|
||||
test("Main resource with slash on test classpath"):
|
||||
assert(getClass.getResource("/MainResource.txt") != null)
|
||||
|
||||
test("Main resource contents"):
|
||||
val str = new String(
|
||||
getClass.getResourceAsStream("/MainResource.txt").readAllBytes()
|
||||
)
|
||||
assert(str == "Main")
|
||||
end ResourceTest
|
||||
Loading…
Reference in New Issue