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

Test and document the possibility to modify the transactions list #995

Open
honzajavorek opened this issue Mar 27, 2018 · 1 comment
Open

Comments

@honzajavorek
Copy link
Contributor

honzajavorek commented Mar 27, 2018

Disclaimer

Dredd is primarily a tool designed to perform isolated tests and hooks are here to help you to isolate each test. If you need to modify the transactions array, it's a sign you're not creating isolated tests. YMMV if that's good or bad.

Workaround using Dredd hooks

There is a way how to modify the array of transactions in a beforeAll hook. An example how to duplicate the first transaction and how to add it at the end of the transactions array:

const hooks = require('hooks');
const clone = require('clone');

beforeAll((transactions, done) => {
  transactions.push(clone(transactions[0]));
  done();
});

Flaws

Will this work in other languages than JS?

Use cases

The workaround allows you to solve following problems:

Why this is a workaround

Again, Dredd is primarily a tool designed to perform isolated tests. We may support integration scenarios or workflows in the future and we would love to hear about what approach you think would be the most useful to you (tracking issue: #358), but as of now, Dredd isn't ready to help you with more complicated flows.

@MCMic
Copy link

MCMic commented Jun 6, 2019

It does not seem to work in PHP

I tried:

Hooks::beforeAll(function(&$transactions) {
  array_splice($transactions, 2);
});

But all transactions still got tested.

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

No branches or pull requests

2 participants