GithubHelp home page GithubHelp logo

Comments (4)

aslakhellesoy avatar aslakhellesoy commented on July 19, 2024

Maybe the Given/When/Then methods could store the step definitions in a static Map<Class, List> somewhere. Then ScalaAnalyzer.registerHooksAndStepDefinitionsFor(...) could look them up in that Map later. Maybe not the most elegant solution, but maybe it can be done cleaner in Scala than in Java.

from cuke4duke.

aslakhellesoy avatar aslakhellesoy commented on July 19, 2024

Another option could be to make ClassLanguage a singleton (with a getInstance() method - yuck) and register the step definitions directly on that singleton from within the Given/When/Then methods. If you go for that approach, the registerHooksAndStepDefinitionsFor(...) method could be empty and do nothing (it would already be done in the Given/When/Then methods).

from cuke4duke.

teigen avatar teigen commented on July 19, 2024

(Aslak: Edited formatting of list)

This one is a little tricky.
Scala step definitions are really just closures paired with a string, so doing this through static analysis would not work. Storing stepdefinitions in a singleton would not be correct since the stepdefinitions would then be referencing the world they were created in.

What we can do, is capture the stepdefinitions for each new world being created. That would correctly scope the closures to the world defined by the objectfactory (since the objectfactory should be used to create the instances of the scalaDsl).

The result would then be pretty good where all tests are run in the same classloader allowing caching of expensive stuff in singletons, while at the same time executing the defined world.

The process would then be

  • pass all classfiles to cuke4duke
  • create objectfactory
  • repeat:
    • create world
    • capture stepdefinitions
    • execute
    • dispose world

Alternatively we could capture the stepdefinitions in a "dry run", an return delegators for each stepdefinition. The delegators would the execute the re-captured ones scoped to the correct world. This could give some strange behaviour if people have sideeffects in their ScalaDsl constructors (they would get n+1 applications of that effect)

from cuke4duke.

aslakhellesoy avatar aslakhellesoy commented on July 19, 2024

Fixed a few weeks back during a heroic hacking session

from cuke4duke.

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.