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

How to write a Scenario without using tables #192

Closed
crisefd opened this issue Jan 5, 2017 · 4 comments
Closed

How to write a Scenario without using tables #192

crisefd opened this issue Jan 5, 2017 · 4 comments

Comments

@crisefd
Copy link

crisefd commented Jan 5, 2017

I was writing my test in Cucumber, but decided to move to Spinach. I had this scenario in my previous Cucumber tests:
Scenario: Test if a generated matrix is in fact, an L8 Taguchi array
Given the number of levels Q is 2
And N is 7
And J is 3
Then the resulting matrix should be:

       `| 0 | 0 | 0 | 0 | 0 | 0 | 0 |

        | 0 | 0 | 0 | 1 | 1 | 1 | 1 |

        | 0 | 1 | 1 | 0 | 0 | 1 | 1 |

        | 0 | 1 | 1 | 1 | 1 | 0 | 0 |

        | 1 | 0 | 1 | 0 | 1 | 0 | 1 |

        | 1 | 0 | 1 | 1 | 0 | 1 | 0 |

        | 1 | 1 | 0 | 0 | 1 | 1 | 0 |

        | 1 | 1 | 0 | 1 | 0 | 0 | 1 |`

I know you do not support tables, but how then can I input my arrays ?

@ywen
Copy link
Collaborator

ywen commented Jan 5, 2017

Write the result in the step file. The step can be:

Then the result matrix is correctly computed

Then in the step file

step "the result matrix is correctly computed" do
  expect(result).to eq(result_matrix)
end

@crisefd
Copy link
Author

crisefd commented Jan 6, 2017

Ok, but if do this, I think the writen scenario is not readable enough.Correct me if I'm wrong, but I thougth the whole point of writing the scenarios in gherkin for acceptance tests was to allow anyone, even a customer, to read and understand the tests.

@ywen
Copy link
Collaborator

ywen commented Jan 6, 2017

My own understanding is you need a different mindset when determining what is a good "reads and understands" test. I would write this test as (while I have no idea what Taguchi array is):

Feature: Generated matrix is an L8 Taguchi array
  As a role,
  In order to accomplish something
  I want to be able to have a correct algorithm on generating Taguchi array

  Scenario: Happy Path
    Given a reasonable input
    When I invoke the algorithm
    Then the algorithm outputs the desired result


  Scenario: N is out of bound 
    Given N is out of bound
    And other params are within normal range
    When I invoke the algorithm
    Then the algorithm handles N out of bound the error

Look at your original test, it does say what happens but it doesn't really say the intention of the tests, does it? I would argue the steps like N is 7 or the result should be (matrix) are rather noise that a customer doesn't really care about.

But this is just my opinion. In any case, when using spinach there is no way to write tests with such dynamic steps. If you feel strongly about to have these capacities you may also want to look into https://github.com/jnicklas/turnip

@crisefd
Copy link
Author

crisefd commented Jan 6, 2017

I guess you have a point there. Thanks a lot by the way

@crisefd crisefd closed this as completed Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants