I want to create a test case and use the same test case several times but with different data, as shown below.
@RunWith(Parameterized.class)
public class ExampleInstrumentedTest extends TestCase {
private MainActivity ma = new MainActivity();
@Parameterized.Parameter(0)
public float expectedResult;
@Parameterized.Parameter(1)
public float firstNum;
@Parameterized.Parameter(2)
public float secondNum;
@Parameterized.Parameters(name = "{index}: testAdd {0} = ({1}+{2})")
public static Collection<Object[]> testData(){
Object[][] data = new Object[][]{ {6,2,4}, {7,4,3}};
return Arrays.asList(data);
}
@Test
public void testAdd() throws InterruptedException {
float result = firstNum + secondNum;
Assert.assertEquals(expectedResult, result, .1);
}
}
And this is the end result. enter image description here
The test did generate the test cases but the test cases suppose to be passed and not failed. The error was "java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()". I tried all the solution that is available but it still shows the same message.
Please kindly assist me with this proble.
Much appreciated
Aucun commentaire:
Enregistrer un commentaire