0

For example a package being tested has a method:

package package.being.tested
....
public class MainActivity extends AppCompatActivity {
....
public Int myMehod(String s){
 <do something>
}

How to call this method in tests?

cur4so
  • 1,750
  • 4
  • 20
  • 28

1 Answers1

0

Exactly as you would call this method in a non-test class.

@Test
public void myMethodTest() {
    MainActivity mainActivity = new MainActivity();
    Integer i = mainActivity.myMethod("A string");
}
Val Bonn
  • 1,129
  • 1
  • 13
  • 31
  • actually it gives RuntimeException: "Can't create handler inside thread that has not called Looper.prepare()" – cur4so Oct 07 '16 at 19:58
  • I cannot help you for that. But perhaps will you be interested in http://stackoverflow.com/questions/6732529/cant-create-handler-looper-prepare-in-inherited-activity – Val Bonn Oct 07 '16 at 20:12