This commit is contained in:
stargateprovider 2021-12-04 14:28:52 +02:00
parent 339fa0a378
commit 73b94adcd3
2 changed files with 52 additions and 0 deletions

View File

@ -44,7 +44,9 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
debugImplementation 'androidx.fragment:fragment-testing:1.4.0'
//To use activityViewModels
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

View File

@ -0,0 +1,50 @@
package com.tarkvaraprojekt.mobileauthapp
import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.lifecycle.Lifecycle
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.IdlingPolicies
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.*
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.not
import org.junit.Assert.*
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
)
@Before
fun setUp() {
IdlingPolicies.setMasterPolicyTimeout(1, TimeUnit.SECONDS)
IdlingPolicies.setIdlingResourceTimeout(1, TimeUnit.SECONDS)
activityActivityTestRule.activity
.supportFragmentManager.beginTransaction()
}
@After
fun tearDown() {
}
@Test
fun test() {
onView(withId(R.id.menu_settings_option)).perform(click())
onView(withId(R.id.can_menu_action)).perform(click())
onView(supportsInputMethods()).perform(typeText("123456"))
onView(withId(R.id.next_button)).perform(click())
onView(withText(R.string.can_status_saved)).inRoot(
withDecorView(not(`is`(activityActivityTestRule.activity.getWindow().getDecorView())))
).check(matches(isDisplayed()))
}
}