[ADD] Location Tests + ID at every XML file

This commit is contained in:
Robin Koedood
2021-01-05 10:58:33 +01:00
parent bcd9eb6378
commit d3cab8c70d
14 changed files with 57 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
package com.a1.nextlocation;
import androidx.test.espresso.contrib.RecyclerViewActions;
import androidx.test.rule.ActivityTestRule;
import com.a1.nextlocation.fragments.LocationFragment;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import static androidx.test.espresso.Espresso.*;
import static androidx.test.espresso.action.ViewActions.*;
import static androidx.test.espresso.assertion.ViewAssertions.*;
import static androidx.test.espresso.matcher.ViewMatchers.*;
public class LocationFragmentTest {
@Rule
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void clickBackButton() throws Exception{
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new LocationFragment()).commit();
onView(withId(R.id.locationBackButton)).perform(click());
onView(withId(R.id.homeFragment)).check(matches(isDisplayed()));
}
@Test
public void clickDetailButton() throws Exception{
mActivityTestRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.mainActivity, new LocationFragment()).commit();
onView(withId(R.id.locationRecyclerView)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
onView(withId(R.id.locationDetailFragment)).check(matches(isDisplayed()));
}
}