✅ Please help me read this simple API endpoint documentation
So the image I included is a sample of one of the rows in a table that is supposed to be the documentation of the endpoints of an API I have to write Unit and Integration tests for. I do not have access to the code (as it probably doesn't even exist or at least not fully) and I don't know much about how the application will end up in terms of codebase or in terms of final software produced. This documentation is in reference to the API endpoints of the backend of a web app that will be developed in ASP.NET (at least the backend part will be in ASP). What I need help with is in understanding better what an API endpoint is and what it does in this context. Also how that connects with the info on this table. Finally, I also need to know how I can use all that information once I understand it and understand how it all is interrelated to make these unit and integration tests (I'm doing integration right now, cause no code yet).
19 Replies
As a clarification, I can switch back to doing unit tests if you think even with having no code I can make them with just this info, that just wasn't what I was planning but whatever it's completely fine either way.
An API endpoint is the code that handles a given HTTP call
In this case, a
GET
call to https://some-website.com/User/[email protected]
Which is supposed to return that user's data
Their ID, username, and state
Something like
Unit tests without having the code are not really possible
Integration tests... are more possible
Ok, so integration then. I ran this exact same info by chatGPT and asked for integration tests and this is what it said:
What do you think? If I understand all that is happening can I use it? Is it good code? Can I emulate it for all the other endpoints to the best of my ability?
This code tries to get the user by ID and not email, and it used
dynamic
So, no, it immediately fails at doing what it's supposed to do
I highly recommend not using LLMs if you're just learningOk, so I tried to adapt what gpt gave me to this, what do you think?
You don't use
UserReal
anywhere
So what are you checking here? Not the response from the API that's for sureyeah, sorry I had misunderstood:
Now the problem is that the ReadAsync() method can't read anything. But perhaps that is unavoidable if there is no real code or app to read anyting from??? I don't know, is it?
What is
ReadAsAsync()
?
It's a hallucination of the LLM
It's not a method that existsIt's not anything, it's a placeholder. I just left it as that...it's not meant to work because I assume that I would need to have the code or some form of the app to make that call and have it contain something.
This is essentially just meant to be a skeleton of the test which will be finalized once I have more to go on and to test
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
No, you don't need anything from the project
You know what the API returns
because NUnit was complaining
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Ooooh, I didn't understand that's what WebClientFactory was for
I do have that file in my proj
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
yeah, mispell
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View