cur4so cur4so - 2 months ago 7
Java Question

how to refer to a method, defined in a package being tested from a test

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?

Answer

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");
}