title: Unit testing: where to track output results from TextView
body: <p>So i have this test Activity with 3 elements: TextView, EditText, Button. When user clicks button, Activity then transforms text from EditText to some text in TextView.</p>
  
  <p>Question is: how do i write unit test for such activity? </p>
  
  <p>My problem: i should "click" (.performClick) on a button in one thread, but to wait asynchronously in another but that breaks a logic of a unit test since it runs every test starting with "test" prefix and marks test as "Ok" if there were no unsuccessful assertions. </p>
  
  <p>Code of a unit test: </p>
  
  <pre><code>public class ProjectToTestActivityTest extends ActivityInstrumentationTestCase2&lt;ProjectToTestActivity&gt; {
  
      private TextView resultView;
      private EditText editInput;
      private Button   sortButton;
  
      public ProjectToTestActivityTest(String pkg, Class activityClass) {
          super("com.projet.to.test", ProjectToTestActivity.class);
      }
  
  public void onTextChanged(String str)
  {
      Assert.assertTrue(str.equalsIgnoreCase("1234567890"));
  }
  
  
         @Override  
         protected void setUp() throws Exception {  
             super.setUp();  
  
             Activity activity = getActivity();  
             resultView = (TextView) activity.findViewById(R.id.result);
             editInput = (EditText) activity.findViewById(R.id.editInput);
             sortButton = (Button) activity.findViewById(R.id.sortButton);
  
         resultView.addTextChangedListener(new TextWatcher() {
  
          public void afterTextChanged(Editable arg0) {
              onTextChanged(arg0.toString());
          }
             }
         }  
  
         protected void testSequenceInputAndSorting()
         {
             editInput.setText("1234567890");
             sortButton.performClick();   
         }
  }
  </code></pre>