【发布时间】:2019-10-30 09:13:09
【问题描述】:
这是什么测试?以下被认为是端到端测试还是集成测试或系统测试?如果不是,您可以在代码示例的上下文中详细说明测试的类型。
我基本上是在本地主机上调用端点并断言状态/输出。
let assert = require("assert");
let http = require("http");
describe("EndToEndTesting", function() {
describe("GET /users", function() {
it("should return list of users", function(done) {
http.request({
method: "GET",
hostname: "localhost",
port: 3000,
path: "/users"
}, function(response){
let buffers = [];
response.on("data", buffers.push.bind(buffers));
response.on("end", function(){
let body = JSON.parse(Buffer.concat(buffers).toString());
assert(response.statusCode == 200);
});
}).on("error", console.error).end();
});
}
}
【问题讨论】:
标签: node.js testing integration-testing end-to-end system-testing