使用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)。
1条答案
按热度按时间falq053o1#
您可以尝试https://httpx.sh/。
请参见related feature request and comments。