fsprojects / TickSpec

Lean .NET BDD framework with powerful F# integration
Apache License 2.0
133 stars 23 forks source link

"Missing step definition" when applying multiple step attributes to single step #55

Closed jcoliz closed 1 year ago

jcoliz commented 2 years ago

Hi. In the comments for issue #25, @michalkovy notes that it is possible to allow a single step to function both as (say) a Given and When step.

We could potentially have such attribute but you can do the same today by writing:

let [<Given; When; Then>] ``I have defined a step definition`` () = ()1

However, this is not working for me today in 2.0.2.

This is what I have:

let [<Given; When>] ``user launches site`` (page: IPage) (uri: Uri) = 
    page.GotoAsync(uri.ToString()) |> Async.AwaitTask |> Async.RunSynchronously
Scenario: Root loads OK
    When user launches site
    Then page loaded ok

Scenario: Home page loads OK via navbar
    Given user launches site
    When clicking Home on navbar
    Then page title reads "Home"

This is what TickSpec has to say:

    TickSpec.StepException : Missing step definition on line 4 in Site is alive and healthy
    "When user launches site"

Note that the Given step still works fine.

I can work around it by duplicating the step, but yuck.

This workaround does work:

let [<When>] ``DUPLICATE user launches site`` (page: IPage) (uri: Uri) = 
    ``user launches site`` page uri
Scenario: Root loads OK
    When DUPLICATE user launches site
    Then page loaded ok
jcoliz commented 1 year ago

@mchaloupka Thanks!