In this video, we will understand what are test cases and why do we need them along with the difference between unit and integration test case, we will understand the need for a writing unit test case in a project with the help of an example. In the second part of the video where we will learn how to write test cases for an API along with some good practices. If you have any questions on this topic please do ask in the comments and do share the video with your friends and do support the channel by subscribing to it. Happy iCoding.
I really like everything on this channel and the fact that you reply to each and every comment. Man!!!! you are doing a splendid job with so much of passion. A video on VIPER implementation from you will add something more to this channel. Thanks once again. PS: I would really like to buy you a pizza or a beer :p hehehehehe.... Keep it up!!
Thanks for the kind words Anurag it means a lot, VIPER is planned for next year along with other complicated topics which will be simplified soon. I also share some short videos on Instagram like a 2-3 min reels on swift so do check those out as well Pan base pizza is ❤️ but for now just share the channel with anyone who wants to learn swift or with your iOS group of company or WhatsApp or LinkedIn 😊
Few of your subscribers are known to me i have shared your channel to them and they are subscribed to you. And also I do want to buy a Pan pizza then for you. 😅😅
I guess I would never stop making videos on Swift or anything related to iOS development, as when I was down and demotivated the iOS community took care of me and for that I am grateful and want to continue this work.
This is called quality content… I have seen few videos of yours from yesterday and i would say it’s great. my company is going to change my team and in the new team, I have to write test cases and Jenkins will take screenshots. These types of videos has limited audience still you are creating with full of passion so thank you so much.
Much appreciated! Thank you for your kind words. I am glad this channel and its content are proving to be helpful. I also share some short swift content on my instagram account (@codecat15) so do check that out as well :)
Code coverage is something that's ignored by many, and devs feel that just by adding test cases they are doing a good job but then really it all boils down to how much of your code is covered with test, are you performing integration test with happy and failure path scenarios coz just like for every if condition we need an else similarly for every happy path we need a failure path test cases as well. I make sure that when I get the PR, the code coverage is more than 70% else I reject that PR, well I do have that automated in my build configurations hehe
Very useful and conceptually explained all the things very clearly. Thank you Ravi sir for creating such a very fundamental and useful content for the community..!!
welcome to the channel Vaibhav, I am glad this video was helpful to you. Please do share this with your iOS group or with anyone who wants to know why test cases are so important and always feel free to ask question I will be happy to answer them
Video editing and all video delivery are great... Keep it up and video on all swift. docs topic ... For every chapter and each topic ..up to Advance level SwiftUI etc Thanks
Hey Sambit, i am glad this video was helpful, do feel free to ask questions on this topic and do share this video with your iOS group. Merry Christmas to you too buddy
Hey @ravi. I am really a fan of yours. Whenever I want to learn anything in iOS then I search in your channel first and then I go through it. Your way of explanation is just awesome. Now I am doing unit testing for my project but using Quick and Nimble, Can you please make a video on Quick and Nimble especially UI Tests?
sir, i have a project with a chatting screen too in which i want to chat and along with i want send multiple image name, url, or multiple documents so how to do it??? i did chatting for both sides receiver as well as sender and it is working well using table view.......but inside tableview i wanna take a collectionView in horizontal scrolling in which i want to send a url of image or any kind of documents(must be multiple) and and horizontal rows of must be tied with the row of tableView cell's row in which i am sending message but not others......don't want to use any third party or firebase..........so plz help me
Hi I love watching your sessions, it helps me a lot, I have request can you please make some videos on vip clean swift and unit test cases in vip clean swift
Hey Suhas can you elaborate more on the api response model please coz am sure the api series takes care about such models but i just wanted to be sure before I answer this question
Sir, I am getting error like this : /CoreData:1:1: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x7fb68fc515d0, store PSC = 0x0) I am not using core data in my project although its showing like this !
I can show local notifications and cover all grounds with that but for push notification i need my own personal account and cannot use company account and the issue is I don’t have a personal account for APNS so showing just theory is something I don’t want to do coz for push notifications theory adds a less value than practical
Hi Ravi, Thanks for the video , was really looking for some test cases tutorials. I want to ask that the scenarios that you have passed through the test files, I also need to follow the same approach in my controller files too right ?
Can't we use protocol default implementation for logics instead of hard coding? Can't we define a protocol which we use for our logics in ViewModel/model/validator & use the same logic in test case? For ex. Protocol SomeProtocol { func getFullName(fName: String, lName: String) -> String } extension SomeProtocol { func getFullName(fName: String, lName: String)-> String { fName + lName } } struct ViewModel: SomeProtocol { } Class TestCase: SomeProtocol { XctAssertEqual(viewModel.getFullName("Code","Cat), self.getFullName("Code","Cat") //with this approach we can test all the values at once }
if i understand that right, you want to use the same protocol and write the business logic or should I say code from the view model or other layers in the extensions? Correct me if i got that wrong please but if I did get that right my question is why do you want to do code duplication at two places and what's stopping you to directly use the concrete implantation?
My point is It is better to re-use the same logic instead of hard coding the logic in the test case. For example If we are reading first name & last name from a JSON file, it will be easier to loop for all the values & assert In test case. func testNames() { users.forEach { user in let actual = viewModel.getFullname(user.firstName, user.lastName) let expected = getFullname(user.firstName, user.lastName) XctAssertEqual(expected, actual) } }
@@nagarajvrao7249 calling an actual API is preferred and let me tell you why Nagraj, sometimes when the server folks change the response key value then it will be easy to detect such hiccups because you are hitting a real server and not mocking the response from the server and I have had my fair share of pain in the past because some creative developer from the API team had different key-value pair on dev and different on QA, and if I did not have test cases I would have never caught such fantastic work of art done by the API team later i came to know that their deployment was failing to QA and they had no process so it was my test that caught it. I know once the QA was down and it was my test cases that caught it because my tests were failing. Having a JSON file locally will hide these kinds of issues
1.We can't call the API if it isn't ready 2.If the API is dependent (on token...), we can't hardcode it. So Instead of directly calling the API, I thought of reading it from the local JSON & parse. Ofcourse If in the backend if the key value is updated, we can update the local JSON as well. I didn't get what issues you faced/ one might face? Can you explain (if not here may be in the next video) In your case key-values for development & staging were different?
Api when its ready can have issues and the local json file will never ever catch that issue coz the local file is not the place where api developers will make the change, or what if there’s a logical change? Also it will be a pain to maintain that local file in sync with server response, we cannot be sure that api response will never change coz changes do happen and we won’t work on the same project for 5 years someone else will maintain or pick it up So when they look at this wonderful test that pass but in reality due to server response changes or server not being live you are not getting the response so the test is really not helping us, it defects the whole purpose of having a test case in your project. Having a test case which does not really hit the server is not doing us any good, it will hide the potential issues that can arise on the server, the margin of error is a little high if we are not hitting the real server. The code that you will write to fetch the data will hit the server and not local json file so why have a local json file for test and a different route for the real implementation? The idea of test cases is to capture every potential bug and not to hide them, the local json file hides it as its not calling the real server.
As i said earlier this is the video where english and hindi is mixed, but i am working on it and i assure you that next time it will be pure hindi so apologies for the same 😊
In this video, we will understand what are test cases and why do we need them along with the difference between unit and integration test case, we will understand the need for a writing unit test case in a project with the help of an example. In the second part of the video where we will learn how to write test cases for an API along with some good practices. If you have any questions on this topic please do ask in the comments and do share the video with your friends and do support the channel by subscribing to it. Happy iCoding.
I really like everything on this channel and the fact that you reply to each and every comment. Man!!!! you are doing a splendid job with so much of passion. A video on VIPER implementation from you will add something more to this channel. Thanks once again. PS: I would really like to buy you a pizza or a beer :p hehehehehe.... Keep it up!!
Thanks for the kind words Anurag it means a lot, VIPER is planned for next year along with other complicated topics which will be simplified soon.
I also share some short videos on Instagram like a 2-3 min reels on swift so do check those out as well
Pan base pizza is ❤️ but for now just share the channel with anyone who wants to learn swift or with your iOS group of company or WhatsApp or LinkedIn 😊
Few of your subscribers are known to me i have shared your channel to them and they are subscribed to you. And also I do want to buy a Pan pizza then for you. 😅😅
Please do not ever stop creating videos , soon your channel will be famous , it is slow process but then indeed a permanent one it will be.
I guess I would never stop making videos on Swift or anything related to iOS development, as when I was down and demotivated the iOS community took care of me and for that I am grateful and want to continue this work.
This is called quality content… I have seen few videos of yours from yesterday and i would say it’s great.
my company is going to change my team and in the new team, I have to write test cases and Jenkins will take screenshots.
These types of videos has limited audience still you are creating with full of passion so thank you so much.
Much appreciated! Thank you for your kind words. I am glad this channel and its content are proving to be helpful. I also share some short swift content on my instagram account (@codecat15) so do check that out as well :)
@@CodeCat15 Sure, will subscribe you there also, thanks a lot again brother for the quality content.
Indeed @pushpender
Excellent intro to Unit Test Cases. I liked mention of Code Coverage and its importance. #CheersToCodeCat15
Code coverage is something that's ignored by many, and devs feel that just by adding test cases they are doing a good job but then really it all boils down to how much of your code is covered with test, are you performing integration test with happy and failure path scenarios coz just like for every if condition we need an else similarly for every happy path we need a failure path test cases as well.
I make sure that when I get the PR, the code coverage is more than 70% else I reject that PR, well I do have that automated in my build configurations hehe
Great work. keep posting videos on different topics related to iOS development. Kudos to you.👍
Thank you @polu and welcome to the channel
Very useful and conceptually explained all the things very clearly.
Thank you Ravi sir for creating such a very fundamental and useful content for the community..!!
You are most welcome, do share the video with your iOS group and always feel free to ask questions
great video Ravi...
Definitely your video will add more value in to iOS engineer...
Keep it up bro....
Thank you Yogesh, am glad the content is helpful. Do consider sharing the same with your iOS group 👍
your content and efforts are much appreciated
welcome to the channel Vaibhav, I am glad this video was helpful to you. Please do share this with your iOS group or with anyone who wants to know why test cases are so important and always feel free to ask question I will be happy to answer them
Video editing and all video delivery are great... Keep it up and video on all swift. docs topic ... For every chapter and each topic ..up to Advance level SwiftUI etc Thanks
I will try my best Karmjeet and thank you for your kind words
It was really an Awesome video! It is very helpful for me, Thanks 🙏 & Merry Christmas 🎄
Hey Sambit, i am glad this video was helpful, do feel free to ask questions on this topic and do share this video with your iOS group. Merry Christmas to you too buddy
Superb and Excellent explanation ... 👌
I am glad this was helpful 👨💻
simple explanation yet very informative content.
Hey @ravi. I am really a fan of yours. Whenever I want to learn anything in iOS then I search in your channel first and then I go through it. Your way of explanation is just awesome. Now I am doing unit testing for my project but using Quick and Nimble, Can you please make a video on Quick and Nimble especially UI Tests?
Your explanation is awesome Ravi sir. I really loved this video 😍❤️. Keep posting such videos 😊.
Thank you so much 😀
Very Good one. Thanks!
Glad you liked it!
I am a big fan of you
your explanation is awesome
Thank you so much 😀
Great work . Keep on more videos
Hello Anshu, welcome to the channel and thank you for your comment :)
sir, i have a project with a chatting screen too in which i want to chat and along with i want send multiple image name, url, or multiple documents so how to do it???
i did chatting for both sides receiver as well as sender and it is working well using table view.......but inside tableview i wanna take a collectionView in horizontal scrolling in which i want to send a url of image or any kind of documents(must be multiple) and and horizontal rows of must be tied with the row of tableView cell's row in which i am sending message but not others......don't want to use any third party or firebase..........so plz help me
Great Content
Yar kya bat hy Ravi bhai ❤❤❤❤
Can there be a source code , which is hard to write unit tests for?
Hi I love watching your sessions, it helps me a lot, I have request can you please make some videos on vip clean swift and unit test cases in vip clean swift
Excellent explanation
Glad it was helpful! Kartheek
Nice example!
Glad that was helpful Dhaval
keep on making such videos...
Thanks Vaibhav, I will surely keep on sharing whatever I learn or implement something new with everyone
Simply awesome 👍
Good job
Thank you, I am glad this was helpful.
Kudos bro..
Thanks for efforts to make a video. Can you make a video on API response model.
Hey Suhas can you elaborate more on the api response model please coz am sure the api series takes care about such models but i just wanted to be sure before I answer this question
Hey Ravi thanks for your video, i want to learn How to made SDK can you pls get a session of SDK Creation..it will helps to lots of people ..
Sir, I am getting error like this :
/CoreData:1:1: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x7fb68fc515d0, store PSC = 0x0)
I am not using core data in my project although its showing like this !
You sure you are not having an xcdatamodel in your project? Can you also check app delegate to make sure there’s no start up code for core data?
@@CodeCat15 Yes Sir ! I am sure . I can also share a GitHub link
yeah sure go ahead, share the link please
@@CodeCat15 github.com/KurbanAli6615/ShoppingAppIOS
Sir please replay ASAP
@@CodeCat15 Sir i have found error. Its showing error cause of assets. I have entered wrong type of asset
hey CodeCat, please make a video on types of notifications.
I can show local notifications and cover all grounds with that but for push notification i need my own personal account and cannot use company account and the issue is I don’t have a personal account for APNS so showing just theory is something I don’t want to do coz for push notifications theory adds a less value than practical
Ok thanks. If you get time then start memory management topic also.
Love from Pakistan bhai level ha apka
Thank you 🙏
thanks for video!!
Welcome Shashank, please let me know if you have any questions on this topic and do share this with your iOS group on WhatsApp or Facebook
Hi Ravi, Thanks for the video , was really looking for some test cases tutorials. I want to ask that the scenarios that you have passed through the test files, I also need to follow the same approach in my controller files too right ?
when you say controller files, do you mean UI test cases? or something else?
Hi Sir, could you please share some UI test case demos?
Sir can you make video how to make project from basic step by step how to do Start and end in hindi .
Can't we use protocol default implementation for logics instead of hard coding?
Can't we define a protocol which we use for our logics in ViewModel/model/validator & use the same logic in test case?
For ex.
Protocol SomeProtocol {
func getFullName(fName: String, lName: String) -> String
}
extension SomeProtocol {
func getFullName(fName: String, lName: String)-> String {
fName + lName
}
}
struct ViewModel: SomeProtocol {
}
Class TestCase: SomeProtocol {
XctAssertEqual(viewModel.getFullName("Code","Cat), self.getFullName("Code","Cat")
//with this approach we can test all the values at once
}
if i understand that right, you want to use the same protocol and write the business logic or should I say code from the view model or other layers in the extensions? Correct me if i got that wrong please but if I did get that right my question is why do you want to do code duplication at two places and what's stopping you to directly use the concrete implantation?
My point is It is better to re-use the same logic instead of hard coding the logic in the test case.
For example If we are reading first name & last name from a JSON file, it will be easier to loop for all the values & assert In test case.
func testNames() {
users.forEach { user in
let actual = viewModel.getFullname(user.firstName, user.lastName)
let expected = getFullname(user.firstName, user.lastName)
XctAssertEqual(expected, actual)
}
}
@@nagarajvrao7249 calling an actual API is preferred and let me tell you why Nagraj, sometimes when the server folks change the response key value then it will be easy to detect such hiccups because you are hitting a real server and not mocking the response from the server and I have had my fair share of pain in the past because some creative developer from the API team had different key-value pair on dev and different on QA, and if I did not have test cases I would have never caught such fantastic work of art done by the API team later i came to know that their deployment was failing to QA and they had no process so it was my test that caught it. I know once the QA was down and it was my test cases that caught it because my tests were failing. Having a JSON file locally will hide these kinds of issues
1.We can't call the API if it isn't ready
2.If the API is dependent (on token...), we can't hardcode it.
So Instead of directly calling the API, I thought of reading it from the local JSON & parse.
Ofcourse If in the backend if the key value is updated, we can update the local JSON as well.
I didn't get what issues you faced/ one might face? Can you explain (if not here may be in the next video)
In your case key-values for development & staging were different?
Api when its ready can have issues and the local json file will never ever catch that issue coz the local file is not the place where api developers will make the change, or what if there’s a logical change?
Also it will be a pain to maintain that local file in sync with server response, we cannot be sure that api response will never change coz changes do happen and we won’t work on the same project for 5 years someone else will maintain or pick it up
So when they look at this wonderful test that pass but in reality due to server response changes or server not being live you are not getting the response so the test is really not helping us, it defects the whole purpose of having a test case in your project.
Having a test case which does not really hit the server is not doing us any good, it will hide the potential issues that can arise on the server, the margin of error is a little high if we are not hitting the real server.
The code that you will write to fetch the data will hit the server and not local json file so why have a local json file for test and a different route for the real implementation?
The idea of test cases is to capture every potential bug and not to hide them, the local json file hides it as its not calling the real server.
post the video English language
please speak hindi🙏
As i said earlier this is the video where english and hindi is mixed, but i am working on it and i assure you that next time it will be pure hindi so apologies for the same 😊