winter-junit4 / io.jentz.winter.junit4 / ExtendGraphTestRule

ExtendGraphTestRule

class ExtendGraphTestRule : GraphLifecycleTestRule

Test rule that takes a component qualifier and a ComponentBuilderBlock and extends the Graph with componentQualifier by applying the ComponentBuilderBlock.

It also provides a reflection based inject method that injects into all property annotated with javax.inject.Inject by using the Graph with given componentQualifier.

Example:

@get:Rule
val rule = WinterJUnit4.rule("presentation") {
  singleton<ListPresenter>(override = true) { MockListPresenter() }
}

@Inject
lateinit var presenter: ListPresenter


@Before
fun beforeEach() {
  rule.inject(this)
}

Properties

graph

var graph: Graph?

Functions

graphDispose

fun graphDispose(graph: Graph): Unit

graphInitialized

fun graphInitialized(graph: Graph): Unit

graphInitializing

fun graphInitializing(parentGraph: Graph?, builder: ComponentBuilder): Unit

inject

fun inject(target: Any): Unit

Inherited Functions

apply

fun apply(base: Statement, description: Description): Statement