0

Am trying call a method from another class which is present in different files.

Main File :

public class Test extends AndroidTestCase {
    mTestUtils = new TestUtils(this, TAG, OUTPUT_FILE);

Second File :

public class TestUtils {
    public TestUtils(Context context, String tag, String outputFile) {

        mContext = context;
        mTag = tag;
        mOutputFile = outputFile;
    }
}

It throws Constructor undefined error. Any help would be appreciated.

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
taz
  • 76
  • 8

2 Answers2

5

you are doing

TestUtils(this, TAG, OUTPUT_FILE);

but this is not a context in that case.

the method getContext() will provide you that, just look the doc

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
0

the signature of TestUtils constructor takes object of type Context and when you do this in Test class

new TestUtils(this, TAG, OUTPUT_FILE);

you're not passing Context object

instead of this you should pass Context object

checkout this question

Ali Faris
  • 17,754
  • 10
  • 45
  • 70