Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
6002CEM_8918189/app/src/androidTest/java/com/example/booksharing21/MainActivityExpress.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
66 lines (45 sloc)
2.23 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.booksharing21; | |
import static androidx.test.espresso.Espresso.onView; | |
import static androidx.test.espresso.action.ViewActions.click; | |
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; | |
import static androidx.test.espresso.action.ViewActions.typeText; | |
import static androidx.test.espresso.assertion.ViewAssertions.matches; | |
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; | |
import static androidx.test.espresso.matcher.ViewMatchers.withId; | |
import androidx.test.ext.junit.rules.ActivityScenarioRule; | |
import androidx.test.ext.junit.runners.AndroidJUnit4; | |
import androidx.test.filters.SmallTest; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
@RunWith(AndroidJUnit4.class) | |
@SmallTest | |
public class MainActivityExpress { | |
private static final String VALID_Email = "john.doe@outlook.com"; | |
private static final String VALID_Password = "1234john"; | |
@Rule | |
public ActivityScenarioRule<MainActivity> activityRule = | |
new ActivityScenarioRule<>(MainActivity.class); | |
// android developers https://developer.android.com/training/testing/espresso/basics | |
// checking users credentials | |
@Test | |
public void ValidCredentials() { | |
onView(withId(R.id.email)).perform(typeText(VALID_Email), closeSoftKeyboard()); | |
onView(withId(R.id.password)).perform(typeText(VALID_Password),closeSoftKeyboard()); } | |
@Test | |
public void WrongEmail(){ | |
onView(withId(R.id.email)).perform(typeText("john"),closeSoftKeyboard()); | |
onView(withId(R.id.password)).perform(typeText(VALID_Password),closeSoftKeyboard()); } | |
@Test | |
public void WrongPassword(){ | |
onView(withId(R.id.email)).perform(typeText(VALID_Email),closeSoftKeyboard()); | |
onView(withId(R.id.password)).perform(typeText("doe"),closeSoftKeyboard()); } | |
@Test | |
public void NoCredentials(){ | |
onView(withId(R.id.email)).perform(typeText(""),closeSoftKeyboard()); | |
onView(withId(R.id.password)).perform(typeText(""),closeSoftKeyboard()); } | |
@Test | |
public void RegButton(){ onView(withId(R.id.reg)).perform(click()); } | |
@Test | |
public void logButton(){ onView(withId(R.id.log)).perform(click()).check(matches(isDisplayed())); } | |
} |