Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException: No Scope registered for scope 'cucumber-glue' #600

Closed
cpkelley opened this issue Oct 4, 2013 · 8 comments · Fixed by #711
Closed

IllegalStateException: No Scope registered for scope 'cucumber-glue' #600

cpkelley opened this issue Oct 4, 2013 · 8 comments · Fixed by #711

Comments

@cpkelley
Copy link

cpkelley commented Oct 4, 2013

After Cucumber JVM v1.1.4, when using @scope('cucumber-glue') or in the cucumber.xml context file <bean .... scope="cucumber-glue" /> , spring throws the following exception:

Caused by: java.lang.IllegalStateException: No Scope registered for scope 'cucumber-glue'

See failing example here: https://github.com/cpkelley/cuke-demo-spring/

This works fine when reverting back to v1.1.2. It's possible that I'm just not using the new cucumber spring properly. I tried following the steps specified in the Cucumber Recipes book.

@anatolyD
Copy link

anatolyD commented Oct 7, 2013

v1.1.5 has the same issue.

@azzoti
Copy link

azzoti commented Nov 8, 2013

Also having this problem with 1.1.5

@azzoti
Copy link

azzoti commented Nov 8, 2013

Found a workaround for this problem:

In my test-applicationContext.xml I added this (copied from cucumber-glue.xml in the cucumber distribution) Workaround for a bug? in cucumber-spring after 1.1.3

<bean id="glueCodeScope" class="cucumber.runtime.java.spring.GlueCodeScope">
</bean>

<bean id="glueCodeScopeConfigurer" class="org.springframework.beans.factory.config.CustomScopeConfigurer">
    <property name="scopes">
        <map>
            <entry key="cucumber-glue" value-ref="glueCodeScope"/>
        </map>
    </property>

<!-- my normal config follows -->
...

@cpkelley
Copy link
Author

Just an update. I just started using 1.1.6 and this is still an issue. The workaround posted by azzoti works though.

@brasmusson
Copy link
Contributor

An variation on the workaround is of course to import the cucumber-glue.xml in the test application context xml file instead of copying the content:

    <import resource="classpath:cucumber/runtime/java/spring/cucumber-glue.xml"/>

@whittle
Copy link

whittle commented Mar 2, 2016

I am encountering this error with v1.2.4. I have a class co.masslab.shiba.CucumberTests annotated with:

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/resources",
                 glue={"co.masslab.shiba", "cucumber.api.spring"})
@Configuration

A step definition class in the same package annotated with:

@ContextConfiguration(classes={ShibaApplication.class, TestDoubleConfig.class, DataSourceConfig.class},
                      loader=SpringApplicationContextLoader.class)
@IntegrationTest
@WebAppConfiguration

And a DataSourceConfig class, also in the same package, that looks like this:

@Configuration
public class DataSourceConfig {

    @Scope("cucumber-glue")
    @Bean
    public DataSource datasource() {
        return new EmbeddedDatabaseBuilder()
            .setType(EmbeddedDatabaseType.H2)
            .build();
    }

The innermost error in the stack trace is java.lang.IllegalStateException: No Scope registered for scope name 'cucumber-glue'.

In light of this, I am asking that this ticket be reopened.

@whittle
Copy link

whittle commented Mar 2, 2016

Sorry, just now saw #965 which I assume covers this issue.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants