player icon indicating copy to clipboard operation
player copied to clipboard

assert http response body against files

Open staabm opened this issue 5 years ago • 8 comments

I wasnt able to find a example which shows how it is possible to assert a expected http response body against the contents of a local file.

I imagine something like

scenario
    visit url('/blog/')
        name "Blog homepage"
        assert main.peak_memory < 10M
        expect body() == file(/my/local/file/with/expected.html)

IMO this would enhance readability of my test-scenario file, as I dont have huge blobs of html in them (and maybe might even allow me to generated the expected http response body using other tools) Is this kind of operation supported?

staabm avatar Dec 04 '19 16:12 staabm

That's currently not possible. I'm working on implementing it though :)

fabpot avatar Dec 05 '19 08:12 fabpot

It would also be great to use this local-file "thing" as a request body, not as an response assertion only feature.

staabm avatar Dec 05 '19 14:12 staabm

any progress on this feature?

staabm avatar Jan 07 '20 13:01 staabm

@staabm Implemented now. Waiting for reviews, merge, and release. Should happen in the next couple of weeks I would say.

fabpot avatar Jan 10 '20 06:01 fabpot

/cc @iamluc

fabpot avatar Jan 10 '20 06:01 fabpot

@staabm It's been implemented as of 27fb22764a62e58bbaf5c5ab6fa5ca687b71f76f Could you have a look and tell us if it fulfills your needs?

romainneutron avatar Jan 15 '20 12:01 romainneutron

thx for noticing.

how to install the current dev-build? I am still getting the 1.7.0 build via curl -OLsS https://get.blackfire.io/blackfire-player.phar

staabm avatar Feb 05 '20 14:02 staabm

is it also supported to provide the request body with this feature?

in curl e.g. I am using:

#!/bin/bash
blackfire curl \
    -H "Content-Type: text/xml; charset=utf-8" \
    -H "Accept: application/xml" \
    -d @artikel_request_6_sku.xml \
    -X POST https://myhost.com/example/url/

staabm avatar Feb 05 '20 14:02 staabm