What kind of testing is this? Is the following considered end to end testing or is it an integration testing or a system testing? If not if you can elaborate on the types of testing in context of the code example.
I'm basically calling the endpoint on localhost and asserting on the status/output.
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();
});
}
}
Interesting question, unfortunately the answer can depend on a number of things.
Let's start with a few definitions:
So the first question to consider, is this test checking a complete flow that a user would be expected to achieve?
This does mean you need to define who the user is. If for example you are building an API that is then re-used by other developers your user as the author of the api will be different to the end user of the solutions integrating your api.
My best guess is that this isn't an end to end test. Looking at the test it is a web request to get a list of users. If you are building a Web UI that can list confidential information I would expect this to require the person accessing the list to be logged in. Therefore the end to end test would include logging into the system.
So, next question, what components are being tested? Hard to tell from the test code but I am guessing the data is stored in database somewhere. So yes this is an integration test as it checks the interaction between the web component and the database.
Finally, is this a system test. Probably yes as I cannot see any evidence of this not being run against the system as a whole. Also, assuming the requirement of your solution is to be able to list the users then it is testing the required functionality.
So, in this case I believe it could either be a system or an integration test. Unfortunately based on the definitions of these test types there is often an overlap where tests could be classified as either. So it's ultimately up to you whether you call it a system or an integration test.