CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-dev-zio--zio-test-sbt-3

ZIO Test SBT Framework integration that provides test interface implementation for running ZIO-based tests within SBT build environments

Pending
Overview
Eval results
Files

framework-integration.mddocs/

Framework Integration

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.

Capabilities

ZTestFramework

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 results

Platform-Specific Runner Creation

The 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): ZTestRunnerJVM

JavaScript 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
): Runner

Native 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
): Runner

Framework Properties

The 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.

Integration Flow

  1. Discovery: SBT loads ZTestFramework class from classpath
  2. Registration: Framework registers ZioSpecFingerprint for test discovery
  3. Runner Creation: Framework creates platform-appropriate runner instance
  4. Execution: Runner handles test discovery, execution, and result reporting

The 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

docs

event-handling.md

framework-integration.md

index.md

js-platform.md

jvm-platform.md

native-platform.md

test-discovery.md

tile.json