Building up on this question, the example provided seems to lock the text in the feature file too much to Java programming style (notice that the text is written in all uppercase, and is only one word.
Is it possible to pass enums when the feature file has more "human readable" text? E.g.:
Simple Example
Feature: Setup Enum and Print value
In order to manage my Enum
As a System Admin
I want to get the Enum
Scenario Outline: Verify Enum Print
When I supply a more human readable text to be converted to <Enum>
Examples: Text can have multiple formats
|Enum |
|Christmas |
|New Year Eve |
|independence-day|
I reckon the enum could be something like:
public enum Holiday {
CHRISTMAS("Christmas"),NEW_YEAR("New Year"),INDEPENDENCE_DAY("independence-day");
private String extendedName;
private Holidays(String extendedName) {
this.extendedName = extendedName;
}
}
How could we convert one from the other?
More complex example
In a more complex example, we would pass this onto a ScenarioObject
Scenario: Enum within a Scenario Object
When I supply a more human readable text to be converted in the objects:
|Holiday |Character|
|Christmas |Santa |
|New Year Eve |Harry|
|independence-day|John Adams|
public class ScenarioObject{
private String character;
private Holiday holiday;
(...getters and setters)
}
Update:
If the only solution is to apply a Transformer
, as described here, an example of how this would be a applied to the ScenarioObject
would be appreciated, since simply tagging the enum with a @XStreamConverter(HolidayTransformer.class)
is not sufficient for the transformer to work within the ScenarioObject
.
The best solution I found for this so far was with a transformer. In the case of the complex example with
ScenarioObject
,this involves:Mark enum with converter
Create the transformer
Mark the ScenarioObject with the transformer as well