Reputation: 121
I am learning Mockito, So I am new to Mockito. Can make mockito method parameterised? eg. I have one class (ABC.java) where I have few methods with @Test annotations like
@Test
public void addition() {
}
And I am invoking them through another Test class (testClass.java).
Result result = JUnitCore.runClasses(ABC.class);
for (Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
So I want to invoke an addition method with a parameter from the test class(testClass.java).
Upvotes: 1
Views: 213
Reputation: 131526
Mockito allows to mock class. Here you don't need to mock anything.
So I want to invoke an addition method with a parameter from the test class(testClass.java).
JUnitCore.runClasses()
run test classes passed as parameter. That doesn't provide a way to pass parameters to the test class methods.
So you should parameterize the addition()
test method from the test class itself by using @RunWith(Parameterized.class)
.
More information here.
Upvotes: 1