Why does my Android Unit Test runs twice?

Viewed 498

Here is the complete test class for my Kotlin unit tests:

package xyz.hitit.userapplication.unittests.fragmentUnitTests
import androidx.fragment.app.testing.FragmentScenario
import androidx.fragment.app.testing.launchFragmentInContainer
import org.junit.After
import org.junit.Before
import org.junit.Test
import xyz.hitit.userapplication.ui.registrationLogin.VerificationCodeFragment

class VerificationCodeFragmentUnitTests {
    var scenario: FragmentScenario<VerificationCodeFragment>? = null

    @Before
    fun setup() {
         scenario = launchFragmentInContainer<VerificationCodeFragment>()
    }

    @Test
    fun testHandleVerificationCodeResult2() {
        scenario?.onFragment { sut ->
            sut.didRun = false
            var menu = "NotAnEmailSearch"
            sut.handleVerificationCodeResult(menu = menu, userInputVerCode = "list2")
            assert(sut.didRun == true)
        }
    }

    @After
    fun tearDown() {
        scenario = null
    }
}

Whenever I run this test class testHandleVerificationCodeResult2() runs twice and the last one fails. Which process should I take to find the solution??

0 Answers
Related