SBT test framework integration for ZIO that enables running ZIO-based test suites through SBT's testing infrastructure.
npx @tessl/cli install tessl/maven-dev-zio--zio-test-sbt_sjs1_3@1.0.0ZIO Test SBT provides SBT test framework integration for ZIO, enabling developers to run ZIO-based test suites through SBT's standard testing infrastructure. It includes test task implementations that bridge ZIO's asynchronous, effect-based testing model with SBT's test interface, supporting cross-compilation for JVM, JavaScript (Scala.js), and Native platforms.
build.sbt:
libraryDependencies += "dev.zio" %% "zio-test-sbt" % "1.0.18"import zio.test.sbt._Platform-specific imports:
// For SBT framework registration (automatically handled)
import zio.test.sbt.ZTestFramework
// For custom test tasks or runners
import zio.test.sbt.{ZTestRunner, BaseTestTask, ZTestEvent}
// For summary handling and communication
import zio.test.sbt.{SendSummary, SummaryProtocol}ZIO Test SBT integrates automatically with SBT's testing infrastructure. Users typically don't interact with the API directly, but register the framework in their build configuration:
// In build.sbt
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
// Your ZIO test specifications
import zio.test._
object MySpec extends DefaultRunnableSpec {
def spec = suite("MySpec")(
test("example test") {
assert(2 + 2)(equalTo(4))
}
)
}The framework automatically discovers and executes ZIO test specifications when running sbt test.
ZIO Test SBT is built around several key components that work together to bridge ZIO's effect system with SBT's testing infrastructure:
ZTestFramework serves as the entry point for SBT integration, implementing SBT's Framework interfaceZTestRunner, ZMasterTestRunner, ZSlaveTestRunner) handle test discovery and execution coordinationBaseTestTask and platform-specific task implementations execute individual test specifications within the ZIO runtimeZTestEvent converts ZIO test results into SBT-compatible events for reporting and IDE integrationSendSummary and SummaryProtocol handle result transmission, especially for distributed execution on JS/Native platformsCore SBT framework integration that enables ZIO test discovery and execution within SBT's testing infrastructure.
class ZTestFramework extends sbt.testing.Framework {
val name: String
val fingerprints: Array[sbt.testing.Fingerprint]
def runner(
args: Array[String],
remoteArgs: Array[String],
testClassLoader: ClassLoader
): sbt.testing.Runner
}Test execution system that runs ZIO test specifications and handles platform-specific execution models.
abstract class BaseTestTask(
taskDef: sbt.testing.TaskDef,
testClassLoader: ClassLoader,
sendSummary: SendSummary,
args: zio.test.TestArgs
) extends sbt.testing.Task {
def execute(
eventHandler: sbt.testing.EventHandler,
loggers: Array[sbt.testing.Logger]
): Array[sbt.testing.Task]
}
class ZTestRunner(
args: Array[String],
remoteArgs: Array[String],
testClassLoader: ClassLoader
) extends sbt.testing.Runner {
def tasks(defs: Array[sbt.testing.TaskDef]): Array[sbt.testing.Task]
def done(): String
}Event system that converts ZIO test results into SBT-compatible events for reporting, IDE integration, and test result visualization.
case class ZTestEvent(
fullyQualifiedName: String,
selector: sbt.testing.Selector,
status: sbt.testing.Status,
maybeThrowable: Option[Throwable],
duration: Long,
fingerprint: sbt.testing.Fingerprint
) extends sbt.testing.Event
object ZTestEvent {
def from[E](
executedSpec: zio.test.ExecutedSpec[E],
fullyQualifiedName: String,
fingerprint: sbt.testing.Fingerprint
): Seq[ZTestEvent]
}Communication system for handling test result transmission across different platforms, with serialization support for JavaScript and Native platforms.
type SendSummary = zio.URIO[zio.test.Summary, Unit]
object SendSummary {
def fromSend(send: zio.test.Summary => Unit): SendSummary
def fromSendM(send: zio.test.Summary => zio.UIO[Unit]): SendSummary
def noop: SendSummary
}
object SummaryProtocol {
def serialize(summary: zio.test.Summary): String
def deserialize(s: String): Option[zio.test.Summary]
}// Type alias for summary transmission
type SendSummary = zio.URIO[zio.test.Summary, Unit]
// Fingerprint for ZIO test discovery
object RunnableSpecFingerprint extends sbt.testing.SubclassFingerprint {
def superclassName(): String
def isModule(): Boolean
def requireNoArgConstructor(): Boolean
}
// Task execution policy interface
abstract class ZTestTaskPolicy {
def merge(zioTasks: Array[ZTestTask]): Array[sbt.testing.Task]
}
// Default task policy implementation
class ZTestTaskPolicyDefaultImpl extends ZTestTaskPolicy {
def merge(zioTasks: Array[ZTestTask]): Array[sbt.testing.Task]
}