or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cross-platform-execution.mdevent-handling.mdframework-integration.mdindex.mdjvm-execution.md
tile.json

framework-integration.mddocs/

Framework Integration

Core framework classes that integrate ZIO Test with SBT's test discovery and execution system. These classes implement the standard SBT test interface to enable SBT to recognize and execute ZIO test specifications.

Capabilities

ZTestFramework

Main framework entry point that SBT uses to recognize ZIO Test as a legitimate test framework.

/**
 * Main framework entry point for SBT integration
 * Implements sbt.testing.Framework interface
 */
class ZTestFramework extends Framework {
  /** Framework display name with ANSI formatting */
  val name: String = s"${Console.UNDERLINED}ZIO Test${Console.RESET}"
  
  /** Array of fingerprints for test discovery */
  val fingerprints: Array[Fingerprint] = Array(ZioSpecFingerprint)
  
  /** Creates appropriate platform-specific runner */
  def runner(
    args: Array[String], 
    remoteArgs: Array[String], 
    testClassLoader: ClassLoader
  ): Runner
}

The framework creates platform-specific runners:

  • JVM: Returns ZTestRunnerJVM for full-featured JVM execution
  • JavaScript: Returns ZMasterTestRunnerJS for browser/Node.js execution
  • Scala Native: Returns ZMasterTestRunner for native binary execution

Usage Example:

// Configured automatically in build.sbt
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")

ZioSpecFingerprint

Fingerprint that tells SBT how to discover ZIO test classes by identifying classes that extend ZIOSpecAbstract.

/**
 * Fingerprint for ZIO test discovery
 * Extends sbt.testing.SubclassFingerprint
 */
object ZioSpecFingerprint extends SubclassFingerprint {
  /** Returns the superclass name for test discovery */
  def superclassName(): String = classOf[ZIOSpecAbstract].getName
  
  /** Indicates tests are objects/modules, not classes */
  def isModule(): Boolean = true
  
  /** ZIO specs don't require no-arg constructors */
  def requireNoArgConstructor(): Boolean = false
}

This fingerprint enables SBT to automatically discover any Scala object that extends ZIOSpecAbstract, ZIOSpecDefault, or other ZIO test base classes.

Usage Example:

// This object will be discovered by SBT automatically
object MyTestSpec extends ZIOSpecDefault {
  def spec = suite("My Tests")(
    test("example") {
      assertTrue(true)
    }
  )
}

Framework Registration

The framework must be registered in your build configuration for SBT to use it.

SBT Configuration:

// build.sbt
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
libraryDependencies += "dev.zio" %% "zio-test-sbt" % "2.1.19" % Test

Mill Configuration:

// build.sc
def testFramework = Seq("zio.test.sbt.ZTestFramework")
def ivyDeps = Agg(ivy"dev.zio::zio-test-sbt:2.1.19")

Cross-Platform Framework Variations

The framework implementation varies slightly across platforms to support platform-specific features:

JavaScript Platform:

class ZTestFramework extends Framework {
  // Creates ZMasterTestRunnerJS for local execution
  def runner(
    args: Array[String],
    remoteArgs: Array[String],
    testClassLoader: ClassLoader
  ): ZMasterTestRunnerJS
  
  // Creates ZSlaveTestRunnerJS for distributed execution
  def slaveRunner(
    args: Array[String],
    remoteArgs: Array[String], 
    testClassLoader: ClassLoader,
    send: String => Unit
  ): ZSlaveTestRunnerJS
}

Scala Native Platform:

class ZTestFramework extends Framework {
  // Creates ZMasterTestRunner for local execution
  def runner(
    args: Array[String],
    remoteArgs: Array[String],
    testClassLoader: ClassLoader
  ): ZMasterTestRunner
  
  // Creates ZSlaveTestRunner for distributed execution  
  def slaveRunner(
    args: Array[String],
    remoteArgs: Array[String],
    testClassLoader: ClassLoader, 
    send: String => Unit
  ): ZSlaveTestRunner
}

The slave runner functionality enables running tests in separate processes or workers, which is particularly useful for JavaScript and Native platforms where memory isolation or parallelization across processes is beneficial.