opaluchlukasz / junit2spock

JUnit test to Spock test converter
MIT License
15 stars 7 forks source link

Junit to Spock Conversion failure. #1

Open ushsamsan opened 6 years ago

ushsamsan commented 6 years ago

Hi,

I am trying to convert my Junit test to Spock using junit2spock, but it fails with the following error.

16:09:59.215 [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@17d99928: startup date [Thu Jan 18 16:09:59 PST 2018]; root of context hierarchy Exception in thread "main" java.lang.ClassCastException at org.eclipse.jdt.core.dom.ASTNode.checkNewChild(ASTNode.java:2096) at org.eclipse.jdt.core.dom.ASTNode$NodeList.add(ASTNode.java:1417) at com.github.opaluchlukasz.junit2spock.core.Applicable.applyFeaturesToStatements(Applicable.java:36) at java.util.Optional.ifPresent(Optional.java:159) at com.github.opaluchlukasz.junit2spock.core.node.wrapper.TryStatementWrapper.<init>(TryStatementWrapper.java:35) at com.github.opaluchlukasz.junit2spock.core.node.wrapper.WrapperDecorator.wrap(WrapperDecorator.java:17) at com.github.opaluchlukasz.junit2spock.core.model.method.MethodModel.lambda$new$3(MethodModel.java:34) at java.lang.Iterable.forEach(Iterable.java:75) at com.github.opaluchlukasz.junit2spock.core.model.method.MethodModel.<init>(MethodModel.java:34) at com.github.opaluchlukasz.junit2spock.core.model.method.TestMethodModel.<init>(TestMethodModel.java:26) at com.github.opaluchlukasz.junit2spock.core.model.method.MethodModelFactory.get(MethodModelFactory.java:23) at com.github.opaluchlukasz.junit2spock.core.visitor.TypeVisitor.visit(TypeVisitor.java:69) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:611) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782) at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:470) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782) at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:212) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711) at com.github.opaluchlukasz.junit2spock.core.Spocker.toGroovyTypeModel(Spocker.java:49) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1380) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at com.github.opaluchlukasz.junit2spock.App.main(App.java:51) Do you have any fix for this? Thank you, ushsamsan.

opaluchlukasz commented 6 years ago

Nothing comes to mind, but if you are willing to share test file at which it failed, I would take a look.