0

I want to use Cucumber to test my application which takes snapshots of external websites and logs changes. I already tested my models separatly using RSpec and now want to make integration tests with Cucumber. For mocking the website requests I use VCR.

My tests usually follow a similar pattern:
1. Given I have a certain website content (I do this using VCR cassettes)
2. When I take a snapshot of the website
3. Then there should be 1 "new"-snapshot and 1 "new"-log messages

Depending if the content of the website changes, a "new"-snapshot should be created and a "new"-log message should be created. If the content stays the same, only a "old"-log message should be created. This means, that the the application's behaviour depends on the current existing snapshots.
This is why I would like to run the different scenarios without resetting the DB after each row.

Scenario Outline: new, new, same, same, new
    Given website with state <website_state_1>
    When I take a snapshot
    Then there should be <1> "new"-snapshot and <1> "old"-log messages and <1> "new"-log messages

Examples:
| state | snapshot_new | logmessages_old | logmessages_new |
| VCR_1 |       1      |         0       |         1       |
| VCR_2 |       2      |         0       |         2       |
| VCR_3 |       2      |         1       |         2       |
| VCR_4 |       2      |         2       |         2       |
| VCR_5 |       3      |         2       |         3       |

However, the DB is resetted after each scenario is run. And I think that scenario outline was never intended to be used like this. Scenarios should be independent from each other, right? Am I doing something wrong trying to solve my problem in this way? Can/should scenario outline be used for that or is there another elegant way to do this?

J.

Juergen
  • 115
  • 1
  • 1
  • 5
  • 1
    Scenario Outlines are meant to be run independent of each other. I would think you could change this to a regular scenario and use regular data tables for this. – Jeff Price Jul 27 '15 at 15:24
  • I cannot figure out what the scenario outline is doing. The parts with <> should map to column names in the examples table, but they do not so that that is confusing me. Can you describe what is getting tested? – Dave McNulla Jul 27 '15 at 22:02

1 Answers1

1

Each line in the Scenario Outline Examples table should be considered one individual Scenario. Scenarios should be independent from each other. If you need a scenario to depend on the system being in a certain state, you'll need to set that state in the Given.

Marit
  • 2,399
  • 18
  • 27