#8 ServiceNow Automated Test Framework | REST Integration Testing | ServiceNow ATF Training
[Music] in order to subscribe to my channel please click here or click here please share comment and like my videos and channel the next step configuration category is rest that means you can perform rest inbound integration testing with automated test framework as you know you must have different third-party applications connected to your instance that means they must there must be sending inbound requests to your instance and maybe they are fetching some data or maybe they are inserting some data now how can you make sure that whatever data they are getting that is expected data and then they're there they're not getting any kind of errors in that case you can perform testing of your rest inbound integration with ATF we will talk about service portal testing and custom UI in little sections now in this rest category we have different step configuration like send a rest request inbound REST API Explorer the first step configuration which I'm talking about now this is not exactly the part of ATF because this will take you to the REST API Explorer which is the inbuilt functionality the out-of-the-box functionality of service now to perform testing for rest integration and to understand what kind of different out-of-the-box API is we have in ServiceNow apart from that we have other steps that is sent rest request inbound assert status code assert status code name assert response time a third response header a third response JSON payload is valid as response XML payload is valid formed a third example payload element assert JSON response payload element and then last we have a third response payload so let's start there how exactly you can perform this testing in ATF so the demo we will have about rest integration testing this is my personal developer instance I am going to create a new test and that will be ATF demo rest integration I'm going to save this once saved I can add step so first step we will see under arrest category is this one that is REST API Explorer now even if this step is added into this category this won't be added into the step because this will take you to the REST API Explorer so you can see I will go back now and then we can add another step and that step as send rest request inbound now before I start and before I add this step now in order to do this testing the important part here is because we don't have any other third-party application so what we are going to do we will use one of our table API here and whatever data we get while doing testing rest API Explorer we will try to validate that with the help of ATF so here we have incident table selected we can see now this is the endpoint which you give to your consumer and they will send the call to this particular endpoint and perform the operation as but their requirement in that case if I click on sin you can see you can get some data as of now it is returning that record the data for one record one incident record because we have this system limit so if I go here so let's do one thing let's try to force in the request the inbound requests to your instance the input for inbound requests we have this and here I will add a user so I already created a user that is idle user I will add it here I have to add the path now what path I can mention here you have to mention the path till here this is for incident path I'm going here I am mentioning the paths and I'm not putting any kind of parameter maybe if you want you can put the parameter for system limit because otherwise you will get a lot of incidents in response so I will put superb limit and I will just do one here and I will click on submit I will validate again if I have all the data you can see this is becoming empty now I don't know if it is kind of a bug in service now or like as part of the eightieth bug but I have I have tried it many times whenever I am putting the value here I don't know it gets disappeared but that's fine I'm just mentioning right now now this time it won't this time it won't so I'm just putting the value and I am just going the test now and I will try to send the request that means I will run the test so I will run the test it gets passed so it is passed now if you will go to the result you will see that we are getting response 200 ok I'm not I'm not asserting it I'm not I'm not checking that I'm whether I'm getting this or not but he can see this is a this is the data which we have I can pull it a little bit down because that is really important now this is the same data which we are getting in REST API Explorer in response and your consumers will get the same response but he can validate it so you can validate further things as well so let's go to your tests to add further steps I will click here the next thing I will validate that is a third status code while doing the inbound requests am I getting the right status code that's the important thing so I will add here and I will put operation is 200 I will click on submit I will add another step that will be code name so I'll click on next here operations contains I will not do contains maybe I will put directly okay because that is the status code name and I will click on submit then I will click here and I will add another step that is a response time but how much time does it take to provide the response so in that case I will click on next so the response time minimum should be in that is in milliseconds less than 1000 milliseconds I will put thousand I will click on submit now I'm just showing you the demo the values can be different for your testing because as of now I'm doing for incident you might do it for a change or for any other API is may be the table import API is whatever different API is you have in service now you can try to test it then we will add another step and that is response header but till here let's try to do some testing I will click on run test everything is successful that means we got the 200 response yes actual was 200 we got the expected code name yes stack sure was okay we got the response time less than thousand milliseconds and yes it was 122 milliseconds everything as expected I will go to my test and the next test step I have is header a third response and header whether I am getting the wrist right response header are not expected response header so here I can mention I have this like response here you can see and I have this content type so maybe I can mention here content type header and then I can mention JSON maybe it says contains now I'm put like this so maybe I will just put like contains JSON oh click on submit I will try to test it now let's see if yeah so we are definitely getting that header so if I test it yes actual header value is application that there's the whole value so yes we are it is so we've invention contains and yes it is able to test properly and and passing so similarly like this you can we can perform testing for headers as well so whatever headers were expecting you can validate them with the help of a TF then we have assert JSON payload is valid that means if I click nest next whatever data you're getting whatever response you're getting is it is it the right in JSON format that's what you're going to you're going to validate so assertive JSON response payload is valid I will test it and let's see if it gets succeeded yeah it's get succeeded because we are getting the data in JSON format if you're getting the data in XML and if it's data that data is valid in that case you can validate XML as well and how you have another step that is XML payload is well-formed that means it's valid that's how you can validate XML response payload as well now then we have examined JSON response payload element that means whatever whatever response you are getting is it is it within the right structure that element is present in your response so I can click on next now as you know it is definitely returning a number in that case what I can do I can maybe try to put some query maybe we are getting this we are getting this number and what what I can do I can I can try to check if I can get the same number so maybe you have this query and I will put number it calls you oh I will copy this one copy and paste it yeah doesn't matter I will make a ten as well it won't affect if I click on yeah I am getting the same sixty incident number when I send it call similarly what you can do you can use this system query in that case what I can do I can go to my test I can go here I can put a query parameter that is this poem query and I can put number equal to this one yeah just part of the demo and I'm saving this so it's saved and then I'm just going here now I'm going to validate it what I have to animate the element here what I will do I will click on next what is XML so we have to validate this on one I will go to JSON click on next I have to mention the element path now what that path is the path has result first /r a result slash incident and then I can put the value so I put the value maybe like this one and that's it let's submit let's see if it is able to validate this element I will click on run and then it will run the test and got failed let's see where exactly it is failing so ok it is not very matching with the operation you mentioned so you see like results I'm an expected element value is this an element name is there so the response payload value does not match well a specified operation and that's kind of strange right we mentioned the same value so the element first expected value is tests and if I see actual element okay so it is not returning the data we can we can definitely try to see this here in this particular not really we are getting the data yeah you can see here we are getting the data we have this number here idly I'm using the right format which is which is mentioned on ServiceNow documentation as well but I'm not sure the while it is not pulling up that particular response element because you can see even if I see the results hmm when I click here it says that expected element value is this and it does not match so we have this one and if I say the actual element value is that so I don't know why exactly it's not working ideally it should work but that's okay you can you can try in your instance maybe there's there's some issue or bug if that's a bug you can definitely raise it with service now I will show you the last step which we have and the last step we have is a third response payload I'll go next here I have operation contains response body or maybe is our try to do is and how I will do one thing I will limits the data I will try to just maybe show in response some number or maybe short description that's it no more data and I will send it well I will send and you will see this is the data I have and that's the data in JSON format I will go to my test I will protect you that's kind of a cert I have to do so first I will copy this and then I will paste it and so operation is this and I will click on submit I will just disable this one because that was giving error and I will now run this let's see if I'm able to get the pass it is failing that's okay response payload does not match with a specific okay it does not pay it is not you can see so it says a certain spawns payload is okay doesn't match with operation actual payload you can see ServiceNow has given the wrong spelling as well payload spelling is this one that's okay okay we are we are getting the whole okay we have given this suspend fields here but the the mistake which we did that we didn't add that parameter yeah how exactly it can filter it so in that case you have to open the racket go here add the header I will add one header that'll be system fields and I will add them and I will save it I will go to my test and run this time idly it should pass and it should not fail but it is again failing let's see that's fine even it is failing at least we have opportunity to troubleshoot we have a description that's not complete it says a pillow does not match with a specified okay I think it just just kind of maybe different format we have given if I think you have to write in this kind of format and if you will write in this kind of format so maybe I will copy this one maybe maybe I will not get the error now but anyhow you can you can because I use is but you can definitely use contains as well so I go here and now I put that right here and I updated when I update it I run the test run the test hardly yeah where'd God succeeded so that's definitely successful so basically the format was not right and that's the reason it was failing so overall this is how you can perform rest inbound integration testing in service now with the help of automated test framework I hope you like my video thanks for watching
https://www.youtube.com/watch?v=mEKLhtceDhM