IntelliJ HTTP客户端插件是否有可以在IDE外部运行的CI包?

mctunoxg  于 2022-10-07  发布在  其他
关注(0)|答案(1)|浏览(120)

使用Intellij's HTTP Client时,您可以编写扩展名为.http的文件,该插件允许您从IDE运行HTTP请求。我们叫它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 + "'");
});
%}

是否有可在持续集成环境中使用的工具来从命令行运行此.http文件?

我正在寻找一个bash脚本或程序,将被调用像./cool-script my-tests.http返回0,如果一切都通过了。它还允许您运行特定的测试,如./cool-script my-tests.http --test=3中只运行第三个请求(在上面的示例中只有一个请求,即get https://httpbin.org/get)。

相关问题