ZIO Test SBT Framework integration that provides test interface implementation for running ZIO-based tests within SBT build environments
—
Test specification discovery mechanism that allows SBT to identify ZIO test classes and convert them into executable test tasks. This system enables automatic detection of ZIO test specifications in the classpath.
The fingerprint implementation that enables SBT to discover ZIO test specifications by identifying classes that extend ZIOSpecAbstract.
/**
* SBT fingerprint for discovering ZIO test specifications
* Identifies classes extending ZIOSpecAbstract as test targets
*/
object ZioSpecFingerprint extends SubclassFingerprint {
/**
* Returns the superclass name that SBT should look for
* @return Fully qualified name of ZIOSpecAbstract class
*/
def superclassName(): String
/**
* Indicates that test specifications are module objects (Scala objects)
* @return Always true, as ZIO tests are typically defined as objects
*/
def isModule(): Boolean
/**
* Indicates whether a no-argument constructor is required
* @return Always false, as Scala objects don't require explicit constructors
*/
def requireNoArgConstructor(): Boolean
}Implementation Details:
// Returns the ZIOSpecAbstract class name for discovery
def superclassName(): String = classOf[ZIOSpecAbstract].getName
// ZIO test specifications are typically Scala objects
final def isModule(): Boolean = true
// Scala objects don't require no-arg constructors
final def requireNoArgConstructor(): Boolean = falseThe test discovery process follows this flow:
ZIOSpecAbstractTaskDef instancesTaskDef instances to platform-specific test runnersThe fingerprint discovers various ZIO test specification patterns:
Basic ZIO Spec Object:
object MyTestSpec extends ZIOSpecDefault {
def spec = suite("MyTests")(
test("example test") {
assert(1 + 1)(equalTo(2))
}
)
}Custom ZIO Spec:
object CustomSpec extends ZIOSpec[TestEnvironment] {
def spec = suite("CustomTests")(
test("custom test") {
// test implementation
assertTrue(true)
}
)
}ZIO Spec with Environment:
object DatabaseSpec extends ZIOSpecDefault {
override def spec = suite("DatabaseTests")(
test("database connection") {
// test with custom environment
assertTrue(true)
}
).provide(/* custom layers */)
}The fingerprint integrates seamlessly with SBT's test discovery mechanism:
// SBT uses the fingerprint to:
// 1. Scan classpath for matching classes
// 2. Create TaskDef instances for each discovered test
// 3. Pass TaskDefs to the framework's runner
// 4. Execute tests and collect results
val discoveredSpecs: Array[TaskDef] = sbtDiscoveryEngine.discover(ZioSpecFingerprint)
val runner = framework.runner(args, remoteArgs, classLoader)
val tasks = runner.tasks(discoveredSpecs)The fingerprint works consistently across all supported platforms:
The discovery process handles various error conditions:
ZIOSpecAbstractThe robust discovery mechanism ensures that ZIO test specifications are reliably found and executed across different build configurations and runtime environments.
Install with Tessl CLI
npx tessl i tessl/maven-dev-zio--zio-test-sbt-3