Spock test method names appear as "$spock_feature_<number>_<number>" when running tests with PaxExam runner

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Spock test method names appear as "$spock_feature_<number>_<number>" when running tests with PaxExam runner

Steve Storck
Hello.  I am using Spock in conjunction with pax-exam to test bundle deployment and functionality in a custom karaf distribution.  When I run the tests, it refers to tests by what appears to be an uninterpreted variable name.  An example is "$spock_feature_1_0".  Am I doing something wrong, or is this a effect of using spock with the PaxExam (or other junit) runner?

Here is how my integration test project is set up:

Apache Maven 3.3.3
Java version: 1.8.0_51, vendor: Oracle Corporation
CentOS 6.6, arch: amd64
Groovy-all 2.4.3
Spock 1.0-groovy-2.4
junit 4.12

I am provisioning the container for Spock as follows:
mavenBundle()
       
.groupId('org.codehaus.groovy')
       
.artifactId('groovy-all')
       
.versionAsInProject(),
junitBundles(),
wrappedBundle(cglibUrl),
wrappedBundle(objenesisUrl),
wrappedBundle(hamcrestUrl),
mavenBundle()
       
.groupId('redbus.repackaged.org.spockframework')
       
.artifactId('spock-core')
       
.versionAsInProject(),

I have a parent class called TestSupport which I have adapted from KarafTestSupport.java by converting it to Groovy and removing some of the methods and properties that I do not currently need in my tests.  This class extends Specification, but it does not implement any Spock tests.  Its purpose is to set up the Karaf container in preparation for the tests, implement common behavior for the tests, and to provide an (indirect) extension of the Specification class for the test classes.

Here is an abbreviated example of one of my test classes:
@RunWith(PaxExam)
@ExamReactorStrategy(PerClass)
public class ExampleTest extends TestSupport {
   
@Before
   
public void perMethodInit() {
        waitBundleState
'my.bundle.impl', Bundle.ACTIVE
   
}

   
@Test
   
public void 'Test service loaded'() {
       
when:
       
def managedServiceFactory = getOsgiService ManagedServiceFactory, 'service.pid=distro.properties', 30000

       
then:
        managedServiceFactory
instanceof PropertiesService
       
'distro.properties' == managedServiceFactory.name
   
}
}

It definitely feels clunky to have to make the method signatures look so un-groovy, but the PaxExam runner does not run the tests if they are not annotated with @Test, and if they are not declared as "public void".

Does anyone have any ideas about why the test methods are displayed as "$spock_feature_1_0" or what I might be able to do better in combining Spock with PaxExam?  Thanks in advance!

Steve

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.