Events Add an event Speakers Talks Collections
 
Virtual RubyConf 2020
November 17, 2020, Online, Houston, TX, USA
Virtual RubyConf 2020
Request Q&A
Virtual RubyConf 2020
From the conference
Virtual RubyConf 2020
Request Q&A
Video
Enough Coverage To Beat The Band - Kevin Murphy
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
Add to favorites
307
I like 0
I dislike 0
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
  • Description
  • Transcript
  • Discussion

About speaker

Kevin Murphy
Principal Software Developer at The Gnar Company, Inc.

Kevin is experienced in web application development, agile project management, and systems analysis. He is dedicated to executing the technical aspects of software development projects with a keen eye towards driving business value.

View the profile

About the talk

The lights cut out. The crowd roars. It’s time. The band takes the stage. They’ve practiced the songs, particularly the covers. They’ve sound checked the coverage of the speakers. They know the lighting rig has the proper colored gels covering the lamps. They’re nervous, but they’ve got it all covered.

Similarly, code coverage can give you confidence before your app performs on production and also tell you how live code is used (or not used). We’ll cover how to leverage ruby’s different coverage measurement techniques in concert to assist your crew and delight your audience.

Kevin Murphy

Kevin lives near Boston, where he is a Software Developer at The Gnar Company. He’s doing the best he can to cope with a year of concerts that could have been.

Share

Wow. Hello, everybody. Here we are again for the next set of sessions, if you have not been paying attention or have followed the channel Associated this talk, I recommend that you do that. So you can find out through browsing the channels in the open chat and I don't give an opportunity for you to ask questions, following up, or whatever is necessary. Looks like we have an echo. And see if we can figure out where that's coming from. Let's try and start this again and see if that will help. What were, what kind of

threat? I think probably. Oh, okay, so the Echoes isolate. That's good. So let me introduce Kevin Murphy. He's going to go through our next live talk, which is really exciting to me, don't forget to follow that slack channel, so you can ask questions in a follow-up and we will go for a while. I'm there. All right, without further Ado Kevin, it's all yours. There was a time not that long ago. Where people could? Safely Gathering crowds. And wait for that

wonderful moment where the house lights would turn out. The fog machine with kick in. Estate, light for turn on and a Bama, take the stage concerts are one of the many things that I'm missing about in 2020. but I figured, you know what I've got a captive audience here, What type of show we're going to help stage an entire tour of concerts using Ruby's coverage module? As a dimension, my name is Kevin Murphy. I'm a software developer than our company or software consultancy in

Boston. Massachusetts, or more accurately, these days in the couches, dining room tables, and makeshift offices in the Greater Boston area Bridge. You call the aptly-named start method. And here, we're going to explicitly asked it to start in lines mode, will pop the band. Play the first 10 shows the tour and let's see, we get back, we'll be get out. Of coverage is a big old hash and I've already condensed the output here to Let's dig in even further into one of the elements of this hash and explain we get back for results.

Either the keys in the trash are names of files that are executed, while coverage is running. The value of which is another hash where the key is, the name of the mode here, we explicitly asked coverage to start in lines mode. So thankfully we got lines back and then for a value here, in our inner array, we have And what that a real represents is. How many times each line in this file was executed? Well covers run order is important in this a ray. So this first item at index, 0 is how many times line one of this file was run? In fact, lines 1

through 6 or I'll run one time over the course of the first 10 shows when 7 is a special case. The new here doesn't mean that it wasn't executed, it be zero in that case cover just telling us there's something special about this line and that's that it considers it irrelevant Open up the string file and see were talking about it in line, 7 is an empty line. So if you look at the results of coverage and you saw a zero, you might take that to mean that there's a problem, or at least willing to investigate, right? Maybe you have

some dead code, you can remove or maybe you have a bug in your code that you're not running certain lines. That should be. But really, this is just an empty line. And what does it mean to even run an empty line or a comment or an end statements? I don't know when and coverage doesn't take a position either instead it provides the add semantics meaning to nil to tell you, you don't have to worry about this line. So we go back to our problem statement, were trying to figure out how many guitar strings we broke. So we can figure out the number of times each line in this file was executed,

if we go back to our implementation, will consider a string broken. When it reports itself is broken and that's online 54 of this file. I don't remember arrays are zero indexed. So to get the 54th line, we actually for index 53 and as a result of that, we have to be broke 16 strings over the course of the first 10 shows. And now if you believe in the statistical, significance of that week, and then place an order for the rest of the tour and the band can confidently play. The rest of the shows that they have the equipment. They need to be able to do so.

We're not going to move in to one shot coverage and for one shot we're going to help the band prepare for one very specific show. They've been booked to play a festival which is great news there, get introduced to a larger audience that they regularly. Don't play to the money's, pretty good and extra play a shorter set so they make more money for Less work. It does have a unique set of constraints them, particularly, there's a very tight schedule. There's a lot of bands of the bills need to make sure they get on and off the stage really quickly. So they're trying to evaluate some ways

to prepare down the amount of equipment that they have on stage, so that takes them less time to get on and off. and one of the things of the band uses a lot of our synthesizers, Multiple members of the band, play the synthesizer for play another instrument, you're probably responsible for also playing the synthesizer the band members need to stretch out across the stage to be able to reach all the synthesizers need to play at one time. He was the drummer, not playing the drums, but instead playing the synthesizer, Recent messages later to cross the stage and try to figure out. Can we

get away with not having so many of them for this one particular show. And as the name implies, the weight of a synthesizer works is that it synthesizes different sounds. You can store those sounds and things called patches. Those beastly act as preset that you can vent recall later quickly. So this is a Stave representation of the knobs, you might twist in the dials. You might spin in the button, do I press to make the synthesizer sound exactly the way you wanted to and having those patches being able to recall really quickly is very important because when you play a

note on synthesizer, you want to make sure you have the right patch set before. Playing the note, because we have the wrong patch set while musically. You are playing the correct. No, it's not going to sound like the song at all if you're using the wrong patch. Now, each synthesizer implements the way that they store, these patches differently. So let's just look at one example, manufacturer. And when you want to read the patch memory, that they have these patches stored on, they just use a case statement. The synthesizer has four buttons that you can use for

presets but not a lot. But when you press each of those buttons, it accesses different positions in memory. Ben wants to know is which of the patches, they're even using for this one show. The fight being. If we can figure out, which patches were using and not using me, we can consolidate something, but we got to check the results. It's going to take advantage of the fact that the band has to practice the set because we mention, they're playing a shorter show. So they're cutting certain songs out and they want to make sure the transition sound

right. It's when they practice that show the stage, just like we do normally we reach, synthesizers going to have all of the patches that we use. We'll have a band practice the show. But imagine what I need to do. So using coverage here, we're going to explicitly ask coverage to start in one shot lines mode. The band will play the set list and we'll see what we get back. welcome back looks really similar to Lyme's coverage but once again, dig into the details here, Look up a cash. The keys of which are again the names of

files that are executed, while coverage is running. The value of witches are another hash with a key is the mode of coverage being run and we got another array for the value of Ray was telling us how many times each line was executed. And this order was important. So index zero was lying one or does it matter in one shot lines, one shot. Just tells you if a line was executed or not even tell you how many times does a ray of telling us that lines 1 2 and 3 were all executed in this file. In fact, if you want to find out every line, we have this big old is Ray and these

are just is a line numbers. It's okay, go back to our implementation of reading memory addresses. We had this case statement, we want to know if we access and use these different Patches at all. So we keep track of these line numbers. We can take the output from coverage and just asked if those line numbers are in that a writer comes back. The results we find out that were using three of the four patches on the synthesizer. That's either good news or bad news. It's not a great candidate for consolidation but hey were using it a lot. So we probably need it.

Cuz he perform this exercise on every synthesizer on stage we might find one that we're only using one of these patches for and as long as we don't need to use both of those instruments simultaneously giving away for this one show of moving the patch on to that other synthesizer and then we don't need to load that sent on to stage at all. Now I recognize that if you're a sympathizer person you might be screaming that two of the same patches will sound radically different on different synthesizers and that's the majesty and beauty of these instruments and I'm with you but a bad looking for

a reasonable facsimile for this one show and thanks to one shot coverage being able to tell us which lines we accessed or not. We were then able to consolidate the amount of equipment we needed everything on stage, we didn't none of things that we don't have the van. Play, the festival setlist and have it still sound the way they'll be expected to. Once I was helpful here because it didn't matter if we use a pack once or a million times, we still need to make sure we have access to it during the show. Went out onto the second half of our set. And talk about

methods coverage, we're going to be helping out the lighting team. 19 has a bit of a problem. They have a spotlight right on the lead singer in the last couple of songs that shows that she has been going out when it should be. That be a problem for any light, but it's particularly problematic when it's front center on your stage. And let's just say the lead. Singer is a bit of a perfectionist, so it's in their best interest to make sure that they figure out what the problem is pretty quickly. Now, if you thought the band played with a lot of synthesizers, just

wait till you see their light show, like they're well-known for the lighting Rags. They bring on tour with them and they contract. I was special effects, firms and lighting teams to design light, that didn't even exist before just for their concerts, which is a lot to say. They have a lot of lights so many so that they can even keep track of which they're using, right. They might be using a light for only one or two songs and as the tour has gone on and they're playing different songs and moving things in and out of the setlist, they might be lights that they're not even using

but they don't know about it. And the one of the theories on the team is, maybe these venues just don't have enough power to be able to support all of these lights. And if we could find some way to unplug some of them, we will have enough power for the lights that we do need. Let's talk about how lightning works for our concerts at the lighting team were really another set of performers just like the band on stage. They just don't get any of the credit, but for every note of every song, they're keeping track of the visual aesthetic of how things should be looking on stage.

So for every note, they're turning lights on and turning lights on, and not just turn them on, but making sure they have the right colors and effects, and they're pointed the right way. And everything looks just the way it's supposed to. And now whether it be a projector or can light or moving, light or a Troublesome Spotlight. All of these different classes of Lights, respond to the trigger method. It's the method you call to turn the light on. And so we're going to perform an experiment on the

next show of the tour where we're going to set everything up. Just as we do normally light all the lights, plug everything in have the band play the show and it will tear everything down and put it back in the trucks and get ready for the next one. But we do this exercise. We are once again going to use our friend coverage to help us out. The timer going to use methods coverage because we're interested in knowing how often a particular method is executed not individual line. We don't care what happens within the trigger method of the can light or the moving light or the

spotlight, we just care that it was called at all. And so we'll have to be in play this, the show performance experiments in and we'll see when we get back. And I'll just looks a little different than what we've seen thus far. Do the same exercise we've done before and dig into one element and a half to get back. As has been consistent with the other modes of the key of this hash is the name of the file executed undercoverage, the Vaio which is a hash with the key is the mode of coverage being reported on in the value of

that hash is another hash where the keys are a bunch of identifying information about the method. And the key is the count of the number of times, that that method was executed while coverage was running. Let's zoom in and explode on this inner most hash, because I skipped over a bunch of elements and we'll go through one by one. We are talked about the far end the count, which is the value for the number of times that this method was executed under coverage, Not going left to right. This first identifying piece of information is the name of the class that were

talking about. Remember, the outermost hash key is the name of the file, but if I'll have zero or more classes in it, so this is helping us figure out which class in that file or reporting on. The second value of the name of the method and for our purposes, this is sufficient information from this. We can find out how often these trigger methods are being called on each of these different lights. But we have these are four numbers in here so might as well, explain what they are. And they're giving us some information to help Orient ourselves within the file. The first number is the

starting line. Number II is the starting column number and I have the same thing for the end with the ending line number and the ending column number. Please help identify where in the file this method exists. and so we're trying to find out if there are any lights that we're not using and we can see that our projector here, We set up and have ready to go, but we never even use it. So now the next time we roll into town and light the lights, Not so fast projector. We can just keep you unplugged and instead we'll only have

power going to the lights that we are using. And when making that change, hopefully that leaves enough power. The lights that are used throughout the course of the show because we were interested in knowing whether a overall method was executed, use methods coverage to help us with that. We didn't have a care about the details of which line numbers within the message were called, just that the method itself was called We're going to try closing number here today and for our last song together, we're actually going to help the band. Get ready for the last show of the tour.

One of their friends going to be in town and he's also a singer in a band. And they've invited him on stage to play a song and they let him pick which one he chose one of theirs, but it's not one that they've been playing on this tour. So in the show's leading up to our last show, the band's, when using soundtrack as an opportunity to practice so they don't make complete fools of themselves on stage. It's Elena. What song they're going to practice and the early afternoon, the amble on stage, plug in their instruments, tune up, get everything ready to go and they play the song.

And they're going through this exercise and something just doesn't sound right, but I can't figure out quite what it is. So they're trying to identify any way to analyze what's going on here. and I really don't have anything, but they finally say, like, look Our friend coverage has helped us out a couple of times. Let's see what I can do here. Initials, they don't even really know what problem are trying to solve, so they don't know. They don't really know what to ask coverage. So there's like look, let's just, we'll throw the kitchen sink at it. You can pass the all symbol

to cover that start and I told covers like, give me everything, you got run, everything will have the band rehearse, the song it again, we'll see, we'll get back. And predictably will we get back is a whole bunch of information, but I want you to take from the slide is not really the values in here, but hopefully some appreciation or understanding for why the data that we get back from coverage is structured this way in all the prior examples we explicitly started coverage with one mode but you can run multiple modes of coverage at the same time. And that's why I was

in a given file, you have, you can have multiple Keys representing the different kinds of coverage that were run. I don't actively look for which types of coverage were Ron on our song Here, we see what we have. Lines coverage, methods coverage and branches coverage. But we're missing one. What happened to one shot lines. So turns out there's a technical limitation in how coverage is written such that lines coverage and one shot lines coverage. Can't be run simultaneously and lines coverage can tell you the same information that one shot lines. Does just

presented in a different way using line coverage. You can figure out if a line was executed or not, you just also know how many times was executed. So when faced the opportunity to use one of the other coverage result results using one coverage, It's over going to go fishing here and just see if we can find out anything so we'll start. No, just go coverage by coverage and so we wanted to see if there any lines in our song that we're, we're not running truant and we're we're using all of the relevant ones, so there's really no help there

and it stands to reason that if we are executing a four-year-old at mine, then we're calling every method and that's also true. But we captured the information we had to ask. And that leaves us with branches coverage. I don't really know what we're looking at here but we got a zero so maybe there's something. So that's one last time, dig into the results of coverage and walk through. What we get back here, predictively the key of the sash is still unable to file undercoverage. The value of which is another hash

with a key is the mode of coverage being reported on the value of each of those entries in that hash is another hash, the keys of which are all of the conditionals within that file, the value of which is another hash the key of which is all the branches within that conditional within that file. What's zoom in on one of these branches and talk about all of this information is here. Maybe you guessed correctly. That the value here is the count for the number of times that this branch is executed what

coverage was run and congratulations if you did. You're correct. And I'll going left to right. This first identifier is a descriptor for the kind of Branch. This is an if conditional with a venn in else and this is the event part of that conditional. and branches coverage, each conditional and Branch get the unique identifier and that's what this first number is Enemies. Next four numbers are the same numbers we get out of methods coverage. The Starting Line number to starting column number, the ending line number and the ending column number. Unless you've actually

examples, as you can see, the branch starts and ends on the same line. And in fact, the entire conditional is all in the same line at Saturn restatement up. So we can use those call numbers help figure out that what the coverage of saying is that we never return this 10 back out of this if test. Open Amazon us to figure out if that's even a problem. Let's figure out what this code is even doing what this is doing is setting up a vocal effects on the lead singers, microphone for how echoey it should sound and the the song has a couple of verses and a couple of courses.

And we passing a number to the chorus method, to figure, out how ugly it should be. And it should like Wax and Wane across the different courses in the problem is it's just waxing or not waiting or vice versa depending on your perspective because the numbers were passing in here, never satisfy both conditions of the sniff test. So it always goes to the else condition But it should be going to both parts until we found natural bug in our code and the issues. We have a buy one error or like, you know, these course they shouldn't be zero-index, they should be one

indexed, it's only change. The number that we passed in this course method, and we run coverage. Again, we can execute both branches of this conditional. As a result about the song, sounds way, it should and the bank and go up on stage. The last show of the tour, invites a friend up and thinks down the way it should in the audience is none. The wiser that they had all this hard time. Figuring out what's going on I don't think the branches covers. They were able to identify that because lines coverage was telling us that you're you're good, you're executing every line this

file and I was correct. The issue is it was a coat. There were multiple code paths on one single line and only branches covered was able to tell us that you're not executing part of this line and Italy was on us to figure out does that matter. So let's take a break here before I get up on stage and wrap up. I'm talking about rubies coverage module. Andrew discovered module has four different modes that can help you answer for different questions about your code. You want to know how many times

each line was executed. You can use lines coverage if you don't care about how many times someone was executed because that was executed, you can use one shot lines. If you only care about how many time, sorry if a line was executed, one shot lines will provide a performance method over lines coverage because for the second through and time that align is running, didn't have to do that, bookkeeping to keep track of it. If you don't care about individual lines, but you want to know if and how often methods are called, you can use the athlete named methods mode. And if you wanted to go

into your conditionals and find out how off your branches are being executed, you can use franchise mode. If you're interested in using coverage in your application, but you want a little help, there are a couple of gems I can recommend if you want to use coverage to evaluate your test coverage, I recommend simple, but if you want to ask some questions about your production code, you can use the cover band. Jim, both of them, use rubies coverage module under the hood. If you would like to have a bit of a narrative description of coverage, as has been presented in this

talk, you can visit this GitHub. IO, Paige, a link will also be present in the chat and I will add one in the slack Channel after we get done here. On that page, you can also find a link to the a copy of these slides, a link to a repository that has all the code examples and I can learn a little more about than our company. If you're interested. I'm also on Twitter at Kevin underscore, a underscore M. I'm happy to connect you there and talk about any any questions you might have. But directly after this, I'm also going to be jumping in the slack channel for this, which is RC talk enough

coverage to beat the band and I'll answer any questions there. So we can talk about, you know, what concerts you've seen, what concert your tickets to this year and couldn't get to or we can talk about coverage, whatever you might want. So, I thank you all for being here. You've been a great audience. I thank you for your time and I hope you enjoyed the show. Thank you. Wow, thank you so much. Kevin much appreciated like to have. It said, jump on over to the slack Channel, answer some

questions. If you have any give Sam, a scuotto's joined him on stage for truly speaking. At least, you know, all the things off. Fantastic. So, thank you so much. Kevin much. Appreciate a really great talk, really enjoyed it. I always love the analogy or the comparison to other areas in the industry in the world. I come from performing arts background so you know I felt you I felt this I felt you hear I did I was there all the way. All right everyone else. Let's jump over to slack finish up things they're asked questions over there but I will say to you before you go we

are still looking for a handful of folks to join us maybe you could Kevin I have a feeling Kevin is a performer Baby. Who knows if you have the opportunity or want to participate in telling a story of your experiences or whatnot, don't forget. We're still looking for some submissions but otherwise see you over there.

Cackle comments for the website

Buy this talk

Access to the talk “Enough Coverage To Beat The Band - Kevin Murphy”
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free

Standart

Get access to all videos “Virtual RubyConf 2020”
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
Ticket

Interested in topic “IT & Technology”?

You might be interested in videos from this event

September 28, 2018
Moscow
16
179
app store, apps, development, google play, mobile, soft

Similar talks

Ariel Caplan
Backend Developer at Cloudinary
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
Soutaro Matsumoto
Technical Lead at Square
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
Eileen Uchitelle
Staff Software Engineer at GitHub
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free

Buy this video

Video

Access to the talk “Enough Coverage To Beat The Band - Kevin Murphy”
Available
In cart
Free
Free
Free
Free
Free
Free
Free
Free

Conference Cast

With ConferenceCast.tv, you get access to our library of the world's best conference talks.

Conference Cast
816 conferences
32658 speakers
12329 hours of content