ttt307307 / junitparams

Automatically exported from code.google.com/p/junitparams
0 stars 0 forks source link

ClassCastException in ParameterisedTestMethodRunner #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I get the below stacktrace when using a test which contains a JMock 
JunitRuleMockery.  I think the issue is on line 89 of 
ParameterisedTestMethodRunner, I think the assignable check is the wrong way 
around.  It should be checking whether Statement is a superclass of 
field.getType(), but instead it's checking whether field.getType() is a 
superclass of Statement.  In this case field.getType() is java.lang.Object so 
that's always going to return true.

java.lang.ClassCastException: a.b.c.MyTest cannot be cast to 
org.junit.runners.model.Statement
    at junitparams.internal.ParameterisedTestMethodRunner.getOriginalStatement(ParameterisedTestMethodRunner.java:98)
    at junitparams.internal.ParameterisedTestMethodRunner.statementOrNull(ParameterisedTestMethodRunner.java:90)
    at junitparams.internal.ParameterisedTestMethodRunner.nextChainedInvoker(ParameterisedTestMethodRunner.java:80)
    at junitparams.internal.ParameterisedTestMethodRunner.findParameterisedMethodInvokerInChain(ParameterisedTestMethodRunner.java:68)
    at junitparams.internal.ParameterisedTestMethodRunner.findChildForParams(ParameterisedTestMethodRunner.java:58)
    at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:39)
    at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:143)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:405)
    at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:383)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Original issue reported on code.google.com by fac...@gmail.com on 16 Jul 2013 at 4:56

GoogleCodeExporter commented 8 years ago
Please provide some sample code.

Original comment by lipinski...@gmail.com on 26 Oct 2013 at 4:10

GoogleCodeExporter commented 8 years ago
Ok, seems like you're right. Fixed, to be released with 1.0.3.

Original comment by lipinski...@gmail.com on 26 Oct 2013 at 5:17

GoogleCodeExporter commented 8 years ago
Is 1.0.3 ever going to be released?

Original comment by el...@elnur.me on 15 Jun 2014 at 1:27

GoogleCodeExporter commented 8 years ago
will it be released?

Original comment by lstachow...@lstachowiak.pl on 25 Jul 2014 at 4:18