by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 14 15:42
    BIPLAVGHOSAL closed #250
  • Jun 14 15:42
    BIPLAVGHOSAL commented #250
  • Jun 14 14:55
    cressie176 commented #250
  • Jun 14 14:55
    cressie176 commented #250
  • Jun 14 14:16
    BIPLAVGHOSAL commented #250
  • Jun 14 14:15
    BIPLAVGHOSAL commented #250
  • Jun 14 11:51
    BIPLAVGHOSAL commented #250
  • Jun 14 11:20
    cressie176 commented #250
  • Jun 14 10:49
    BIPLAVGHOSAL opened #250
  • May 19 19:36
    cressie176 commented #149
  • May 19 18:56
    lolmaus commented #149
  • May 19 18:35
    lolmaus commented #149
  • May 19 18:35
    lolmaus commented #149
  • May 19 18:23
    lolmaus commented #149
  • May 19 18:04

    dependabot[bot] on npm_and_yarn

    (compare)

  • May 19 18:04

    cressie176 on master

    Bump lodash from 4.17.11 to 4.1… Merge pull request #246 from ac… (compare)

  • May 19 18:04
    cressie176 closed #246
  • May 19 18:04

    dependabot[bot] on npm_and_yarn

    (compare)

  • May 19 18:04
    dependabot[bot] synchronize #246
  • May 19 18:04

    dependabot[bot] on npm_and_yarn

    Bump lodash from 4.17.11 to 4.1… (compare)

Jánszky László Lajos
@inf3rno
This message was deleted
Jánszky László Lajos
@inf3rno

What are the best practices to deal with verbal contexts?
e.g. I have 2 scenarios, both removing items from collections:

    Given John is authorized to remove tasks from the todo list
    When John removes a task from the todo list
    Then the task should be removed from the todo list
    Given John is authorized to remove products from the product catalog
    When John removes a product from the product catalog
    Then the product should be removed from the product catalog

I can define steps by each sentence.

What if we create an abstraction, like a Collection or a List:

    Given a todo list with tasks
    And John is authorized to remove items
    When John removes an item
    Then the item should be removed
    Given a product catalog with products
    And John is authorized to remove items
    When John removes an item
    Then the item should be removed

By these scenarios I have the following options:

  • use a different library instance by each scenario to avoid step definition conflicts by the similar sentences
  • use a single library instance and add if-else blocks to each step definitions
  • use a single library instance and add an abstraction like a CollectionTestHelper interface, and inject the helper instance by the first Given statement
  • use a single library and define steps on the fly when the parser meets with the first Given statement (I guess this is not possible with the current parser)

What are your best practices to use similar steps by different contexts?

Normally I would consider test code duplication as a sign to create an abstraction, but by BDD these collections does not necessary have the same interface. They can solve similar problems in completely different ways. Maybe creating a testing abstraction is the right way, but I am not sure.

Jánszky László Lajos
@inf3rno

Another type of verbal context here could be

    Given a todo list with tasks
    And John is authorized to remove tasks
    When he removes a task
    Then the task should be removed

so we use he instead of John

Stephen Cresswell
@cressie176
Starting with your last question (he instead of John)
I typically add a ctx object to yadda.run
then from inside the "Given" step do something like
this.ctx.currentUser = user
You can also use a dictionary to convert "he" into the current user automatically
WRT to you other question - avoiding ambiguous steps. I would avoid if/else in your steps
Yadda will "prefer" steps from the last used library
Stephen Cresswell
@cressie176
so providing you separated all 8 steps into two libraries, 4 for product catalog and 4 for todo list
you could load both libraries without issue
An alternative approach would be to annotate the test with a hit to say which library to load
@library="productCatalog"
and use this in your test runner to load libraries per scenario
I don't like this method since it pollutes the spec with code hints
Jánszky László Lajos
@inf3rno
@cressie176 So you think the first solution is the best, and the DRY principle does not apply here. I can more or less accept this. I think this is not black and white, so in some cases when these features are not closely related to each other, using different libraries is the good solution, while in other cases using the same library and creating helper objects would be a better solution. I don't have examples yet, I still need to practice BDD more. I'll post again as soon as I have something interesting in this topic, it might take a few months. :-)
Jánszky László Lajos
@inf3rno

Does yadda support something like the following?

Scenario q
  Given x
  When a
  Then b
  When c
  Then d
  Given y
  When e
  Then f

It is possible to keep contexts with the backgrounds too.

Background
  Given a
  Given b

Scenario x
  ... // ctx:  a & b

Background
  Given !b

Scenario y
  ... // ctx:  a & !b


Background
  Given !a

Scenario z
  ... // ctx:  !a & !b

It is currently my proposition by the gherkin developers. I think it is closer to natural language when we keep and modify the verbal context during the discussion instead of always dropping a redefining it. The latter one is testing framework logic, but according to many BDD users, the main goal of BDD to ease the communication between the stakeholders and the developers, so having something close to plain English has a higher priority than having something which is similar to testing frameworks. At least I think so.

ignaciocavina
@ignaciocavina
Hello!
I'm having issues with async steps, as implemented in the mocha-webdriver example... I'm trying to make some async stuff within my step (ie calling an external service), but I can't find a way to avoid the flow to continue to the next step before my service call finishes...
Michael Roytman
@MichaelRo
Hey guys,
Is there any best-practice in the matter of using json multiline strings as a parameters in example tables?
Eugene Maslovich
@ehpc
@inf3rno actually chaining given.when.then.when.then is the right way to do it according to Dan North. And you're right, the priority of BDD as agile methodology is communication over tools and processes, that's actually in the Manifesto. BDD is for the whole team, not only for devs, so everyone should be able to understand stories (that's where DDD and ubiquitous language come in) and anyone should be able to write them, so the language should be simple and unambiguous (and definitely non-technical, so those logical operands are too much).