Added UC12Test

This commit is contained in:
stargateprovider 2021-12-07 11:24:02 +02:00
parent fc3161be51
commit 6bb9638418
3 changed files with 82 additions and 25 deletions

View File

@ -0,0 +1,30 @@
package com.tarkvaraprojekt.mobileauthapp
//import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.espresso.IdlingPolicies
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.junit.*
import org.junit.runner.RunWith
import java.util.concurrent.TimeUnit
@RunWith(AndroidJUnit4::class)
open class BaseUCTest {
@get:Rule
var activityActivityTestRule: ActivityTestRule<MainActivity> = ActivityTestRule(
MainActivity::class.java
)
@Before
fun setUp() {
IdlingPolicies.setMasterPolicyTimeout(3, TimeUnit.SECONDS)
IdlingPolicies.setIdlingResourceTimeout(3, TimeUnit.SECONDS)
activityActivityTestRule.activity
.supportFragmentManager.beginTransaction()
}
@After
fun tearDown() {
}
}

View File

@ -0,0 +1,50 @@
package com.tarkvaraprojekt.mobileauthapp
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import org.junit.*
class UC12Test : BaseUCTest() {
private fun navigateToPINView() {
onView(withId(R.id.menu_settings_option)).perform(click())
try {
// Delete existing PIN
onView(withText(R.string.pin1_delete)).perform(click())
} catch (ignore: NoMatchingViewException) {}
onView(withId(R.id.pin_menu_action)).perform(click())
}
@Test
fun validPIN() {
navigateToPINView()
onView(withText(R.string.pin_helper_text)).check(matches(isDisplayed()))
onView(supportsInputMethods()).perform(typeText("0000"))
onView(withText(R.string.continue_button)).perform(click())
onView(withText(R.string.pin_status_saved)).check(matches(isDisplayed()))
}
@Test
fun tooShortPIN() {
navigateToPINView()
onView(supportsInputMethods()).perform(typeText("000"))
onView(withText(R.string.continue_button)).perform(click())
onView(withText(R.string.pin_helper_text)).check(matches(isDisplayed()))
}
@Test
fun tooLongPIN() {
navigateToPINView()
onView(supportsInputMethods()).perform(typeText("0".repeat(13)))
onView(withText(R.string.continue_button)).perform(click())
onView(withText(R.string.pin_helper_text)).check(matches(isDisplayed()))
}
}

View File

@ -1,39 +1,16 @@
package com.tarkvaraprojekt.mobileauthapp
//import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.IdlingPolicies
import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.junit.*
import org.junit.runner.RunWith
import java.util.concurrent.TimeUnit
@RunWith(AndroidJUnit4::class)
class UC4Test {
@get:Rule
var activityActivityTestRule: ActivityTestRule<MainActivity> = ActivityTestRule(
MainActivity::class.java
)
class UC4Test : BaseUCTest() {
@Before
fun setUp() {
IdlingPolicies.setMasterPolicyTimeout(3, TimeUnit.SECONDS)
IdlingPolicies.setIdlingResourceTimeout(3, TimeUnit.SECONDS)
activityActivityTestRule.activity
.supportFragmentManager.beginTransaction()
}
@After
fun tearDown() {
}
fun navigateToCANView() {
private fun navigateToCANView() {
onView(withId(R.id.menu_settings_option)).perform(click())
try {
// Delete existing CAN