Merken

Sustainable way of testing your code

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
yeah yeah 5 adjusted hello the human again
are my name is a gene and I work as a team leader scoping out and I was like enough or a few was 2 years to work in different areas of IT like on games for social networks all collectible onion-like created but just for a short major part to solve for my job was to review code and I might say that the readability of tests and as we see now is not really
good enough but actually tests are important to our work we can if we look at the top 100 most start to produce that the the top so we can see that the
20th 3 % of code is like editing desk test so this means that if your job is to just to read through of the code of this project that you would spend 2 hours a day and just 300 and just became more and more are important and even from this 100 products of 34 products have revision history as many as 5 years deep so we can take the clique look into this percentage of test to their code the tests and we
see it steadily growing and if we take a look at some absolute metrics like a number of lines of code we can see that a growth is
even more significant in from 100 to for the 3 southern delight to nearly half a million lines for justice so the so if we take a look at some general test renewable source yeah this is how almost of tests
are written by at least 1 of the ones that I see but but when we look at it we can do better job of describing our intent that means that when other people would agree this called the wouldn't have answers questions like what is called these is that actually guess what it's supposed to be and if there is an error in the course of the test run was it because of the is there is a Croat or because because test is so what actually is test how can we understand the test consists of 3 main things the 1st 1 is environment environment in which we have before we just something it could be no special environment could be fixed date and time the could be the cutest and some chat service and with the profile you another thing is what we actually test what are we can test that to and multiply by 2 equals 4 I wouldn't yesterday so we can only these have fictional the universe tried to swear and publication and after each you and we have some expectations this means that we expect that to multiply by 2 equals 4 that's just the google it is correctly adds up to severity there would be banned from moment to refuse to so nearly the indicator the father of the Caribbean development Denmark published an article where he proposed and you know and then tinplate to describe the RCB here take a look at Wikipedia examples here 1st aligned described following a lot would have we have customers who have is what the switch from us would have stopped with the iterative with test that went so that is the term then the heat to them number of selectors adults toppling trees but 1 on and this is a very clear about where it clearly where we see what we we care what we do and what we want to do in the result in pure during development they right and this test as the text so managers result any programming experience good arises volume users out but and but they have additional layer of transforming text to actually go From benefit from this template we actually don't need that Claire what we can do is simply extract methods generate an environment to the method by which start with word given and so the same with when them and let's have an example I showed you this not as before who what we just here is when registered a wonderful for centuries it doesn't it is the same thing twice so same error wouldn't appear twice in the sentence so so let's take a look what environment for creating letters environment so we move to a separate matter same for actually we can see that there's 2 options it's a little bit alarming would talk about it the emitted later and what's results so not when we transform code in this way it's much better took and understandable what it does and what we expect it to actually when we have would want to actions so it's a good allotments and because we almost never wanted 2 actions in our code because we want to check that progressing from 1 state to the environment with an action we get to another state and when the 2nd action would do we want to generate that previous state and the 1st action we just moved to a separate so I didn't highlight covered collided but you can see the 2nd test method self given Hendler register so this is where we describe what we had at the beginning of also at all when you it into little words we can see 1 something wrong with what we wanted to do so here last from last expectation which that's that number of sensors cameras register actually what we want instead is to change that every sentence centered on the register too easy and so on we more to another method of course we change the hearer I do with if you and another thing when users and developers firstly approach system plate as they tend to put everything and I mean everything in the code itself so it's theories character it's kind against common sense wouldn't news we have a setup so common and don't be afraid you still checkups at the stop when you read this phone right action but this is a good way to structure single test but single test is not only in our problem and as we I also want to organize regular editors file of which was it's the consider world so what multiple a test we have better organized so let's take a look at another you so if you take a look at the requirement that has some commitment h of have on the environment and like salt water fresh water and this is in addition to our where the majority of space is taken by plants so this is kind of like classes so we we can take a signal so the here is an example of this occurrence with and we see that as inherited from each other and also we will want to check single-minded there's a lot of money could be but this methods on the top of class and inherited but each every 1 of but of course was a quorum would have a lot of fish and you there always such that my mentor district would have just like this it's a lot of repetition and I'm a lot and there could be a hundreds of cases for example if you just embarrassing for its extract removing malicious code from there are actually could be 100 OK so we don't want a sexual interest usually it's strong form In a little so have require and for each data we look through we checked that we do some action we test the same but it's just a little bit better than if I can't stress enough how bad looks Africa's for this particular case if there is an there are ways the fish you don't know well there errors just as they always every other future always some particular fish I but is this information is very important because you can spend half a day looking into a place where you shouldn't look for this particular problem because the problem is somewhere else and you would see this if you immediately have results from which has passed which don't off here for example we that there's a last for grouping and from
goldfish and don't last for asthma and vulnerable to you're training could be what they call those connected because you set of something else at the moment and thinking about it you would be able to find exact spot which I unites those particular problem so how do we want to translate data to separate test I would like to know is parameterized model which like this
and by the way if you don't know this month's on those parameterized updates and actually applies not just from knows but fighters and you need to also you transform test so on test methods now have parameters you can see after so there is a fish parameter and so you will right your code on your data in last decade decorate much unfortunately particular formal spectrometry parametrized there is a problem was inheritance so if we inherited from freshwater requiring special require and take notice that is the different data so we change družba programming and we don't just 4 levels Our obstetricians could be either we're on tests in Dutch aquarium just for this stupid orbits unites all of them and transport and Leopold I had to and that those 3 unfortunately what's actually happened in this we have forecast for each on the aquarium and what happened here so you would understand that we have 4 tests from freshwater aquarium we replaced for those we have and the the last this is just a left over which is inherited from previous so far it's files and it's not something the but it should be considered so what do how can we apply inheritance profile artists so all rules would be to have just parameterized like most merger might well regiment parameterization like knows is good enough but they need to be able to deal with here so inheritance is not also we probably don't want to repeat each test each time of 4 I character Descartes all we wanted to to be defined in the parent class and seamlessly use In the child cases present we don't want to apply it we don't always want to apply all the data from parent cases to the chair on cases so we need a way to control this so this girls due who would be ah region to the next environments for parameterized personalization we need to apply a single test method to different data as much as for the character does not an interior tons of Dessau itself what we need to so this is just an access to parent cluster and we can extract and that of and orthogonal execution what we want is a way to exclude that so let's take a look at what Python Jules and approaches could help us to deal with is called the greater I use the most important part of parameterization it's used in every approach which I would show and unfortunately you usually you see you have is diminished to just create a new function function which would some called before all later you by but being functions of function or function the character is actually transforming you watch almost anything you could see this out for example keep you from the character of unit test it so transform function dependent on the condition phi either to original function autumn sky on function traces the film because of can be also applied to classes not only find
this also to transformation of the original classes so how would we have played a character truck achieving of but
most version part of parameterized show us a a very good way to define that it's clear in the stimulus or not we articulate each test case with with that of the it's requires but on the Declaration of doesn't create multiple test so what we need a way to transform this function with a sign that accrued to to multiple test cases some here we just assign to the matter not in any way you want and to with 2nd iterator are we take this class we have all this methods defining and for those methods which defined parameterization we create additional measures With this approach we have started desperate relations but it's not very good for inheritance it's applicable because you can do this but for each cluster which inherited from this article on from this test unit
again to reply is the character for new test because on but what we simply did here used instead of some test case where created some test case was more methods it's not a plan be to its child looking another approach
would be medical all reach is a way to configure how you create typical approach is and we would use typical approach here is we have a name who have a basis which is all parent clusters of this particular case and who have a name space which is dictionary of methods parameters from which we create this square so what we can move manipulate was dictionary before created this class of all we have sometimes which
have got assigned which arise from through all of them and for those we for those who has we and some keys and well to this namespace it's seamless and it is working with inheritance so that when you create the Arab child test cases this behavior is also transform them so unfortunately
with medical and there's also a tradeoff when you have that it's requires that each medical us is inherited in India chain not of some 3 solar well it's not a problem for your single bird when you start packaging things are when if there is 1 with a class in 1 package and 1 medical us with another party and they not correlated with each other you users couldn't be able to deal with them not to use both so this approach is useful at some extent but also well
yeah but we can also notice that return of some class but and so on so France is as approach and its use by knows tries of when he characterized by it's it's actually a listed on us frames of course and it's and that namespaces where cook cursor is our integration courses in so no sperm tries
take a frame from which it what is aggression was cold and each it is inject your the method there and also so it's here namespace would be definition of art clusters freshwater and these transformed like that not it's like we were written in this right I I'm with a little bit short of time so I quickly approach last last 1 of my favorite before that here it is very understandable why we can't approach that way we can to get parent from here because at that very moment we don't have classes to get parent from where just defined in the namespace so with frames we can't target apparently so my favorite 1 use custom Lauder of off unit all orders are responsible for gathering information gathering tests from what you cross and created since from from them we don't need actually
anything at this point except to Mark was dead and so we don't have to think about inheritance what we have here is something like this we get names we iterate through all the names and if it has some that we can extend of way extend
out so if it's not we create usual now this is actually worth mentioning that unit test users slaughter to create different intensities instances for each test method so it's not 1 class with a lot of this week what was a lot of methods but a lot of instances for this class which has a single men Service message for forward so so you can vary read through it and it's we're understandable here of what we would do we rate that and when we approach actually just the on test we create additional tests wouldn't change anything to cause we just decide if we want this test if you don't understand all the free OK want to create multiple tests from from this this 1 of I didn't mention before previous for approaches are controlling the crucial which skipping inherited that this is because there's 2 general approach for the mn not the 1 for those where we share access to parent cluster we can clearly clearly tell what we want to do with the data from parent classes we can extend that we can remove some vertical adapted from apparent that we can completely replace another approach which don't I need to create different because it this is just to inserted in jobs protests but something like sky but I like very much G Unit approach where they can assume so we can have assumed here which would go nicely with you and then and it was the best if it's not applicable the parent is a child so I want to quickly to give some mental experiments so I would read out a lot of new things and you try get yourself feelings about so it's not related to test it's just did indeed have now as they are now offers about we had before folders with different approach and changing guidelines after that I am very glad that we have determined happen and I am very sure that you than approaches that demonstrated today I want briefly wasn't there I would be able for you to create a framework that applied to your particular projects that what's best for you that for you and your team it would be very easy to create test it would be no frustration it would
be a low maintenance and you can create greatly there again thank you if it graphical questions including 1 to and thank you the 1st part is is a new functions it's looks a little like the Big Easy isn't it because I don't answer I didn't know what local exceeding and DSL spots in his new functional when you change to they're part of cults these new functionalities their full name so do you mean organizing it into the and the other young yes it is actually a very easy and it has some on and some current cases for example when you want with spent so I you can approach it seems there like a patch isn't on there can can be used with great but it has started and and so you can create a a given function and start questioning and then you most probable all started purchased in there yeah lots of its looks like the following the null ballots there may be a locks it so developed here so that we have today in development but if it is another layer which which we actually don't need because some operator small way so that there is some someone numerous data and we can benefit without using that without and just clarify and what we want to do more like a sense thank you for that the last question OK thank you I so like uh how how you manage like if you have a lot of test because my previous project and that we having a lot of test and uh how you manage to do not create our local function that has to be there to be the the that they do something different and the needs and you know how to make things a lot of helper code to make the best because from what you were set showing the slides you want something to the different functions that 1 responsibility and then you just as easy but you know amazing known in the test cases would be to to read years uh lower if you have like a lot of test cases and then you will get a lot of the copied code because somebody wants to just add this 1 from that this 1 from that the sculptor codes that you know you move out what did not only words for flaws that outline but for the land of the influence of single test where you have a lot of then so far from experience there is actually no apparent to combine those men pointed to some other single bank function so you would have them user is bent and in in this way you would hear that it's the activated that it's can do this that and then there's this so you don't put all of this in the desert but you have to that not a test method is that we describe so generally what you want to do is to follow the organization of the across cell you organizer code somehow and it's better to structure incident you I take the time to answer my question but probably a little bit more but they feel free of cost to adoption of thank you
Roboter
Softwaretest
Flächeninhalt
Spieltheorie
Prozess <Informatik>
Primzahlzwillinge
Mereologie
Code
Computeranimation
Signifikanztest
Softwaretest
Prozess <Informatik>
Versionsverwaltung
Projektive Ebene
Biprodukt
Code
Computeranimation
Signifikanztest
Softwaretest
Softwaretest
Linienelement
Zahlenbereich
Gerade
Gerade
Code
Computeranimation
Resultante
Bit
Momentenproblem
Hinterlegungsverfahren <Kryptologie>
Raum-Zeit
Computeranimation
Eins
Netzwerktopologie
Datenmanagement
Regulärer Graph
Prozess <Informatik>
Signifikanztest
Addition
Template
Profil <Aerodynamik>
Malware
Konfiguration <Informatik>
Texteditor
Rechter Winkel
Ablöseblase
Information
Refactoring
Programmierumgebung
Normalspannung
Aggregatzustand
Fehlermeldung
Wellenpaket
Selbst organisierendes System
Wasserdampftafel
Gruppenoperation
Klasse <Mathematik>
Zahlenbereich
Term
Physikalische Theorie
Code
Erwartungswert
Multiplikation
Bildschirmmaske
Informationsmodellierung
Spezifisches Volumen
Indexberechnung
Datenstruktur
Optimierung
Softwareentwickler
Grundraum
Einfache Genauigkeit
Physikalisches System
Elektronische Publikation
Wort <Informatik>
Softwaretest
Signifikanztest
Lineares Funktional
Parametersystem
Komponententest
Klasse <Mathematik>
Orbit <Mathematik>
Einfache Genauigkeit
Profil <Aerodynamik>
Schlussregel
Transformation <Mathematik>
Elektronische Publikation
Code
Computeranimation
Übergang
Konditionszahl
Mereologie
Vererbungshierarchie
Optimierung
Ablaufverfolgung
Programmierumgebung
Innerer Punkt
Signifikanztest
Lineares Funktional
Klasse <Mathematik>
Relativitätstheorie
Automatische Handlungsplanung
Versionsverwaltung
Iteration
Kartesische Koordinaten
Computeranimation
Multiplikation
Einheit <Mathematik>
Vorzeichen <Mathematik>
Deklarative Programmiersprache
Mereologie
Vererbungshierarchie
Einflussgröße
Signifikanztest
Parametersystem
Namensraum
Quadratzahl
Basisvektor
Klasse <Mathematik>
Vererbungshierarchie
Cluster <Rechnernetz>
Schlüsselverwaltung
Computeranimation
Namensraum
Verkettung <Informatik>
Rahmenproblem
Klasse <Mathematik>
Maßerweiterung
Computeranimation
Cursor
Integral
Softwaretest
Namensraum
Bit
Punkt
Rahmenproblem
Momentenproblem
Klasse <Mathematik>
Computeranimation
Einheit <Mathematik>
Rechter Winkel
Vererbungshierarchie
Information
Cluster <Rechnernetz>
Ordnung <Mathematik>
Server
Bit
Subtraktion
Maschinencode
Komponententest
Selbst organisierendes System
Klasse <Mathematik>
Mathematisierung
Zellularer Automat
Kardinalzahl
Inzidenzalgebra
Framework <Informatik>
Code
Computeranimation
Einheit <Mathematik>
Geometrische Frustration
Prozess <Informatik>
Code
Endogene Variable
Vererbungshierarchie
Softwareentwickler
Signifikanztest
Softwaretest
Nichtlinearer Operator
Addition
Lineares Funktional
Einfache Genauigkeit
Strömungsrichtung
Bitrate
Softwarewartung
Rechenschieber
Patch <Software>
Mereologie
Projektive Ebene
Wort <Informatik>
Message-Passing
Instantiierung

Metadaten

Formale Metadaten

Titel Sustainable way of testing your code
Serientitel EuroPython 2015
Teil 64
Anzahl der Teile 173
Autor Amirov, Eugene
Lizenz CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
DOI 10.5446/20105
Herausgeber EuroPython
Erscheinungsjahr 2015
Sprache Englisch
Produktionsort Bilbao, Euskadi, Spain

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Eugene Amirov - Sustainable way of testing your code How to write a test so you would remember what it does in a year from now? How to write selective tests with different inputs? What is test? How to subclass tests cases and yet maintain control on which tests would run? How to extend or to filter inputs used in parent classes? Are you a tiny bit intrigued now? :) This is not another talk about how to test, but how to organize your tests so they were maintainable. I will be using nose framework as an example, however main ideas should be applicable to any other framework you choose. Explaining how some parts of code works I would have to briefly touch some advanced python topics, although I will provide need-to-know basics there, so people with any level of python knowledge could enjoy the ride.
Schlagwörter EuroPython Conference
EP 2015
EuroPython 2015

Ähnliche Filme

Loading...