arquillian / arquillian-testrunner-spock

Arquillian Spock TestRunner
Apache License 2.0
30 stars 20 forks source link

Could not obtain SpecInfo from Sputnik Runner #24

Closed kriegaex closed 8 years ago

kriegaex commented 8 years ago

In order to log feature method names ("test method names") I added this JUnit rule to our code base:

package de.xx.yy.test

import org.junit.rules.TestWatcher
import org.junit.runner.Description

import java.text.SimpleDateFormat

class TestMethodLogger extends TestWatcher {
  public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS")

  @Override
  protected void starting(Description description) {
    printf "%s Starting test method: %s.%s%n", DATE_FORMAT.format(new Date()), description.className, description.methodName
  }

  @Override
  protected void finished(Description description) {
    printf "%s Finished test method: %s.%s%n", DATE_FORMAT.format(new Date()), description.className, description.methodName
  }
}
package de.xx.yy.test

import org.junit.Rule
import spock.lang.Specification

public abstract class OurSpockSpec extends Specification {
  @Rule
  public TestMethodLogger testMethodLogger = new TestMethodLogger();
}

I made all our unit tests inherit from OurSpockSpec and everything runs just fine.

Now I did a similar thing for our Geb Tests which are executed in a WildFly server via Arquillian Spock Runner:

package de.xx.yy.zz.geb.frame

import de.xx.yy.test.TestMethodLogger
import geb.spock.GebReportingSpec
import org.junit.Rule

class OurGebSpec extends GebReportingSpec {
    @Rule
    public TestMethodLogger testMethodLogger = new TestMethodLogger();

    // Other stuff
}

Now our Geb tests inherit from OurGebSpec (which they have done before anyway because other common methods are defined there) and the tests run fine locally from IntelliJ IDEA as well as Maven. But the very same Maven tests fail on our Jenkins integration server with the following error:

2015-12-16 11:09:50,484 Starting test method: de.xx.yy.aa.bb.wrapper.SomeIT.ourFeatureMethod
2015-12-16 11:09:50,690 Finished test method: de.xx.yy.aa.bb.wrapper.SomeIT.ourFeatureMethod
2015-12-16 11:09:50,725 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017535: Unregistered web context: /dd.yy.aa.bb.wildfly-2.23.0-SNAPSHOT
2015-12-16 11:09:50,739 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016009: Stopping weld service for deployment dd.yy.aa.bb.wildfly-2.23.0-SNAPSHOT.war
2015-12-16 11:09:50,741 ERROR [stderr] (xnio-file-watcher[Watcher for /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/tmp/vfs/temp/temp3b1837a5c69b4110/content-94325ac151e4d3c2/]-0) Exception in thread "xnio-file-watcher[Watcher for /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/tmp/vfs/temp/temp3b1837a5c69b4110/content-94325ac151e4d3c2/]-0" java.nio.file.ClosedWatchServiceException
2015-12-16 11:09:50,741 ERROR [stderr] (xnio-file-watcher[Watcher for /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/tmp/vfs/temp/temp3b1837a5c69b4110/content-94325ac151e4d3c2/]-0)  at sun.nio.fs.AbstractWatchService.checkOpen(AbstractWatchService.java:80)
2015-12-16 11:09:50,742 ERROR [stderr] (xnio-file-watcher[Watcher for /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/tmp/vfs/temp/temp3b1837a5c69b4110/content-94325ac151e4d3c2/]-0)  at sun.nio.fs.AbstractWatchService.checkKey(AbstractWatchService.java:92)
2015-12-16 11:09:50,742 ERROR [stderr] (xnio-file-watcher[Watcher for /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/tmp/vfs/temp/temp3b1837a5c69b4110/content-94325ac151e4d3c2/]-0)  at sun.nio.fs.AbstractWatchService.take(AbstractWatchService.java:119)
2015-12-16 11:09:50,742 ERROR [stderr] (xnio-file-watcher[Watcher for /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/tmp/vfs/temp/temp3b1837a5c69b4110/content-94325ac151e4d3c2/]-0)  at org.xnio.nio.WatchServiceFileSystemWatcher.run(WatchServiceFileSystemWatcher.java:85)
2015-12-16 11:09:50,742 ERROR [stderr] (xnio-file-watcher[Watcher for /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/tmp/vfs/temp/temp3b1837a5c69b4110/content-94325ac151e4d3c2/]-0)  at java.lang.Thread.run(Thread.java:745)
2015-12-16 11:09:50,815 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment dd.yy.aa.bb.wildfly-2.23.0-SNAPSHOT.war (runtime-name: dd.yy.aa.bb.wildfly-2.23.0-SNAPSHOT.war) in 94ms
2015-12-16 11:09:50,848 INFO  [org.jboss.as.repository] (management-handler-thread - 1) JBAS014901: Content removed from location /opt/.jenkins/jobs/OurJenkinsJob/workspace/server/wildfly-8.2.1.Final/standalone/data/content/bd/c40e6b1044408a5cde37ff69100f0ba7112163/content
2015-12-16 11:09:50,848 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018558: Undeployed "dd.yy.aa.bb.wildfly-2.23.0-SNAPSHOT.war" (runtime-name: "dd.yy.aa.bb.wildfly-2.23.0-SNAPSHOT.war")
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 32.187 sec <<< FAILURE! - in de.xx.yy.aa.bb.wrapper.SomeIT
ourFeatureMethod(de.xx.yy.aa.bb.wrapper.SomeIT)  Time elapsed: 0.236 sec  <<< ERROR!
java.lang.RuntimeException: Could not obtain SpecInfo from Sputnik Runner
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.obtainCurrentSpecification(SpockSpecificationFilter.java:78)
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.<init>(SpockSpecificationFilter.java:48)
    at org.jboss.arquillian.spock.container.SpockTestRunner.execute(SpockTestRunner.java:61)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:171)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:137)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException: null
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.obtainCurrentSpecification(SpockSpecificationFilter.java:74)
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.<init>(SpockSpecificationFilter.java:48)
    at org.jboss.arquillian.spock.container.SpockTestRunner.execute(SpockTestRunner.java:61)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:171)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:137)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: org.junit.runner.Description.createTestDescription(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/annotation/Annotation;)Lorg/junit/runner/Description;
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.obtainCurrentSpecification(SpockSpecificationFilter.java:74)
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.<init>(SpockSpecificationFilter.java:48)
    at org.jboss.arquillian.spock.container.SpockTestRunner.execute(SpockTestRunner.java:61)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:171)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:137)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

As you can see, the method logging for this failing test as such works as can be seen at the very beginning of the log:

2015-12-16 11:09:50,484 Starting test method: de.xx.yy.aa.bb.wrapper.SomeIT.ourFeatureMethod
2015-12-16 11:09:50,690 Finished test method: de.xx.yy.aa.bb.wrapper.SomeIT.ourFeatureMethod

But then we have this problem (Spock 0.7-groovy-2.0, Groovy 2.4.1, by the way):

Caused by: java.lang.NoSuchMethodError: org.junit.runner.Description.createTestDescription(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/annotation/Annotation;)Lorg/junit/runner/Description;
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.obtainCurrentSpecification(SpockSpecificationFilter.java:74)
    at org.jboss.arquillian.spock.container.SpockSpecificationFilter.<init>(SpockSpecificationFilter.java:48)
    at org.jboss.arquillian.spock.container.SpockTestRunner.execute(SpockTestRunner.java:61)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:171)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:137)
    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:98)

Any ideas?

bartoszmajsak commented 8 years ago

Thanks for the detailed report :) Seems that I am going to have plenty of work to do during Christmas, not only eating and spending time with family.

I will try hard to wrap all of it up before new year!

kriegaex commented 8 years ago

The road to hell is paved with good intentions, they say... ;-)

bartoszmajsak commented 8 years ago

That was quite heavy joke ;)

kriegaex commented 8 years ago

If you have ever tried to renounce chocolate or start doing more sports, you know what I mean.

bartoszmajsak commented 8 years ago

Sure, or reduce beer etc.

In general New Years resolutions ;)

kriegaex commented 8 years ago

I just found out by means of Maven Enforcer Plugin that conflicting JUnit versions from a BOM and our own project were the source of the problem. Somehow the shrink-wrapped WAR did not find the right version. Pinning down the version in the <dependencyManagement> section of our root POM fixed our integration tests.

Sorry for the noise. This one was really nasty to debug. Now there is a little more time for you to celebrate Xmas (or to solve our other open tickets).

bartoszmajsak commented 8 years ago

code-09