dependencies {
// other dependencies
testImplementation 'com.squareup.assertj:assertj-android:x.x.x'
}
import org.junit.Test;
import androidx.test.rule.ActivityTestRule;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.squareup.assertj.android.api.Assertions.assertThat;
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> activityTestRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void testMainActivityTitle() {
onView(withText("Hello, World!")).check(matches(isDisplayed()));
assertThat(activityTestRule.getActivity()).hasTitle("My App");
}
}
dependencies {
// other dependencies
testImplementation 'com.squareup.assertj:assertj-android:x.x.x'
}
import org.junit.Test;
import androidx.test.rule.ActivityTestRule;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.squareup.assertj.android.api.Assertions.assertThat;
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> activityTestRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void testMainActivityTitle() {
onView(withText("Hello, World!")).check(matches(isDisplayed()));
assertThat(activityTestRule.getActivity()).hasTitle("My App");
}
}