• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Finding the Middle Way of Testing
 

Finding the Middle Way of Testing

on

  • 3,018 views

Talk about what should and shouldn't be tested in web application development. How to find the sweet spot of testing.

Talk about what should and shouldn't be tested in web application development. How to find the sweet spot of testing.

Statistics

Views

Total Views
3,018
Views on SlideShare
2,973
Embed Views
45

Actions

Likes
4
Downloads
34
Comments
0

2 Embeds 45

http://www.oscon.com 44
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • I&#x2019;ve wanted to do this talk for a while. I&#x2019;ve given a bunch of talks on the mechanics of testing. But i feel like there is something missing. We need to talk more about what to test and what not to test. There is a kind of macho, who can test the We need a balance <br />
  • One way of thinking of testing is to not do them, but to release often, quickly, write code with feature flags. I like to call this the flickr way, it works. It&#x2019;s very similar to how facebook works really. Lots of small iterations. No tests, in code, you&#x2019;ve got users for that! If the space between releases is really short, this model works. <br />
  • http://flic.kr/p/tvUHq <br />
  • The other direction is testing everything. You want it to be like this. Rushing along, everything is a blur as you race through development. This is called the TATFT method of software development. <br /> http://flic.kr/p/7kKDuo <br /> <br />
  • This is the &#x2018;test all the fucking time&#x2019; method of software development. It&#x2019;s appealing because it&#x2019;s hard core. Alpha male, Test First, Test Always style. <br />
  • This is the &#x2018;test all the fucking time&#x2019; method of software development. It&#x2019;s appealing because it&#x2019;s hard core. Alpha male, Test First, Test Always style. <br />
  • But if done to extreme, without regard to utility, you get this. Burdened down by your tests. <br /> http://flic.kr/p/GNhm3 <br />
  • Sometimes we need to find balance between these ways. Testing is a technique we use to make better software. <br />
  • So the question is then what&#x2019;s the middle way. What rules should we use to decide what should and shouldn&#x2019;t be tested. I&#x2019;m going to go through a bunch of best and worst practices. My rules of thumb for the way of testing. <br />
  • n ways to find the middle way in testing. What to test, what not to test, and when to know the difference. http://flic.kr/p/8kAmwf <br />
  • I do rails development, the examples come from rails. But the point is try and extract ideas which are useful in many technology stacks. <br />
  • The worse of the bad testing techniques is to go from no tests to spending weeks just writing tests. To catch up! <br /> <br /> http://flic.kr/p/7ZSbRQ <br />
  • It&#x2019;s important not to test to little, to be to focused on the details. You end up testing the implementation. Tests fail, but not because the software as a whole is broken. The simple, Assert 2, 1+1. It&#x2019;s not interesting. http://flic.kr/p/6Zeo1V <br />
  • Just as testing the details of an implementation, is bad, testing to broadly also can fail for two reasons. First is time. Testing is a tool for debugging. Debugging is what we are really doing most of the time when we say we&#x2019;re programming. http://flic.kr/p/7azreS <br />
  • One classic problem is when people start writing tests is that they are testing their use of somebody else&#x2019;s library. Presumably that library should have tests itself, or if it doesn&#x2019;t has at least a stable API. Treat it as a black box. http://flic.kr/p/3c89jn <br />
  • One example in Rails is to do tests that confirm Active Record is working correctly. That a has_many association can be created and deleted. <br />
  • I know there was just a talk about Gherkin, the extension of cucumber to make it work in multiple human languages. But i think you should just say no to Cucumber. Clients don&#x2019;t want to write them. More to the point they can&#x2019;t do them well. It&#x2019;s a fascinating exercise, but cucumber stories do not translate in to good code. It&#x2019;s bulky, nobody reads the stories, code when it fails is easier to understand. <br /> <br /> http://flic.kr/p/5aZYkP <br />
  • <br /> <br /> http://flic.kr/p/7qQZni <br />
  • Even though natural language tests like cucumber are, in my humble opinion a disaster, integration tests are a great idea. They&#x2019;re code, they are ways of dealing with our web apps in a way similar to real use, but simulated. We&#x2019;re mocking the real browser, and replacing it with something more useful for testing. <br /> <br /> http://flic.kr/p/kZtKo <br />
  • This is what you should do. Test the bugs. Write tests when things break. What you should do is manually try and reproduce a bug. Then once you can &#x2018;see&#x2019; it, then you write the test. Then with the test, you can fix it. This is the way to do it. Don&#x2019;t do that sprint thing. <br /> <br /> http://flic.kr/p/JAE3v <br />
  • <br />
  • When you go in an refactor, then is vital. Really this is the only time it makes sense to spend any time writing just tests. <br /> <br /> http://flic.kr/p/88X9DY <br />
  • So when you&#x2019;re refactoring, as opposed to updating, then you need tests. Because by definition, refactoring, is to change the implementation without changing the functionality. So you need a test to confirm the functionality is the same. <br /> <br /> http://flic.kr/p/aCDk7 <br />
  • The mocky stubbly things. Taking functionality out and replacing it with fakes. There be dragons here. On the one hand, if you have the full system, it&#x2019;s slow to test. Things like networks, payment processing gateways, they aren&#x2019;t things you want to hit when <br /> <br /> http://flic.kr/p/6Q6en <br />
  • Show XKCD comic of compiling.... <br /> <br /> Testing is the new compiling. Perhaps we needed the cognitive space. A break in our work, and so in interpreted languages we started writing tests, to fill the gap which used to be created by compiling. <br /> <br /> <br />
  • Show XKCD comic of compiling.... <br /> <br /> Testing is the new compiling. Perhaps we needed the cognitive space. A break in our work, and so in interpreted languages we started writing tests, to fill the gap which used to be created by compiling. <br /> <br /> <br />
  • http://flic.kr/p/4heE23 <br />
  • <br /> <br /> http://flic.kr/p/55d56F <br />
  • One lesson from the BDD experience is that you assertions must make sense. Think of writing the tests so when they fail, the test name makes sense, and the failure is directed. <br /> <br /> http://flic.kr/p/4Jrqs1 <br />
  • Tests are different from application code. It&#x2019;s ok to repeat yourself. Some. <br /> <br /> http://flic.kr/p/gLUeh <br />
  • The tests should be damp. As in, repeat yourself some. Because each test is of a variation of functionality, it requires some repetition. Not DRY, but damp as it were. <br /> <br /> http://flic.kr/p/4qBKRw <br />
  • Your tests should be atomic. Each test has the same environment. This means your fixtures need to work well. If one test has an effect on another, then you&#x2019;re in for a world for hurt. You know what happens when you start smashing volatile atoms together, right? <br /> <br /> http://flic.kr/p/7Gssw1 <br />
  • If you fail to keep your tests separate from each other, things fall apart <br /> <br /> http://en.wikipedia.org/wiki/Nuclear_explosion <br />
  • I strongly agree with what Trotter said in the previous talk. Outside In. Finding the sweet spot, outside of your application, outside of the implementation, which you can test. <br />
  • Similar to the atomic thing. You want your tests to be self contained. A single activity or thing. The tricky part here is to keep each test self contained, a bit of functionality, a unit as it were, but not so focused as to be a sub-unit. <br /> <br /> <br /> http://flic.kr/p/5ZFbHE <br />
  • Easily be able to see what works and what doesn&#x2019;t, clear red green results. If you&#x2019;ve got one of those grahpical IDE things, then use that. The idea is you have to easily, automatically, know what works. <br /> <br /> So, it&#x2019;s code, look to see if worked, code, see if it worked, code, see if it worked. That is the old school model of software development. <br /> <br /> http://flic.kr/p/7vVAJW <br />
  • That&#x2019;s my middle path, there is no one path. But i think we need to start calling out what we want, what we do, what we shouldn&#x2019;t do in testing. While there may be more than one way to do it, all the ways aren&#x2019;t the same, some work, some don&#x2019;t. <br />
  • <br />

Finding the Middle Way of Testing Finding the Middle Way of Testing Presentation Transcript

  • Testing Finding the Middle Path source: http://flic.kr/p/6v82qN
  • The Flickr Way source: http://flic.kr/p/6MQYyj
  • The QA Way source: http://flic.kr/p/tvUHq
  • Test Everything Way source: http://flic.kr/p/7kKDuo
  • TATFT source: http://flic.kr/p/7kKDuo
  • Test All The Fucking Time source: http://flic.kr/p/7kKDuo
  • Overloaded With Tests source: http://flic.kr/p/GNhm3
  • Balance source: http://flic.kr/p/3enph8
  • Finding The Way source: http://flic.kr/p/5tZaUe
  • On Rails source: http://flic.kr/p/4WR1F9
  • Test All At Once source: http://flic.kr/p/7ZSbRQ
  • Don’t Test To Narrowly source: http://flic.kr/p/6Zeo1V
  • Don’t Test To Broadly source: http://flic.kr/p/7azreS
  • Testing What Is Already Tested source: http://flic.kr/p/3c89jn
  • The Database
  • Cucumber source: http://flic.kr/p/5aZYkP
  • What You Should Do source: http://flic.kr/p/7qQZni
  • Integration source: http://flic.kr/p/kZtKo
  • Test The Bugs source: http://flic.kr/p/JAE3v
  • Refactoring source: http://flic.kr/p/88X9DY
  • Test Then Change source: http://flic.kr/p/aCDk7
  • Mocky Stubbly Things source: http://flic.kr/p/6Q6en
  • Make Tests Fast source: http://flic.kr/p/5tZaUe
  • Make Tests Fast TESTING TESTING! source: http://flic.kr/p/5tZaUe
  • Fixtures light fixture? source: http://flic.kr/p/5tZaUe
  • Data For Tests source: http://flic.kr/p/5tZaUe
  • true is not false source: http://flic.kr/p/5tZaUe
  • Tests Aren’t DRY source: http://flic.kr/p/5tZaUe
  • They’re Damp source: http://flic.kr/p/5tZaUe
  • Atomic source: http://flic.kr/p/5tZaUe
  • Atomic Failure source: http://flic.kr/p/5tZaUe
  • Outside In source: http://flic.kr/p/4KgEv
  • Self Contained source: http://flic.kr/p/5ZFbHE
  • Red Green source: http://flic.kr/p/5tZaUe
  • That’s My Middle Path @rabble - cuboxsa.com source: http://flic.kr/p/6v82qN