Reputation: 117
Please help us with this question.
We have a data migration system that can migrate data from different sources to targets. For example, from Oracle to Db2, from Postgres to Kafka, from MySQL to Hadoop, etc.
In our feature file we can have the following logic:
Scenario: Test data migraiton
Given I have the following source to target mapping
| source | target |
| Oracle | Db2 |
| Postgres | Kafka |
| MySql | Hadoop |
When I try to run migration basic test
Then I get abc
...
Then I get xyz
For User 1, if they added code pertaining to Oracle source, they may not care about running the full suite before check-in. So what I had in mind was keep the feature file the same for all users, but provide configuration file where users can tweak the database they care about and only run the tests for those databases.
Here's what the file would look like:
books:
Oracle:
credentials:<database credentials>
url:<url>
Db2:
credentials:<database credentials>
url:<url>
Note that it's missing details for Kafka, Hadoop, MySQL, and Postgres.
The build system, on the other, hand might want to run the entire test suite so a complete configuration.yaml file would solve that problem.
I was hoping there was a way to solve this problem efficiently without having if checks everywhere to see if the current {source,target} is defined in configuration yaml. If not, skip the test for that combination.
Upvotes: 1
Views: 473
Reputation: 4099
I would probably do this by writing something like
Given I am mapping from A to B
When I do a basic mapping
The I should get ...
and configure A and B via environment variables. This would allow users and CI to script the way they want the test too work, with something like
cucumber features/mapping A=ORACLE B=Hadoop
This is basically pulling the programming (configuring A and B and looping) up from Cucumber into a script. In general with Cuking you want to push programming down (into helper methods) or pull it up into scripts. Programming in Cucumber itself just doesn't work well (or at all).
In your step defintions you could use helper methods with case statements if you need to do different things for different db's e.g.
module MappingStepHelper
def map_source
case Orcacle
case Postgres
...
end
end
World MappingStepHelper
Above is ruby way of doing this.
Upvotes: 1
Reputation: 12039
So you are running your tests against a matrix of different systems. And it looks like the the specifics of the systems themselves aren't tested. So you could solve this by putting the matrix of systems tested into your CI system.
Something like:
Is there a way to use a single example file for all cucumber test?
Upvotes: 1
Reputation: 4099
Take 'In the Garden of Beasts' out of the scenario.
There is no point in having it in the scenario if its not going to be tested by the scenario.
Upvotes: 1