title: Android Espresso - assert text on screen against string in resources
body: <p>I have the following text in strings.xml resources file:  </p>
  
  <pre><code>&lt;string name="txt_to_assert"&gt;My Text&lt;/string&gt;
  </code></pre>
  
  <p>Normally in a application code, to use this text and display it on screen, I'm doing the following:</p>
  
  <pre><code>getString(R.string.main_ent_mil_new_mileage);
  </code></pre>
  
  <p>At the moment, I'm trying to use this string resource in a UI test written with Espresso. I'm thinking of doing something like that:</p>
  
  <pre><code>String myTextFromResources = getString(R.string.main_ent_mil_new_mileage);
  onView(allOf(withId(R.id.my_text_on_screen), withText(myTextFromResources))
      .check(matches(isDisplayed()));
  </code></pre>
  
  <p>However, <code>getString(...)</code> method cannot be used here.<br>
  Is there a way to get a text from strings.xml resource file and use it in a test written with Espresso?</p>