Ability to use output from earlier test in input to later test
I have some tests that need to keep state in between them.
For example, I have a HTTP API where the caller POSTs to one URL, gets a generated ID back, and GETs another URL with that ID as an argument for a status update. The GET must be constructed with the output of the POST.
The simplest way to do this might be with a regexp group, where the matched group in a (re) test were available to the input of a future test. But I think this will have to be a little more involved than having the last test's groups available, I can think of things I want to test which would need to remember the output from 2 or more interactions back. Maybe a global dict and named test lines, like:
match previous test $ do_setup foo You gave me foo, the ID is (.+) (re) $ use_id \1 You used id (.+), which matches foo match earlier test with setup_id label $ setup_id do_setup bar You gave me bar, the ID is (.+) (re) $ do_something OK $ use_id setup_id:\1 You used id (.+), which matches bar
Maybe the answer is a pyunit test runner? I was thinking about something like that, but I don't want to give up the simplicity of the current format and the auto-patching, it's let me write tests very quickly. Are there any examples of scripting cram.test()?