Reputation: 2179
I am testing a simple application. When i start JUnit testing, although i get test run finished, I am not getting any result. Pop up menu showing "Test Class not found". Could anyone fix this?
Stack trace :
junit.framework.AssertionFailedError: Class com.example.testbuild.test.second has no public constructor TestCase(String name) or TestCase() at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
package com.example.testbuild.test;
import junit.framework.Assert;
import android.app.Activity;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.Button;
import android.widget.TextView;
import com.example.testbuild.MainActivity;
public class second extends ActivityInstrumentationTestCase2<MainActivity> {
MainActivity a;
Button b;
TextView v;
public second(Class<MainActivity> activityClass) {
super(activityClass);
// TODO Auto-generated constructor stub
}
@Override
protected void setUp() throws Exception {
super.setUp();
a=getActivity();
b=(Button)a.findViewById(com.example.testbuild.R.id.button1);
v=(TextView)a.findViewById(com.example.testbuild.R.id.textView1);
}
public void clicking()
{
a.runOnUiThread(
new Runnable() {
public void run() {
b.performClick();
}
});
String s=v.getText().toString();
Assert.assertEquals("test passed", "Hello",s);
}
}
Upvotes: 0
Views: 1410
Reputation: 582
I believe the constructor will not pass any arguments. try:
public second(){
super(MainActivity.class);
}
Upvotes: 2