I'm trying to use Java ServiceLoader in Scala 2.10 to find all my test classes by reflection:
val services = ServiceLoader.load(classOf[MyClass])
for (service <- services.asScala) {
test(service.getClass.getCanonicalName) {
println(service)
... test code
}
}
I'm very sure 'MyClass' has several subclasses which contains test cases, as I can use 'classOf[]' function to find them in the same code snippet
However, my test always ends with
Empty test suite.
Is the ServiceLoader not working in Scala? How to fix or circumvent this problem?
Sorry I forgot to set the META-INF/services/ file, after adding the binary name of the service class everything goes normal!