winter-testing / io.jentz.winter.testing / WinterTestSession

WinterTestSession

class WinterTestSession

WinterTestSession helps to write cleaner tests that require Winter by eliminating boilerplate code.

This is used by the Winter JUnit4 and JUnit5 modules but can also be used directly with other test frameworks.

Example:

class ExampleTest {

  private lateinit val session: WinterTestSession

  @Mock service: Service = mock()

  @Before fun setup() {
    session = WinterTestSession.session(this) {
      application = MyWinterApp
      bindAllMocks()
      testGraph("activity")
    }
    session.start()
  }

  @After fun teardown() {
    session.stop()
  }

}

See Also

WinterTestSession.Builder

Types

Builder

class Builder

Properties

allGraphs

val allGraphs: List<Graph>

A list of all graphs that where opened after calling start.

requireTestGraph

val requireTestGraph: Graph

The test graph.

testGraph

var testGraph: Graph?

The test graph if open otherwise null.

Functions

resolve

fun resolve(type: Class<*>, qualifier: Any? = null): Any

Resolve an instance of type with optional qualifier.

start

fun start(): Unit

Call this to start the session.

stop

fun stop(): Unit

Call this to stop the session.

Companion Object Functions

session

fun session(vararg testInstances: Any, block: WinterTestSessionBlock): WinterTestSession