hatepoint / phrases-hyperskill-tests

0 stars 1 forks source link

write the name of @tests that you would like to have #8

Closed RedJocker closed 1 year ago

RedJocker commented 1 year ago

Make descriptive name for the @test you would like to have on StageUnitTest. I can help implementing either implementing them myself or just giving direction on how to implement it.

hatepoint commented 1 year ago

dafc1f313e50506ae89dac4b7cd7318b559181f5 - Stage4UnitTest has a test03_checkAddDialog. I would like to check that after clicking on the addButton the dialog shows up, some phrase could be typed in the EditText and then after clicking ok/positive button it's saved and shown Could you do that, please?

hatepoint commented 1 year ago

@RedJocker

RedJocker commented 1 year ago

ok

RedJocker commented 1 year ago

please provide stage4 task.html

RedJocker commented 1 year ago

I think you just need this to do what you want. Include this on AbstractUnitTests

/**
     * Use this method to find views.
     *
     * The view existence will be assert before being returned
     */
    inline fun <reified T> Dialog.findViewByString(idString: String): T {
        val id = this.context.resources.getIdentifier(idString, "id", context.packageName)
        val view: View? = this.findViewById(id)

        val idNotFoundMessage = "View with id \"$idString\" was not found"
        val wrongClassMessage = "View with id \"$idString\" is not from expected class. " +
                "Expected ${T::class.java.simpleName} found ${view?.javaClass?.simpleName}"

        assertNotNull(idNotFoundMessage, view)
        assertTrue(wrongClassMessage, view is T)

        return view as T
    }

then you can use this to find views on your dialogs custom layout on tests

RedJocker commented 1 year ago

I'm closing this, but you can re-open if you need