Skip to content
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

Data driven execution should be represented in context #2201

Open
jensakejohansson opened this issue Jan 29, 2022 · 3 comments
Open

Data driven execution should be represented in context #2201

jensakejohansson opened this issue Jan 29, 2022 · 3 comments

Comments

@jensakejohansson
Copy link
Contributor

I'm running a specification using data driven execution. I will not go into the exact details of what I'm trying to achieve, but I do believe that the table data that that gets "injected" into each execution of a scenario should be available in it's context in the execution hooks.

Basically in the [BeforeSpec] (I'm using dotnet):

[BeforeSpec]
public void BeforeSpec(ExecutionContext context)

I'd like to have a reference to the current data from the "data driven"-table (essentially the current row of the table) and also be able to dynamically modify it (add colums, alter column data) and any changes should of course be propagated through out the scenario.

This should give the user much more freedom to extend the data driven possibilities by inject "dynamic" data, inject test data from other sources on-the-fly and so on.

@sriv
Copy link
Member

sriv commented Jan 30, 2022

I imagine that the context can be enriched with the run being data driven, and more information about current row and the resolved data row etc.

This should give the user much more freedom to extend the data driven possibilities by inject "dynamic" data, inject test data from other sources on-the-fly and so on.

This goes against the responsibility designed, i.e mutating the context bit, not empowering the user bit. The spec files and supporting data files are the source of record for the data driven execution.

I believe gauge could do better to support more data sources and allowing users to plug in richer data source. We discussed this, but at that time it came out that this will cause other aspects (ex. gauge's parsing) to break, so we parked it.

@jensakejohansson
Copy link
Contributor Author

jensakejohansson commented Jan 30, 2022

Agreed that changing the data in hooks would likely violate the intended design in terms of responsibility and design patterns.

Hm, it would not be reasonable to allow a "data-setup-method"? Instead of a table/text-file at the top of the spec, as of now, you could also have "data-setup-step" in which the user could generate the test-data with the requirement that the method must return a Gauge-table? The table would then been used in the same way as today. Then it would be possible to programtically generate test-data in that step definition, and after that point no mutating of the data is possible - but still it should be readable through context. I believe context should provide as much information as possible about what's going on.

I guess what I'm asking for is basically something along the line of what it is provided by for example TestCaseSource in NUnit:
https://docs.nunit.org/articles/nunit/writing-tests/attributes/testcasesource.html

@sriv
Copy link
Member

sriv commented Feb 2, 2022

yeah, that is also something I had thought of. Essentially similar to nunit, the idea is to have a [TestDataSource] attribute, that would decorate a method which returns a DataTable.

The challenge here is internal to gauge's architecture, but the gist is:

  • gauge requires the test data to perform it's validation
  • gauge's validation has to run without bringing up the runner to perform validations that do not require a runner
  • the TestDataSource approach essentially will require gauge to bring up runner before the validation

Not saying this isn't possible or should/can not be done. Just that it requires change at different level, which will impact all runners, so this is a not-so-insignificant change. Bandwidth is a challenge for me personally, but I am more than happy to help in case anyone is willing to drive this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants