<commit_before>package com.elpassion.android.commons.espresso

import android.os.Bundle
import android.support.test.rule.ActivityTestRule
import android.widget.Button
import android.widget.FrameLayout
import org.junit.Rule
import org.junit.Test

class HasChildWithTextAssertionsTest {

    @JvmField @Rule
    val activityRule = ActivityTestRule(Activity::class.java)

    @Test
    fun shouldConfirmHasChildWithText() {
        onId(anId).hasChildWithText(firstText)
    }

    @Test
    fun shouldConfirmHasChildWithTextRes() {
        onId(anId).hasChildWithText(secondTextRes)
    }

    @Test
    fun shouldConfirmDoesNotHaveChildWithText() {
        onId(anId).doesNotHaveChildWithText("not existing text")
    }

    @Test
    fun shouldConfirmDoesNotHaveChildWithTextRes() {
        onId(anId).doesNotHaveChildWithText(123)
    }

    class Activity : android.app.Activity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(FrameLayout(this).apply {
                id = anId
                addView(Button(this.context).apply {
                    text = firstText
                })
                addView(Button(this.context).apply {
                    setText(secondTextRes)
                })
            })
        }
    }

    companion object {
        private val anId = 124
        private val firstText = "text"
        private val secondTextRes = R.string.app_name
    }
}<commit_msg>Add fail case test to HasChildWithTextAssertionsTest<commit_after>package com.elpassion.android.commons.espresso

import android.os.Bundle
import android.support.test.rule.ActivityTestRule
import android.widget.Button
import android.widget.FrameLayout
import com.elpassion.android.commons.espresso.test.R
import org.junit.Rule
import org.junit.Test

class HasChildWithTextAssertionsTest {

    @JvmField @Rule
    val activityRule = ActivityTestRule(Activity::class.java)

    @Test
    fun shouldConfirmHasChildWithText() {
        onId(anId).hasChildWithText(firstText)
    }

    @Test(expected = AssertionError::class)
    fun shouldFailConfirmHasChildWithText() {
        onText(firstText).hasChildWithText(firstText)
    }

    @Test
    fun shouldConfirmHasChildWithTextRes() {
        onId(anId).hasChildWithText(secondTextRes)
    }

    @Test(expected = AssertionError::class)
    fun shouldFailConfirmHasChildWithTextRes() {
        onText(secondTextRes).hasChildWithText(secondTextRes)
    }

    @Test
    fun shouldConfirmDoesNotHaveChildWithText() {
        onId(anId).doesNotHaveChildWithText("not existing text")
    }

    @Test(expected = AssertionError::class)
    fun shouldFailConfirmDoesNotHaveChildWithText() {
        onId(anId).doesNotHaveChildWithText(firstText)
    }

    @Test
    fun shouldConfirmDoesNotHaveChildWithTextRes() {
        onId(anId).doesNotHaveChildWithText(R.string.non_existing)
    }

    @Test(expected = AssertionError::class)
    fun shouldFailConfirmDoesNotHaveChildWithTextRes() {
        onId(anId).doesNotHaveChildWithText(secondTextRes)
    }

    class Activity : android.app.Activity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(FrameLayout(this).apply {
                id = anId
                addView(Button(this.context).apply {
                    text = firstText
                })
                addView(Button(this.context).apply {
                    setText(secondTextRes)
                })
            })
        }
    }

    companion object {
        private val anId = R.id.first
        private val firstText = "text"
        private val secondTextRes = R.string.existing
    }
}
{'fraction_non_alphanumeric': 0.08544726301735647, 'fraction_numerical': 0.0016021361815754338, 'mean_word_length': 2.687007874015748, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2659513', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1038, 'n_words': 165}