Home > database >  Does the Intellij HTTP client plugin have a CI package that can run outside the IDE?
Does the Intellij HTTP client plugin have a CI package that can run outside the IDE?

Time:09-27

When using Intellij's HTTP Client, you can write a file with the extension .http and the plugin allows you to run HTTP requests from the IDE. Let's call it my-tests.http

my-tests.http

### Check response status, headers, and content-type
GET https://httpbin.org/get

{%
client.test("Request executed successfully", function() {
    client.assert(response.status === 200, "Response status is not 200");
});

client.test("Headers option exists", function() {
    client.assert(response.body.hasOwnProperty("headers"), "Cannot find 'headers' option in response");
});

client.test("Response content-type is json", function() {
    var type = response.contentType.mimeType;
    client.assert(type === "application/json", "Expected 'application/json' but received '"   type   "'");
});
%}

Is there a tool that can be used in Continuous Integration environments to run this .http file from the commandline?

I'm looking for a like maybe a bash script or Python executor that would be invoked like ./cool-script my-tests.http that returns 0 if everything passed. It would also allow you to run a specific test, as in ./cool-script my-tests.http --test=3 to only run the third request (there is only 1 in my example above, GET https://httpbin.org/get).

CodePudding user response:

You can try https://httpx.sh/.

See the related feature request and comments.

  • Related