Advertisement
eveeeeef21

Error Importing closeSoftKeyboard

Jan 20th, 2024 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.78 KB | Source Code | 0 0
  1. package com.example.myunittest.ui
  2.  
  3. import com.example.myunittest.R
  4. import androidx.test.core.app.ActivityScenario
  5. import androidx.test.espresso.*
  6. import androidx.test.espresso.Espresso.*
  7. import androidx.test.espresso.action.*
  8. import androidx.test.espresso.action.ViewActions.*
  9. import androidx.test.espresso.matcher.ViewMatchers.*
  10. import androidx.test.espresso.assertion.ViewAssertions.*
  11. import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
  12. import org.junit.Assert.*
  13. import org.junit.*
  14. import org.junit.runner.*
  15.  
  16. @RunWith(AndroidJUnit4ClassRunner::class)
  17. class MainActivityTest {
  18.     private val dummyVolume = "504.0"
  19.     private val dummyCircumference = "100.0"
  20.     private val dummySurfaceArea = "396.0"
  21.     private val dummyLength = "12.0"
  22.     private val dummyWidth = "7.0"
  23.     private val dummyHeight = "6.0"
  24.     private val emptyInput = ""
  25.     private val fieldEmpty = "Field ini tidak boleh kosong"
  26.     @Before
  27.     fun setup(){
  28.         ActivityScenario.launch(MainActivity::class.java)
  29.     }
  30.  
  31.     @Test
  32.     fun assertGetCircumference() {
  33.         onView(withId(R.id.edt_length)).perform(typeText(dummyLength), closeSoftKeyboard())
  34.         onView(withId(R.id.edt_width)).perform(typeText(dummyWidth), closeSoftKeyboard())
  35.         onView(withId(R.id.edt_height)).perform(typeText(dummyHeight), closeSoftKeyboard())
  36.         onView(withId(R.id.btn_save)).check(matches(isDisplayed()))
  37.         onView(withId(R.id.btn_save)).perform(click())
  38.         onView(withId(R.id.btn_calculate_circumference)).check(matches(isDisplayed()))
  39.         onView(withId(R.id.btn_calculate_circumference)).perform(click())
  40.         onView(withId(R.id.tv_result)).check(matches(isDisplayed()))
  41.         onView(withId(R.id.tv_result)).check(matches(withText(dummyCircumference)))
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement