Giter Club home page Giter Club logo

Comments (4)

prashant-ramcharan avatar prashant-ramcharan commented on June 17, 2024

Hello,

Have you tried using Spring ConditionalOnProperty?

This should only create the web driver bean if the tag you pass at runtime is @fe

@Configuration
@ConditionalOnProperty(name = "cucumber.tags", havingValue = "@fe")
public class WebDriverConfiguration {
}


// or

@Bean
@ConditionalOnProperty(name = "cucumber.tags", havingValue = "@fe")
public WebDriver webDriver() {
}

Pass it at runtime / or define it as a default in your app config

gradle test -Dcucumber.tags="@fe"

from courgette-jvm.

sobi-ki avatar sobi-ki commented on June 17, 2024

Thank you for your response.

I do have a solution if running via gradle cmd, but the issue is when setting a tag of @fe, then I won't be able to fire the API test. The problem is that the tags are not seen when @bean is called from CourgetteRunner class or when running test via Feature / Scenario level in Feature file.

from courgette-jvm.

prashant-ramcharan avatar prashant-ramcharan commented on June 17, 2024

Have you considered making your bean @Lazy ?

@Bean
@Lazy
public WebDriver webDriver() {
}

So only tests that require a webDriver bean will call it to launch a browser.

As your API tests doesn't need a webDriver bean, it simply won't be loaded / created and as a result, no browser will be launched.

You could also dynamically register the bean based on the Cucumber tags at runtime.

    @Before
    public void before(Scenario scenario) {
        if (scenario.getSourceTagNames().contains("fe")) {
            // register your webDriver bean here
        }
    }

from courgette-jvm.

sobi-ki avatar sobi-ki commented on June 17, 2024

Thank you for your feedback. Not tried @lazy will give it a go.

from courgette-jvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.