Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Re-use of step text suggestion (#define) #137

scaphe opened this Issue · 0 comments

1 participant


I have a suggestion regarding how to re-use certain setup-style boiler-plate steps.
I have an example where we are trying to test fix messages, many scenarios requires very similar (often identical) parameter driven steps, which are often step number 3 out of 6 or such and contain many configuration values (field ids etc). After talking to others about how this could be done without cut/pasting that step lots of times, the basic suggestion seemed to be to encode the fix tags (numbers) that are going to be setup/copied inside a simple sentence/step definition, thus hiding the tags that are being setup behind a simple sentence, making the test short and easy to read and re-factor proof. This means that if the common definition (i.e. set of fields) needs to be changed it can be changed once in the step code, so none of the tests are affected.


This means that the definition of what this "simple" re-used step does is now opaque to the QA team who are writing the tests (or anyone else examining the test files), and cannot be changed by them since it is defined in code (which in theory the devs should own imho) so they are dependent on devs to enhance/fix this re-used function.

It seems to me that you could get a lot of the power of re-use by using a very simple pre-processor macro-like replacement before the tests are run (e.g. C multi-line #define constants).

This extension would mean that the whole definition of the test would be contained within the feature file(s) rather than partly hidden in the code but still allowing maximum re-use. The QA team could enhance/fix this re-used step themselves, and there would actually be less code to write and maintain. Also, simply from inspection of the feature file(s) you would know what the test was actually doing.
Note that this suggestion is simple replacement, no arguments allowed.

What do people think?

I was thinking of knocking something up to do this and checking how it seems to work in practice. It feels like this is a better way than putting the re-used parameter sets in new step functions in the code/driver layers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.