PyCon Australia 2013

Por qué utilizo py.test y por qué tu también deberías utilizarlo

Andy Todd  · 


PDF (pincha para descargar)



Extracto de la transcripción automática del vídeo realizada por YouTube.

means first speaker is our first presenter has been using Python for more than 10 years to build desktop and web applications has worked in a variety of organizations and has managed to use Python in all of them that he's going to be telling us about why

he use uses PI tests please welcome Andy Todd thank you very much good afternoon hope the cakes were nice so as I was introduced the talk up there says why use PI dot testing you probably should too I was going to speak about the subject I've mentioned

in the talks on me but but actually it's probably a different talk what does should have said is this is how to start unit testing it kind of changes I wrote it but I think that's probably a better description those of you who are in Ryan's talking

the plenary Hall in the last session if you understood what he was talking about there this probably isn't the talk for you this is for people like myself who who've heard about unit testing I think it's a fantastic thing but really when it comes

down to it it's kind of hard to get started I've written code for far too many years I've written unit tests for that code for somewhat less and I probably should have done more unit testing so what I'm going to try and do today for those of

you who like me so five years ago I had never written any unit test is a quick overview of what unit testing is a very quick tour through some of the libraries in Python and we will talk about PI tests because I think that's probably the best one to start

with we will then probably spend half the talk talking about tips and techniques for how you can actually start adding unit testing to a new application or to an existing set of code as I said the key takeaway from this message from this tool hopefully is

is some how do you start unit testing and and to help you along the way I've done the Google search for you how to start unit testing only a hundred and thirteen million hits I've read all of them so you don't have to interestingly enough from

a man who works in a Microsoft shop at an insurance company there's an awful lot of stuff there for people to use C sharp and dotnet and if you like that's a cultural thing I think testing is a cultural thing if you go to the Java world testing and

unit testing and automated deployment is very big in the Microsoft world I think it's still got a way to catch up luckily we're in Python so everything's much easier much simpler much better hopefully so as I said we'll just do a quick overview

of some of the principles here in case there are people who haven't done unit testing yet I'm sure you all have what exactly is unit testing and there's and there's a few key principles so here's the definition that I wrote well it's

actually is based on our lives based on the definition from Wikipedia and there's a few key elements in unit testing that I think are important and some of them are slightly less important the the probably the key word on that slide should be repeatable

your unit tests and unit tests essentially are code that tests code sometimes people don't think of it that way particularly should be isolated and that is very important if you go to the pure unit testing zealots they'll tell you that every code should

be completely independent of every test should be completely independent of every other test there should be no infection of one test to another you can't share anything between your unit tests mostly that's true and one of the reasons and you'll

see this later in the talk that I recommend you use PI doc test is because sometimes that can be a pain in the bum and often it's it's preferable to share some elements for instance of your setup in your teardown between multiple unit tests just otherwise

it will take far too long to run a test suite the next thing is they should be automated you can't really see it on the picture there but that's one of Google's fancy self-driving cars I'm hoping they've written some tests for that software

but automation is important as well because if you have to run each test by hand you're not going to do it very often what you want to be able to do with the unit test suite is basically just kick it off and run it every every time again if you get into

test-driven development and fully embrace the the methodology you'll run the tests every time you you check in a commit into your a source code repository hopefully maybe more often than that as before you check it in so automation is key here because

if you can't automate your test you're never going to run them the other key component of unit testing I think is is batching each test should test one thing and one thing only but you will find as you go through and write unit tests for a piece of

code or an application system you will logically want to group things together and what you generally speaking want to be able to do is if you've only changed one part of a subsystem you want the ability to run the batch of tests that effect that subsystem

in your application or one module in your library you should by default run everything but sometimes again the overhead of running awful suite of unit tests can be too much and the ability to just break them up is quite good so there was your three minute

[ ... ]

Nota: se han omitido las otras 2.720 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.