ZIO Test SBT Framework integration that provides test interface implementation for running ZIO-based tests within SBT build environments
—
Core SBT framework implementation that enables ZIO Test to be recognized and executed by SBT. This provides the primary entry point for test discovery and execution across all supported platforms.
The main framework class that implements SBT's Framework interface, serving as the entry point for ZIO Test integration.
/**
* Main SBT framework implementation for ZIO Test integration
* Provides framework identification, test discovery, and runner creation
*/
final class ZTestFramework extends Framework {
/** Framework display name with ANSI formatting */
val name: String
/** Array of fingerprints for test discovery, contains ZioSpecFingerprint */
val fingerprints: Array[Fingerprint]
/**
* Creates a test runner for the specified platform
* @param args Test execution arguments
* @param remoteArgs Remote execution arguments
* @param testClassLoader ClassLoader for loading test classes
* @return Platform-specific test runner: ZTestRunnerJVM (JVM), ZMasterTestRunnerJS (JS), ZMasterTestRunner (Native)
*/
def runner(args: Array[String], remoteArgs: Array[String], testClassLoader: ClassLoader): Runner
/**
* Creates a slave runner for distributed execution (JS and Native platforms only)
* @param args Test execution arguments
* @param remoteArgs Remote execution arguments
* @param testClassLoader ClassLoader for loading test classes
* @param send Function for sending test summaries to master process
* @return Slave runner for distributed execution
*/
def slaveRunner(args: Array[String], remoteArgs: Array[String], testClassLoader: ClassLoader, send: String => Unit): Runner
}Usage Example:
// SBT automatically discovers and instantiates the framework
// In build.sbt:
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
// The framework is then used by SBT to:
// 1. Discover ZIO test specifications using ZioSpecFingerprint
// 2. Create appropriate runners for the target platform
// 3. Execute tests and report resultsThe framework creates different runners based on the target platform:
JVM Platform:
// Returns ZTestRunnerJVM for full-featured JVM execution
def runner(args: Array[String], remoteArgs: Array[String], testClassLoader: ClassLoader): ZTestRunnerJVMJavaScript Platform:
// Returns ZMasterTestRunnerJS for single-process execution
def runner(args: Array[String], remoteArgs: Array[String], testClassLoader: ClassLoader): Runner
/**
* Creates a slave runner for distributed JavaScript execution
* @param send Function for sending test summaries to master process
* @return ZSlaveTestRunnerJS for distributed execution
*/
def slaveRunner(
args: Array[String],
remoteArgs: Array[String],
testClassLoader: ClassLoader,
send: String => Unit
): RunnerNative Platform:
// Returns ZMasterTestRunner for single-process native execution
def runner(args: Array[String], remoteArgs: Array[String], testClassLoader: ClassLoader): Runner
/**
* Creates a slave runner for distributed native execution
* @param send Function for sending test summaries to master process
* @return ZSlaveTestRunner for distributed execution
*/
def slaveRunner(
args: Array[String],
remoteArgs: Array[String],
testClassLoader: ClassLoader,
send: String => Unit
): RunnerThe framework provides consistent identification across all platforms:
// Framework display name with ANSI underline formatting
val name: String = s"${Console.UNDERLINED}ZIO Test${Console.RESET}"
// Single fingerprint for discovering ZIOSpecAbstract implementations
val fingerprints: Array[Fingerprint] = Array(ZioSpecFingerprint)The framework name includes ANSI escape codes for enhanced display in terminal output, providing visual distinction in SBT's test framework listing.
ZTestFramework class from classpathZioSpecFingerprint for test discoveryThe framework abstraction allows ZIO Test to integrate seamlessly with SBT's testing infrastructure while maintaining platform-specific optimizations and capabilities.
Install with Tessl CLI
npx tessl i tessl/maven-dev-zio--zio-test-sbt-3