vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

How to write tests on top of the requests?

Open dhmuralikrishna opened this issue 6 years ago • 13 comments

How can we write acceptance tests using rest clients. Lets say if i have 50 request how can i test all those 50 calls are success. with some test cases.

dhmuralikrishna avatar Oct 10 '18 22:10 dhmuralikrishna

How to execute all http calls from cli.

dhmuralikrishna avatar Oct 10 '18 22:10 dhmuralikrishna

@dhmuralikrishna nice suggestion, I think this feature is quite useful, and I will consider it carefully. Thanks

Huachao avatar Oct 11 '18 01:10 Huachao

Compared to postman rest client is very flexible. Don't need to jump in multiple tabs.You did a great job. With postman collection and newman we can run the test through cli. it would be nice if we do the same with rest client.

dhmuralikrishna avatar Oct 11 '18 01:10 dhmuralikrishna

@dhmuralikrishna nice suggestion, I'd like to keep this request open and wait to see if others vote this up.

Huachao avatar Oct 11 '18 01:10 Huachao

Here's a good project to model: https://github.com/eykrehbein/strest

I'd like to see the benefits of this project and strest joined in a single project or have this project leverage an api of strest.

jgroom33 avatar Nov 05 '18 14:11 jgroom33

This would be great. I'm thinking something like another divider for assert results:

GET ....

<<<

assert {{response.headers.ContentType == "application/json"}} assert {{response.body.items.length >= 5}}

It would just have an additional data when running it on its own with pass fail. But running it for the whole file would give pass or fail for each.

Plus a compatible cli that can run a set of files.

This has been my go to rest client. Thank you

faisalraja avatar Jan 27 '19 23:01 faisalraja

I've switched to using strest and wrote this plugin: https://github.com/jgroom33/vscode-strest-client

jgroom33 avatar Jan 28 '19 14:01 jgroom33

That looks good. I'll check it out. Thanks

faisalraja avatar Jan 28 '19 14:01 faisalraja

assert {{response.headers.ContentType == "application/json"}}

+1 looks more flexible/natural than strest's approach where you code your validations as an AST.

ishepherd avatar Jan 30 '19 01:01 ishepherd

Where is the parser located for the http language? If that could be moved out to a separate package it would be easy to contribute with tooling for testing.

mekwall avatar Feb 18 '19 14:02 mekwall

I created a very specific needs that has very similar format with vscode-restclient since I like it's approach. It's still incomplete since we're only using this in our project and we add features as needed. testhttp will also run dependencies, for example you run a test it will run all required calls to populate the variable plus importing a different file to use it's variables too.

faisalraja avatar Apr 18 '19 20:04 faisalraja

I would also like to see a way to implement these tests in a CI system like Jenkins.

raedwa01 avatar Aug 07 '19 14:08 raedwa01

@Huachao - It would be worth looking at how httpYac does assertions. https://httpyac.github.io/guide/assert.html

This allows those calls to show up and be run through VS Code's native testing infrastructure. The ability to "run all" via this infrastrucuter is huge. I'd love to see some alignment around the assertion formats. 👍🏻

Cheers!

calebjenkins avatar Sep 29 '23 02:09 calebjenkins