winter-junit5 / io.jentz.winter.junit5 / ExtendGraphExtension

ExtendGraphExtension

class ExtendGraphExtension : GraphLifecycleExtension

JUnit5 extension 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:

@JvmField
@RegisterExtension
val extension = WinterJUnit5.extension("presentation") {
  singleton<ListPresenter>(override = true) { MockListPresenter() }
}

@Inject
lateinit var presenter: ListPresenter

@Before
fun beforeEach() {
  extension.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

afterEach

open fun afterEach(context: ExtensionContext): Unit

beforeEach

open fun beforeEach(context: ExtensionContext): Unit