Assertion : Contains & Not Contains

A free video tutorial from Automation World
Automation expert at Automation World
14 courses
68,057 students
Learn more from the full course
WebServices/API Testing by SoapUI & ReadyAPI - Groovy |30+hr
Detailed Groovy + Certification Coverage + Soapui tutorial, Rest API Testing, Soap UI Free & Pro
30:52:22 of on-demand video • Updated January 2025
Ready to work on real time Soap & REST API automation project
Able to implement SoapUI on your work place or will also get ready for High Paying API Testing Opportunity
Detailed understanding of WebServices/ API and its automation using SoapUI
Detailed understanding of Groovy Scripting and its implementation in SoapUI
Ready to work in SoapUI Free as well as Pro Version
Ready to develop reusable & maintainable framework for API Automation
English [Auto]
Welcome to the testing world. In this session, we are going to cover assertions. We are going to cover two assertions in this session. One is contains, other is not contains. First we need to understand what do you mean by assertion? So whenever we are doing manual testing after running each test case, we are comparing actual result with the expected results. If actual result is equal to the expected result, we are setting it pass. Else fail. Same like manual testing in soap. Whenever we want to compare actual result with the expected result that can be do by using assertions. To summarize it with the help of the assertions, we can compare actual result with expected results. We have different type of assertions in this session. We are going to cover two assertions. One is contains, other is not contains. Moving to my soap project. So here I have a project. Inside the project I have a test suite. I'm going to create a new test case. So right click on the test suite, select test case. So case one is the name of the test case that I have given here. I don't have any step in the test case, so I'm adding a step. Right click on the test steps, add a step soap test request. I mentioned the name step one here. We have a lot of services. I'm going to select the service, get country by country code. My step one is created. I want to test the particular step is working fine or not. So I have given input. I n is the country code. I'm running it and here we are getting response. From the server. So now I have a test case in which I have a step to hit service. In this step, I'm hitting a service by passing country code as an input and we are getting some output. So now I want to set some assertions to make the assertion. I'm going to a particular step and here on the step we have this icon. Click on the assertion, icon and first assertion we are going to cover is contains. With the help of the contains assertion, we can validate some text which is coming in the response. So here my response is this and I want to validate this response should contain text. India. So I'm comparing like the response that I'm getting in the response we should have India as a text, you can ignore the case. So I'm ignoring the case. It might be possible that we are getting India in capital letter or in small letter or in mixed case. So I'm ignoring the case. Later on, we are going to learn how to make regular expressions. So if we are writing some regular expressions, we can make this check on. Click on. Okay. And here we see a section is added, which is a container section. It is getting passed because as of now we are getting India in the result. I'm going to execute the same test case with another data and this time I'm passing the data us. So I'm running the test case and here we can see my test case is getting failed. Because my test app is getting failed. Go to the test tab and here we can see it shows your assertion is getting failed. Double click on the contains assertion and we are expecting India, but in the result we are not getting India from the server side. With the help of the container solution, we can validate data which is coming from the server in the form of response. Before moving to the next assertion, I'm setting this country code to in. Run it again, and this time it should pass because my country code was in. So in response, we should get India. So that is the one assertion we have covered is contains. Second assertion I want to move on is not contains. So sometimes we want to validate. Particular text must not come from the server. I'm making one more assertion. I'm going to the property contents. And here. We have another assertion is not contains. So not contains. We can validate the text that should not be coming from the server. So I'm saying in any case, we should not get error text from the server. So I set error as the content that I don't want to see in my response. I ignore the case. And click on. Okay. So here, as of now, all the sections are getting parsed. I have made two assertions. Over here is a contains and not contains. If we want to validate some text must be coming from the server. We can use contains assertion and if we want to validate some text should not come from the server, we can go for the not contains assertion. Thanks for watching this video.