I am using junit parameterized approach to do unit testing.
Initially I used to follow the normal parameterized approach to test my workflow[1]. [1] http://ift.tt/1eIwuCv
But later I found this document [2] which provides a better and concise approach to test using parameters. [2] http://ift.tt/1JJuNL9
However, I cannot figure out a way to pass mock objects to the test method.
@TestWith({
"null, mock(B.class),mock(C.class)",
"mock(A.class), null, mock(C.class)",
"mock(A.class), mock(B.class), null"
})
public void test_workflow(final A Aclass,final B Bclass,final C Cclass)
{
assertThat....
}
I am getting illegal argument exception:
java.lang.IllegalArgumentException: cannot interpret string "mock(B.class)" as a class B.class at com.googlecode.zohhak.internal.coercing.CoercingService.coerceParameter(CoercingService.java:58) at com.googlecode.zohhak.internal.coercing.CoercingService.coerceParameters(CoercingService.java:33) at com.googlecode.zohhak.internal.Executor.calculateParameters(Executor.java:28) at com.googlecode.zohhak.internal.junit.ParametrizedFrameworkMethod.invokeExplosively(ParametrizedFrameworkMethod.java:22)
Does anyone know how can I pass mock objects as parameters to the test method? It will be a great help, I will keep trying to figure it out on my end.
Aucun commentaire:
Enregistrer un commentaire