Marcell-Juhasz / secret-diary

0 stars 1 forks source link

make activity and views fields of StageTests #5

Closed RedJocker closed 2 years ago

RedJocker commented 2 years ago

Instead of declaring the activity and view for every test method you can make them fields with lazy initialization instead to avoid repetition of the code

...

val activity by lazy {
    activityController.setup().get()
}

val someView by lazy {
    activity.find<ViewClass>("someViewId")
}

...

these fields will only be instatiated when the field is used for the first time. JUnit re-instantiates fields for every test method.

Marcell-Juhasz commented 2 years ago

Done