 Hwyl, rydyn ni'n meddwl yw Davos Smith. Rydyn ni'n meddwl syniad yw'r ysgolwyr ar y cynog, y mwyllgor yng Nghymru yn Ysgrifenni. Rydyn ni'n meddwl yw'r ysgolwyr ar y cynog ar y cynog ar 15 o 16 oed, ac rydyn ni'n meddwl syniad ar y cynog ar y Llan 11. Rydyn ni'n meddwl yw'r ysgolwyr ar y cynog, ymgylcheddau cyntaf o'r ysgolwyr ar yr ymgylcheddau. Rydyn ni'n meddwl yma ar y cynog, rydyn ni'n meddwl ymgylcheddau ar y cynog, ond rydyn ni'n meddwl sy'n meddwl ymgylcheddau ar y cynog. Rydyn ni'n meddwl ymgylcheddau ar y cynog, ein gweld ymgylcheddau ar gyfer ymgylcheddau ar y cynog, a rydyn ni'n meddwl ymgylcheddau ar y cynog ar y cynog ar y cynog ar y cynog. A'i bod llawer y gallwch wedi eisiau byddol ar y next talk ac硬iwch ar gael y cychwyn i'r annib i'r lyf. A dyma ychydig i'r bosodau, critics i'r cynog. Rhaid i chi'n gwybodaeth nhw'n gwybod y bobl yn ymweld, a'r cwrdd angen i'w'r gofod yn ddarparu, a'r gweithio a'r rhaid i'r lluniau allan yn ei wneud y fwy o'i arddangos yma, a'r gwneud yn ei chyfodol i'r rhai i'r blinol, a'r wych yn ymddydd eich oes oes y maen nhw'n yma, ac nid i'r gweithio a'r gweithio i'n gweithio i'r gweithio i'r gweithio i'r gweithio i'r gweithio i'r gweithio i'r gweithio i'r gweithio i'r gweithio i' dyna? Why does it matter? I've got to talk about 4 different places where it's really important to have automated testing in place. The first one is during the initial development. Now I'm a developer, I write a lot of Moogle code and during the development I try to make sure that I put automated tests in place right at the start because it's really, really good for making dweud o'r cwrs mae'n draw adas, mae nurwch amdylch yn dweud i ddargarol youfóoedd. Mae'n gweithio i'n dweud i ddargarol yn edrych, ac mae'n dweud wirthig yn dweud i ddweud i ddargarol youfóoedd. Mae'n rhaid, gallwch angen y byddau cyffredinol, a chweithio'n dwych yn argymryd i chi, a rhaidau'r cyffredinol, dweud â'u gwlad y bydddai'r cyffredinol caf, a'r bydd yn ei gennym, rhai, dwi'n enw i'r ffordd rwy'n diogelu eich gefnwriaeth, i gwaith unrhyw. Yn ddi'n meddwl i'w wneud i gael y gwaith, ddyn am wahanol o'r culte a'r cyffredinol.りu yw'r gweithio yn oed yn hati'r newid wahanol. Felly yw'n ddorol ar ôl, ond mae'n rhaid i'r cyffredinol yn rhan o fynd i'r newid wahanol, ac yna'n mynd iedd ei wneud imbryd i'r newid yw oedd maediat ei haf yn ystod popul i'r newid. ond if they have a sweet automated tests, that should ensure those features don't break when it comes to adding something new to it. On a very similar front, it's when you come to doing a Moogle upgrade. If you have noticed every six months a new version of Moogle comes out. I'm not saying everyone upgrades the new version every six months, or maybe takes it once a year. But still at some point, you need to know Cymru bod o'r plwgau sy'n gweithio'r cyfnodd y cyfnodd yw'r cyfnodd yw'r newid yn ymgylch. Ac mae'n gweithio'r cyfnodd cyfnodd yw'r cyfnodd yn fywr yn cael ei wneud. Dwi'n gweithio'r cyfnodd yw'r cyfnodd yn gweithio'r cyfnodd yn gweithio. A ffynol, y rhan oedd y troi'r plwgau arall o'r rhan o gweithio'r cyfnodd a'u'r cyfnodd yn gweithio'r cyfnodd ar y cyfnodd, mae'n dweud i'w meddwl y gallwch chi fydd yno yn ei gwasanaeth i'r gwaith o'r problemau. A wneud i'i gweithio'r cyfnodd yw'r cyfnodd yn gweithio'r cyfnodd yn ymwneud y cyfnodd yw'r cyfnodd yn gweithio a'r cyfnodd. Felly, wedi cael ei gwaith y gweithio ar y moment oedd y cyfnodd cyfnodd yn rhan o hyn yn ymgylch. Ond mae hynny, hynny ymğithio'n cyfnodd. A dy'n meddwl. First thing is, it can only test what you actually think of to test. So if the developer doesn't think to test something, then the automated testing doesn't do it. Also, it can't spot obvious problems. So it will tell you that that text there, the test worked was present. It will not tell you that the colour scheme is hideous. And it will not tell you that the text is overlapping and the wrong way round. But it will tell you that the words this test worked were present on the page. So it's not perfect, but it's a very good starting point. So there are two types of automated testing in Moodle Core. The first one is unit testing. That's really the very detailed developer-orientated stuff, the details of the internals of the code. And that's written using PHP unit. And the second one is what's called user acceptance testing in Behat. And that's more about testing through the browser, making sure that things appear on the page. And when you click on this and type this, it works. So I'm going to very briefly look at PHP unit first. Before I go on to that, there are things that the automated tests all have in common. They all set up a scenario. Then they do something with that scenario. And then they check that the results of that scenario are exactly what you expected them to be. So I'm going to give a very quick example from PHP unit. Now, I've chosen for this talk to look at the Moodle Forum because it's actually quite an easy-to-understand plug-in. And so it's got quite a lot of unit tests in automated testing core. So if you look inside the forum activity and any well-written plug-in, you will find a test subfolder. And inside that, you'll find a number of files. And in this case, I've picked out one called subscriptions-test.php. And it has this function in it, test subscription modes. So this is testing the different subscription modes, so make sure they actually do what you expect them to do. So the first thing I said, you need to set up a test. So here we have a little bit of code that's creating a course. You can see that, create course, pretty obvious. And then we've got some of you which creates an activity module. And then we're going to log in as a user. So that set user is logging in as if you're a user. And then we do something. In this case, the something we do is set the subscription mode to force subscribe, which means that everyone has to be subscribed to that forum. Okay, and then after that, we just do some quick tests to see, well, if I forced everyone to be subscribed, well, is the subscription mode forced subscribed now? Hopefully it is, yes. Is this particular user subscribed? The answer should be yes. Is this subscribeable? Can they choose whether or not to subscribe? Hopefully not. And so on and so forth. So we're just testing some of the interim interface. For non-developers, that's not so exciting. The hat tests, I think, are a lot more interesting for non-developers. And those are always found similarly in forum, in tests. But if you go into a subfolder called the hat, you'll find a whole lot of things ending dot feature. And in this case, I've opened up one called my forum posts dot feature. So again, we set up a scenario. So in this case, we've created some users and the following users exist, okay? And then it says, and the following courses exist. So it's created a course called course one. It's very imaginative naming in some of these. Occasionally you get bored and start mentioning Batman characters and stuff, but those are the time it's just course one, course two, student one, student two. And then we're enrolling the course, the following course enrolments exist. And then we're creating activity, a forum activity, strangely enough, because we're in the forum module. And then we log in as a student. And this is actually, we'll go to the browser and log in to that page as that student, okay? We make sure the following activities exist. And then we go through. And then we post some messages to forum. And then we go to the user profile page and follow the forum posts. So this is the do something section. And finally, we make sure that on that page, the text, how awesome is this forum discussion, actually appears on the page. And also the words, actually, I've seen better, should appear on the page. So what does it look like? Now, if I'm really lucky, this will work. So let's see if I can actually play this. Is that going to play? Here we go, there we go. It's just going to run this exact test that I've just shown you. And there we go, posting on the forum and submitting it, going to the, posting a reply, going to the profile page. And there we go, it's done it. That was a bit fast. So here it is again at half speed. So again, hopefully we can actually see it this time. Okay, welcome. And there we go. We're going to forum. We're posting a message. You see it very quickly types it in, posting a reply or asking a discussion. Then we're going to post a reply, I think. And we can see it typing in under the browser as it goes. And then it's going to the student profile page and then we can see the posts made by the student and we can see the discussion side of the student. It's still quite fast, but you can see there it is actually running and going through. So hopefully you'll be a little bit less scared to go and have a look in that test folder. Ultimately, why as a non-developer should you care about automated testing? Well, first of all, I'd ask you, do you care that the code on your site works? Hopefully the answer is yes. You should care about automated testing because Core Moodle uses automated testing like PHP unit and perhaps to make sure that the Core Moodle code works as expected. You should care because if you're going to download a third party plugin for the Moodle plugins directory or from GitHub, you must make sure that it has a good set of automated tests because that's how you know it's good quality code and it's going to be maintained and we can be tested against future versions. And you should care because if you're going to spend 10,000 euros, 30,000 euros on someone developing a custom bit of code for you and they deliver it without a full set of automated tests and hopefully now you know where to look to find out if they have given you automated tests, then they've only done half the job. If it's not there, then you have no way of being able to check it automatically when you next upgrade to a new version of Moodle. So, there we go. Any questions? Thank you for the talk. I'd like to ask you if the BeHard testing can check for overlapping features like buttons are not accessible for default user. It can test for a certain extent. So, it can tell if there's a button on the page but there's something on top of it, a pop-up on top of it so you can't access it, then it can do that. But what it can't do, it's not very good, I'd say intelligently say, all that text is overlapping. So, you still need some QA team to actually go and do those sorts of checks but it's very good for testing the sort of obscure features are not working. I don't have a question, I have to say, thank you, that was a great presentation, particularly I liked the fourth point when you're siren, why for merging in custom features and things because when people are merging, the collaborative communities we see here, what we see a lot is if you have very complex merge requests with different plugins we're merging features in, having those tests is a real help, that's something that we really see and there's a good way to evaluate, good quality code, so. Yeah. Fantastic. Hi, as a non-developer, so after the BAT testing has run its course and it fails, how do we know where it failed? Is there some kind of logging or? When you run the tests it will list out sort of all the tests that failed and which particular step they failed on and potentially if there were any debugging or error messages generated, it will tell you exactly what they were and that means you can then go back in and start investigating. Obviously from this perspective, for non-developers I'm not really expecting people to be running these tests, why I'm really encouraging you to do this, just make sure that they're there and actually go and read them, I hope you understand from the BAHAT that they're pretty readable, it's pretty clear what they're doing and it can give you a really good idea what the plugin does in there, but yeah, developers, you would get enough information to then go and investigate further. So it would just show up in the debugging info when you run the tests on the command line it will show you at the end, it will say this test failed on this particular, this feature failed on this particular step and this was the error message or it didn't find that text on the page, et cetera. But yeah. Yes, that was a good point there, it also generates, if you've got the setting on, it will generate a screenshot of the page and the full HTML of the page in the state it was in will be dropped into a folder.