Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Custom transaction ordering for workflow/scenario testing #358

Open
ghost opened this issue Jan 27, 2016 · 7 comments
Open

Custom transaction ordering for workflow/scenario testing #358

ghost opened this issue Jan 27, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented Jan 27, 2016

hello,
is there any solution _how to run any hooks transactions before others?_ I have some objects depends on others and i need to specify which post method must run first, second, etc..

for example:
book, author - i have to create author first to be able create book..

I cannot find anything about it and --sorted is not enough :-(

@ddelnano
Copy link
Contributor

You don't want to use a before hook handler to seed the data that your other hook transaction would populate?

@netmilk
Copy link
Contributor

netmilk commented Jan 28, 2016

Hey @mkax,

Dredd is designed at this moment to be more a tool for unit testing of each entry in the API Blueprint API reference and hooks are meant as a tool how to isolate and do some setup and teardown for each transaction.

If you'd like to test some workflows or scenarios (more integration or functional-like testing) I would recommend using the simple API Blueprint notation which is not resource oriented and is focused more on describing the HTTP calls. You can use multiple blueprint files - one per each workflow (scenario) using the --path CLI parameter and the "stash" pattern in hooks for passing data between transaction responses and requests.

@netmilk
Copy link
Contributor

netmilk commented Jan 28, 2016

@mkax And I would totally love to have native support for scenarios/workflows in both Dredd and API Blueprint and using items from the reference as steps in these scenarios.

Or at least, some support for custom ordering of transactions.

@netmilk netmilk changed the title Run hooks transaction before another transaction Custom transaction ordering for workflow/scenario testing Jan 28, 2016
@ghost
Copy link
Author

ghost commented Feb 1, 2016

Hey @netmilk,
thank you for answers. I know about the simple way, but there is problem in duplicate resource definition (even if i use different method, this rule should be disable-able) :-) and even i would write some parser to make new apib files with custom sorted transactions because I cannot change our apiary docs, it should stay as is - its not good way.

Custom sorting would be nice, for example.. if I could specify list of transactions in dredd.yml like parameter 'only'.

@ddelnano hooks works good, but cannot do what i need.
example: what I need..

POST Create new Item - this new item has status draft.
PUT Update Item - make revision, final changes and put it to status published.
POST Create Child for Item - this child item belongs to Item, but its possible only to published items.

This is strict functionality in our app, so I cannot create child before Item is published.. I'll get 404 - which is correct behavior.

@netmilk
Copy link
Contributor

netmilk commented Feb 1, 2016

@mkax Thank you so much for the explanation! I think it's totally testing of API scenarios / workflows. I would absolutely love to have this functionality so I'll try to come up with some proposal or workaround.

@netmilk
Copy link
Contributor

netmilk commented Feb 19, 2016

Here is another real-world insight: #151 (comment)

@honzajavorek
Copy link
Contributor

honzajavorek commented Mar 27, 2018

Let's keep this as a tracking issue for the feature request that Dredd should support scenarios / workflows in the future. Related issue describing the current possibilites: #995

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

No branches or pull requests

3 participants