Hi,
I have a Suite with a constructor with default arguments as so:
class MyTests(environmentFactory: FixtureFactory[Environment] = EnvironmentFactory()) extends fixture.FunSuite {
override type FixtureParam = Environment
test("hello world") { environment =>
...
}
override protected def withFixture(test: OneArgTest): Outcome = {
environmentFactory.using { environment =>
test.apply(environment)
}
}
}
object EnvironmentFactory {
def apply(): FixtureFactory[Environment] = ???
}
I want this because the environment factory may optionally be a pool of environments, and I'd like to manage that pool at a higher level when running all my tests but use a non-pooled default version when running one test.
Unfortunately the scalatest SuiteDiscoveryHelper.isAccessibleSuite method doesn't find it as a Suite because Java reflection doesn't see it as having a no args constructor. Is there anything that could be done using Scala reflection to allow for this case? I've had a quick look at the Scala reflection API and it wasn't immediately obvious...
Wondering really if it's worth raising an issue for this or not, particularly as I don't know how to fix it myself! I'm sort of hoping that if it worked in the scalatest runner it would also work inside IntelliJ (which also refuses to run this class as a test standalone).
Thanks,
Rob