<commit_before>package com.mirhoseini.weatherapp;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.mirhoseini.weatherapp.ui.activity.MainActivity;

import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.clearText;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * Created by Mohsen on 5/10/16.
 */
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MainActivityEspressoTest {

    @Rule
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
            MainActivity.class);

    @Test
    public void stage1_testUiDisplayedCorrectly() {
        onView(withId(R.id.city)).check(matches(isDisplayed()));
        onView(withId(R.id.go)).check(matches(isDisplayed()));
    }

    @Test
    public void stage2_testUiFunctionality() {
        testWeatherResultForCity("Tehran");
        testWeatherResultForCity("Berlin");
    }

    private void testWeatherResultForCity(String cityName) {
        onView(withId(R.id.city)).perform(clearText());
        onView(withId(R.id.city)).perform(typeText(cityName));
        onView(withId(R.id.go)).perform(click());
        onView(withId(R.id.name)).check(matches(withText(cityName)));
    }
}
<commit_msg>fixed ui espresso test<commit_after>package com.mirhoseini.weatherapp;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.mirhoseini.weatherapp.ui.activity.MainActivity;

import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.clearText;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.replaceText;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * Created by Mohsen on 5/10/16.
 */
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MainActivityEspressoTest {

    @Rule
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
            MainActivity.class);

    @Test
    public void stage1_testUiDisplayedCorrectly() {
        onView(withId(R.id.city)).check(matches(isDisplayed()));
        onView(withId(R.id.go)).check(matches(isDisplayed()));
    }

    @Test
    public void stage2_testUiFunctionality() {
        testWeatherResultForCity("Tehran");
        testWeatherResultForCity("Berlin");
    }

    private void testWeatherResultForCity(String cityName) {
        onView(withId(R.id.city)).perform(replaceText(cityName));
        onView(withId(R.id.go)).perform(click());
        onView(withId(R.id.name)).check(matches(withText(cityName)));
    }
}

{'fraction_non_alphanumeric': 0.11600625651720542, 'fraction_numerical': 0.0046923879040667365, 'mean_word_length': 5.023547880690738, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4157205', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1215, 'n_words': 163}