 Let's look at an example of how to build a data-driven test I mean, what's the point of testing and then manually modifying we want to actually throw some data at this So I've already got a simple app. It's just got the tesla module in there There's nothing in the main and I've created a blank widget. We're gonna add Qtabug we'll add Qtest and We're gonna add some functions. So this is gonna be very similar to the last one, but we're gonna do it radically differently So I'm gonna say private and we want slots So we're gonna have a function called test age now. We want test age to test. Well data. We're testing an actual variable So we're gonna take this entire signature here copy that and I'm gonna put it first just so you can see the order in which these are called and we're gonna add underscore data So what Qt's gonna do in the background is it's gonna say go through every private slot Look for ones that have underscore data. Find the matching signature and generate the data for it That's kind of nuts So we're gonna add that add that So we're gonna generate some data here and we're just gonna say Qtest and Qtest comes built in with a Data container if you want to call it this way. So we're gonna add a column and This may actually kind of look like a database really So we're gonna add a string And we're gonna call this name We're gonna add another column hint let's call this age and Now we're gonna add some rows Because we have our data structure in place We're actually in the background using a model of some type We're going to just add rows and it's going to have to align with the data structure that we've just given it So we're gonna say invalid and of course because we have a string and then an age We have to add them in that order So we'll say whoops Let's say Bob is 190 years old Let's grab this And we're just gonna add a few of these so we're gonna say old and let's say I'm 44 and Heather's 25 Under age and let's say under age is The dog here the dog is 14 years old and One more Retired and let's say grandma's retired here and grandma is a ripe 90 years old That's it the zollars to it, so I'm just gonna say our data has now been generated and now we can actually move into our test So what we need to do is get the row data We're gonna use Q fetch So what Q fetch does is say hey, what are you really looking for so we need to give it the type and then Give it a variable of some kind Notice how we haven't actually declared the variable. We're just actually saying it's a type and here's the name. I want to give it So Q fetch in the background is going to make that variable for us So now we're fetching a name into our name string and an age integer Which aligns with the model that we just gave it Not truly a model in the background, but you kind of get what I'm saying here. So Q info we will cover models once we get into GUI programming I didn't want to do it here because it's not gonna make them a whole lot of sense talking about a model view framework if you're really Not seeing the view So I'm gonna say testing age and then we're gonna just do some simple if and we'll say if age is less than zero Or Age is greater than 100 Actually, let's change this to less than or equal to just change it to one So if age is less than one or age is greater than a hundred then we're just gonna fail this out Let's go ahead and grab this I'm gonna say age is less than 21. We want them to be an adult and then we're gonna say if Age is greater than 40 then we're gonna Q warn And we're just gonna say getting old there pal if that age is greater than 65 We're just gonna Q info this out Notice the case sensitivity here now when I say case sensitivity, we're talking about Q warn for example if I were to do something like this You have a Q warning and a Q warn don't get those confused Save this and we're gonna jump into our main and we're gonna do something a little bit different here So we're gonna say Q test and Let's include our widget and we're gonna take this whole main function and we're just gonna completely destroy it. That's right So we're gonna say Q test main and what this does is actually adds in a main function and we're gonna test the widget class You don't need to do this. This is just actually a really cool feature so what this is gonna do is it's gonna say hey create a main function and Use this class so it's gonna create an instance of this class and then it's gonna call the actual tests save and run And you can see our data-driven tests So first thing it's doing is it's knitting the test case The last thing it's doing is clean up test case and then it's generating our data The data is generated so you notice that happens before anything else happens the underscore data functions being called and Then it goes in and does the actual test cases So it's testing invalid testing old testing young testing underage testing retired. These are all things Out of you guessed it our data set that we handed this thing Invalid old young underage retired. So it's gonna go through and test each one of these for example Q info test age young testing age Heather is 25 and Test age young has passed. So now we're actually creating data-driven tests Unfortunately Rango under age is only 14 and he must be an adult. So we have a failure Really really solid example on how to do this. You can see we get our totals five past two failed zero skip zero black listed one millisecond Let's just face it. Qt is extremely complex and has a massive learning curve But once you learn it you can do just about anything Unfortunately learning Qt is a challenge in itself and if you've tried learning straight from the docs You've probably become easily frustrated while they do a really good job They're arguably some of the best documentation in the world They don't go that extra step and leave a lot of people guessing what to do. How do all these things interconnect? That's why I started developing videos. I've done videos not just on my own YouTube channel Which you're watching now, but also on the official Qt studios channel and I've started doing video courses out on you to me Right now I have the Qt core series it covers beginners intermediate advanced So it'll take you straight from hello world all the way up to building a complex Multi-threaded encrypted TCP server on top of that if you don't want any of this You can still join the void rooms Facebook group Which has a pretty flourishing group of developers and we discuss everything not just Qt. I hope to see you there