You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2020/09/02 06:50:14 UTC

[GitHub] [fineract-cn-mobile] miPlodder commented on a change in pull request #112: Feat: Add UI/Integration tests for creating group, group list and group details

miPlodder commented on a change in pull request #112:
URL: https://github.com/apache/fineract-cn-mobile/pull/112#discussion_r481777487



##########
File path: app/src/androidTest/java/org/apache/fineract/ui/online/groups/creategroup/CreateGroupActivityAndroidTest.kt
##########
@@ -0,0 +1,87 @@
+package org.apache.fineract.ui.online.groups.creategroup
+
+import android.content.Intent
+import androidx.test.espresso.Espresso.onView
+import androidx.test.espresso.action.ViewActions.click
+import androidx.test.espresso.action.ViewActions.typeText
+import androidx.test.espresso.matcher.ViewMatchers.withId
+import androidx.test.espresso.matcher.ViewMatchers.withText
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.rule.ActivityTestRule
+import org.apache.fineract.R
+import org.apache.fineract.ui.online.groups.GroupAction
+import org.apache.fineract.utils.Constants
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Created by Ahmad Jawid Muhammadi on 30/8/20.
+ */
+
+@RunWith(AndroidJUnit4::class)
+class CreateGroupActivityAndroidTest {
+
+    @get:Rule
+    var activityTestRule =
+            ActivityTestRule<CreateGroupActivity>(CreateGroupActivity::class.java, false, false)
+
+    @Before
+    fun before() {
+        //Open CreateGroupActivity with an intent by putting  create group action as an extra
+        val intent = Intent().apply {
+            putExtra(Constants.GROUP_ACTION, GroupAction.CREATE)
+        }
+        activityTestRule.launchActivity(intent)
+    }
+
+    @Test
+    fun createGroupItem() {
+        onView(withId(R.id.etIdentifier))
+                .perform(typeText("testIdentifier"))
+        onView(withId(R.id.etGroupDefinitionIdentifier))
+                .perform(typeText("group definition"))
+        onView(withId(R.id.etName))
+                .perform(typeText("group name"))
+        onView(withId(R.id.etOffice))
+                .perform(typeText("office name"))
+        onView(withId(R.id.etAssignedEmployee))
+                .perform(typeText("assignedEmployee"))
+
+        //go to next fragment
+        onView(withText("NEXT")).perform(click())
+
+        //Add a member
+        onView(withId(R.id.ibAddMember))
+                .perform(click())
+        onView(withId(R.id.etNewMember))
+                .perform(typeText("Ahmad"))
+        onView(withId((R.id.btnAddMember)))
+                .perform(click())
+        onView(withText("NEXT")).perform(click())
+
+        //Add leader name
+        onView(withId(R.id.ibAddLeader))
+                .perform(click())
+        onView(withId(R.id.etNewLeader))
+                .perform(typeText("Jawid"))
+        onView(withId((R.id.btnAddLeader)))
+                .perform(click())
+        onView(withText("NEXT")).perform(click())
+
+        //fill address details
+        onView(withId(R.id.etStreet))
+                .perform(typeText("Street"))
+        onView(withId(R.id.etCity))
+                .perform(typeText("Pune"))
+        onView(withId(R.id.etRegion))
+                .perform(typeText("Region"))
+        onView(withId(R.id.etPostalCode))
+                .perform(typeText("411048"))
+        onView(withId(R.id.etCountry))
+                .perform(typeText("India"))
+        onView(withText("NEXT")).perform(click())
+        onView(withText("COMPLETE")).perform(click())

Review comment:
       I don't see any assertions here, lets add them, else there is no point (without assertions testing is of not use)

##########
File path: app/build.gradle
##########
@@ -71,6 +71,10 @@ android {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
+
+    kotlinOptions {
+        jvmTarget = JavaVersion.VERSION_1_8

Review comment:
       What do we need this for integration tests, please clarify?

##########
File path: app/src/androidTest/java/org/apache/fineract/ui/online/groups/creategroup/CreateGroupActivityAndroidTest.kt
##########
@@ -0,0 +1,87 @@
+package org.apache.fineract.ui.online.groups.creategroup
+
+import android.content.Intent
+import androidx.test.espresso.Espresso.onView
+import androidx.test.espresso.action.ViewActions.click
+import androidx.test.espresso.action.ViewActions.typeText
+import androidx.test.espresso.matcher.ViewMatchers.withId
+import androidx.test.espresso.matcher.ViewMatchers.withText
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.rule.ActivityTestRule
+import org.apache.fineract.R
+import org.apache.fineract.ui.online.groups.GroupAction
+import org.apache.fineract.utils.Constants
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Created by Ahmad Jawid Muhammadi on 30/8/20.
+ */
+
+@RunWith(AndroidJUnit4::class)
+class CreateGroupActivityAndroidTest {
+
+    @get:Rule
+    var activityTestRule =
+            ActivityTestRule<CreateGroupActivity>(CreateGroupActivity::class.java, false, false)
+
+    @Before
+    fun before() {
+        //Open CreateGroupActivity with an intent by putting  create group action as an extra
+        val intent = Intent().apply {
+            putExtra(Constants.GROUP_ACTION, GroupAction.CREATE)
+        }
+        activityTestRule.launchActivity(intent)
+    }
+
+    @Test
+    fun createGroupItem() {

Review comment:
       Let's follow a standard, test method names must begin with `test`. `testCreateGroupItem` in this case.
   
   Let's also create a negative case also for this flow, where group creation fails, based on improper data, can we check on this. For those cases, let's suffix the test method name with `_invalid<Something>`, where `Something is your invalid data field`

##########
File path: app/src/androidTest/java/org/apache/fineract/ui/online/groups/grouplist/GroupListFragmentAndroidTest.kt
##########
@@ -0,0 +1,54 @@
+package org.apache.fineract.ui.online.groups.grouplist
+
+import androidx.test.espresso.Espresso.onView
+import androidx.test.espresso.action.ViewActions.click
+import androidx.test.espresso.assertion.ViewAssertions.matches
+import androidx.test.espresso.contrib.DrawerActions
+import androidx.test.espresso.contrib.NavigationViewActions
+import androidx.test.espresso.contrib.RecyclerViewActions
+import androidx.test.espresso.matcher.ViewMatchers.*
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.rule.ActivityTestRule
+import org.apache.fineract.R
+import org.apache.fineract.ui.adapters.GroupsAdapter
+import org.apache.fineract.ui.online.DashboardActivity
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Created by Ahmad Jawid Muhammadi on 30/8/20.
+ */
+
+@RunWith(AndroidJUnit4::class)
+class GroupListFragmentAndroidTest {
+
+    @get:Rule
+    val activityRule =
+            ActivityTestRule<DashboardActivity>(DashboardActivity::class.java)
+
+    @Test
+    fun openDrawer_OpenGroupList_ClickOnRecyclerViewItem() {

Review comment:
       prefix test method name with `test`. Follow this convention.

##########
File path: app/build.gradle
##########
@@ -173,6 +177,9 @@ dependencies {
     androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
     androidTestImplementation "androidx.test:runner:$runnerVersion"
     androidTestImplementation "androidx.test:rules:$rulesVersion"
+    androidTestImplementation "androidx.test.ext:junit:$extJunit"
+    androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCore"

Review comment:
       Do we need all these dependencies, please clarify




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org