title: Converting UnitTest to Instrumentation Test in android studio
body: <p>So I started with a UnitTest called MyCoolObjectTest. Needing to do some instrumentation testing, I moved the class right within the <code>Android</code> project view from the <code>test</code> directory to the <code>androidTest</code> directory by dragging. My UnitTest used to work fine; except for the instrumentation portions. But now it does not work at all. I keep getting </p>
  
  <pre><code>Class not found: "com.mypkg.MyCoolObjectTest"Empty test suite.
  </code></pre>
  
  <p>I have been looking all over stackOverflow and at the official docs for a solution. No luck so far. Has anyone experienced something similar?</p>
  
  <p>(if I drag it back to the test folder it works; if I re-drag to the androidTest folder it stops working again)</p>
  
  <p>I remember the was a way to set the folder under test. But I no longer remember.</p>
  
  <p>For some insight, I want to use some android library in my test such as</p>
  
  <pre><code>public String stripFormatting(String input){
      return Html.fromHtml(input).toString();
  }
  </code></pre>
  
  <p>That's why I need instrumentation.</p>
  
  <p>Here is my unit test class with one test for an example:</p>
  
  <pre><code>@RunWith(AndroidJUnit4.class)
  public class MyCoolObjectTest {
      @Test
      public void testJustToKnow() {
          String actual = "&lt;b&gt;0&lt;/b&gt;";
          String expected = "0";
          assertThat(stripFormatting(actual), equalTo(expected));
      }
      public String stripFormatting(String input) {
          return Html.fromHtml(input).toString();
      }
  }
  </code></pre>
  
  <p><strong>update</strong></p>
  
  <p>Here is a different trace that I got. If I click on the method instead of the class, I get the following trace:</p>
  
  <p>Just now I clicked on the method instead of the whole class, and got the following trace:</p>
  
  <blockquote>
    <p>11/04 13:51:16: Launching testJustToKnow() $ adb push
    /Users/me/StudioProjects/Myapp/app/build/outputs/apk/app-debug.apk
    /data/local/tmp/com.mypkg.myapp $ adb shell pm install -r
    "/data/local/tmp/com.mypkg.myapp"     pkg:
    /data/local/tmp/com.mypkg.myapp Success</p>
    
    <p>$ adb push
    /Users/me/StudioProjects/Myapp/app/build/outputs/apk/app-debug-androidTest-unaligned.apk
    /data/local/tmp/com.mypkg.Myapp.test $ adb shell pm install -r
    "/data/local/tmp/com.mypkg.myapp.test"    pkg:
    /data/local/tmp/com.mypkg.myapp.test Success</p>
    
    <p>Running tests</p>
    
    <p>$ adb shell am instrument -w -r   -e debug false -e class
    com.mypkg.myapp.utils.MyCoolObjectTest#testJustToKnow
    com.mypkg.myapp.test/android.test.InstrumentationTestRunner Client not
    ready yet..Test running started</p>
    
    <p>junit.framework.AssertionFailedError: No tests found in
    com.mypkg.myapp.utils.MyCoolObjectTest at
    android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191) at
    android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176) at
    android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
    at
    android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1959)</p>
    
    <p>Tests ran to completion.</p>
  </blockquote>