-
Notifications
You must be signed in to change notification settings - Fork 63
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
Simplify template hierarchy - enable multiple versions #145
base: master
Are you sure you want to change the base?
Conversation
…tes are not present
- version can now be specified - templates can be updated for specific language group (tests, features, step_definitions or actionwords) Works with Ruby, Python and Cucumber-Ruby Almost works for Cucumber-Java
Now works as expected with Cucumber/Java (using flavors inlined_uids and no_empty_scenarios)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really important to have no duplicates in templates? Actually I found it harder to read. Let say actionword for ruby is same since 2 version and step only from previous one, we should have 3 version opened to have a global view of how it is rendered for the last version. And we should also search what is the last version that have the template rendered.
That's a good question :) For the duplication, I'd rather avoid it as much as possible for maintenance purposes. Also much of the templates won't change over time, I don't think we'll change more than two or three template from version to version. |
Hi @vincent-psarga, Is this PR still relevant? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved so it can disappear from my daily notifications :p
Note: this is work in progress and the goal is to get ideas.
TLDR: it's a pain to support a new version of a test framework without breaking code for the users. Let's tackle that, but you'll have to read stuff :D
The problem
So, one of the current problem of hiptest-publisher today is the difficulty to handle multiple versions of a given language/framework.
For example, for all Cucumber frameworks, we do not yet use cucumber-expressions and still generate regular expressions. Same thing, we don't support newer Gherkin syntax.
If we look at hps-* repositories, we have a good idea of the problem, we're testing with old versions of the frameworks as we can not really update them ...
Of course we could do major releases every now and then and stop supporting old frameworks (only the latest one) but that does not really look like a good idea.
The proposed solution
The idea here is first to stop having weird hierarchy of templates (for example
gherkin/java/
orcucumber/java/actionwords/
for example).There are now three main folders in the templates:
Now, inside a folder (for a language or a framework, principles is the same), we'll find templates for each version, eg:
Currently, we always pick the first one, but the idea on the long term will be to have the possibility to specify a version and hiptest-publisher will find the template that is needed.
If a template is not found for the asked version, we'll try previous versions.
In the previous example, if we ask to render a
call
with ruby version 2.4, it'll useruby/version-2.4/call.hbs
.If we ask to render an action word, it'll use
ruby/version-2.3/actionword.hbs
.So logically we should not have to copy-paste templates between each versions, only override with the changes.
Now, two things a bit particular:
flavors:
Languages can have flavors, basically a different way of writing things but not a different version. Currently, we have two examples of those flavors in gherkin:
cucumber-java uses those two flavors which makes the Gherkin rendering a bit different from the one in cucumber-ruby
specific rendering for group languages
When exporting, we have different groups:
feature
,step_definitions
andactionwords
for Gherkin based frameworks,tests
andactionwords
for the other ones.When the rendering for the same node needs to be different based on the group (usual case is for gherkin based framework: we render each actionword once as a function, once with the regex to match the feature file), it is possible to specify it in sub-folders.
For example for cucumber-java framework:
What need to be done
So far, this approach has only been applied to ruby (RSpec, minitest and cucumber) and cucumber-java.
If multiple versions of a language/framework exist, fallback to previous versions if the template does not exist.
I still need to figure out some priorities when it comes to selecting the template (when we'll have multiple versions + flavors for example).
We need a way to ease migration for users who currently override templates (we've started a discussion with @cbliard about that, I think it'll be another PR soon ;) )
We need a way to select the language/framework version directly from CLI (template_finder supports it, but we just pick the first one now)
What it will change
Lots of things hopefully. Mainly it should simplify finding which templates does what and, of course, be able to use multiple versions for a language and/or framework.
We should also be able to fine tune the exports (for example by letting users select the flavors they want)
The
language
andframework
options should disappear to use a single option. That will remove weird stuff (like--language=cucumber --framework=java
should beframework=cucumber-java
) and make things simpler.Also the config files for the different languages should be easier to read:
Most of the time, it'll just be
framework-name, language-name, common
and eventually some flavors for languages.