SBT test framework integration for ZIO Test that enables ZIO's functional testing framework to be executed within SBT builds
npx @tessl/cli install tessl/maven-dev-zio--zio-test-sbt-2-13@1.0.0ZIO Test SBT is a test framework integration that enables ZIO Test specifications to be executed by SBT. It provides cross-platform support for JVM, JavaScript, and Native environments, allowing ZIO's functional testing framework to integrate seamlessly with SBT's testing infrastructure.
build.sbt:
libraryDependencies += "dev.zio" %% "zio-test-sbt" % "1.0.18" % Testimport zio.test.sbt._For testing framework implementation:
import sbt.testing._
import zio.test.sbt.{ZTestFramework, ZTestRunner, SendSummary}ZIO Test SBT is primarily used by SBT internally for test execution. To enable it in your project:
build.sbttestFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")import zio.test._
object MySpec extends DefaultRunnableSpec {
def spec = suite("My Tests")(
test("example test") {
assert(1 + 1)(equalTo(2))
}
)
}ZIO Test SBT consists of several key components:
ZTestFramework implements SBT's Framework interface for test discoveryBaseTestTask and platform-specific implementations handle test executionZTestEvent reports test results back to SBTCore SBT test framework implementation that enables test discovery and execution.
class ZTestFramework extends Framework {
val name: String
val fingerprints: Array[Fingerprint]
def runner(args: Array[String], remoteArgs: Array[String], testClassLoader: ClassLoader): Runner
}Base task execution capabilities for running ZIO Test specifications within SBT.
abstract class BaseTestTask(
taskDef: TaskDef,
testClassLoader: ClassLoader,
sendSummary: SendSummary,
args: TestArgs
) extends Task {
def execute(eventHandler: EventHandler, loggers: Array[Logger]): Array[Task]
}Test event generation and reporting system for SBT integration.
case class ZTestEvent(
fullyQualifiedName: String,
selector: Selector,
status: Status,
maybeThrowable: Option[Throwable],
duration: Long,
fingerprint: Fingerprint
) extends EventPlatform-specific implementations for JVM, JavaScript, and Native environments.
// Platform-specific runners
class ZMasterTestRunner extends ZTestRunner
class ZSlaveTestRunner extends ZTestRunner
// Summary serialization for JS/Native
object SummaryProtocol {
def serialize(summary: Summary): String
def deserialize(s: String): Option[Summary]
}// Summary sending effect
type SendSummary = URIO[Summary, Unit]
// Task policy for merging tasks
abstract class ZTestTaskPolicy {
def merge(zioTasks: Array[ZTestTask]): Array[Task]
}
// Test discovery fingerprint
object RunnableSpecFingerprint extends SubclassFingerprint {
def superclassName(): String
def isModule(): Boolean
def requireNoArgConstructor(): Boolean
}JavaScript and Native platforms include additional types for distributed execution and serialization that are not available on the JVM platform.