News for hackers. Stuff that matters.
Re:Why Most Unit Testing is Waste [pdf] by collyw on Thursday March 06, 2014 @09:52AM (#7353942)
I have been trying to add unit tests to my app, but almost all the tutorials you find are useless. They show you how to test 1 + 1, or how to test the framework I am using. The parts of the code I am almost certain will work. None of them show you how to actually test anything useful.
Re:Why Most Unit Testing is Waste [pdf] by michaelfeathers on Thursday March 06, 2014 @10:27AM (#7354197)
I wrote a book called 'Working Effectively with Legacy Code' that's really all about testing code that is not easy to test - real apps beyond toy examples.

There are techniques in the book but really you should try to write tests for code as you write it. It's the best way to make sure that your code is decoupled enough for testing. If you do that, you don't need the techniques in the book.

Re:Why Most Unit Testing is Waste [pdf] by earlz on Thursday March 06, 2014 @11:15AM (#7354571)
You're the author of that!? I love that book, and even though I stick to it's practices less than I probably should, it was incredibly helpful
Re:Why Most Unit Testing is Waste [pdf] by n1ghtmare_ on Thursday March 06, 2014 @12:22PM (#7355100)
This book is legendary! This and Uncle Bob's books Clean Code. A must read for every programmer !
Re:Why Most Unit Testing is Waste [pdf] by ollysb on Thursday March 06, 2014 @10:51AM (#7354406)
I've heard many good things about this book, definitely on the reading list!
Re:Why Most Unit Testing is Waste [pdf] by ollysb on Thursday March 06, 2014 @10:47AM (#7354372)
I read many tutorials and several books on TDD but never quite got it until I read Kent Beck's Test Driven Development By Example[1]. I also highly recommend his Screencast series on pragprog.com[2] which gives you a good flavour of the workflow he uses with TDD.

Edit: For those that don't know Kent Beck is basically the godfather of TDD.

[1] http://www.amazon.com/Test-Driven-Development-By-Example/dp/...

[2] http://pragprog.com/screencasts/v-kbtdd/test-driven-developm...

Re:Why Most Unit Testing is Waste [pdf] by Chupachupski on Thursday March 06, 2014 @03:35PM (#7356381)
Personally I can relate to Kent Beck's approach to testing rather than "test everything":

"I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence (I suspect this level of confidence is high compared to industry standards, but that could just be hubris). If I don't typically make a kind of mistake (like setting the wrong variables in a constructor), I don't test for it. I do tend to make sense of test errors, so I'm extra careful when I have logic with complicated conditionals. When coding on a team, I modify my strategy to carefully test code that we, collectively, tend to get wrong."

http://stackoverflow.com/questions/153234/how-deep-are-your-...

Re:Why Most Unit Testing is Waste [pdf] by ollysb on Thursday March 06, 2014 @03:43PM (#7356436)
Yeah, I think this comes with experience. I started off testing everything but over the years you get a feel for which tests aren't going to add value over the lifetime of the project.
Re:Why Most Unit Testing is Waste [pdf] by lgunsch on Thursday March 06, 2014 @06:26PM (#7357270)
I have also read Test Driven Development By Example. It really opened my eye's to how TDD is suppose to work. Its quite well written. Most of what I have seen on the web does not explain it to any sufficient level.
Re:Why Most Unit Testing is Waste [pdf] by mattgreenrocks on Thursday March 06, 2014 @10:10AM (#7354051)
Testability falls out of good design. Testability is not worth optimizing for on it's own, though. It's just a nice side effect.

Read Growing Object-Oriented Software Guided By Tests. The authors walk through the development of an auction sniper.

Re:Why Most Unit Testing is Waste [pdf] by Iftheshoefits on Thursday March 06, 2014 @10:18AM (#7354122)
The "testability" of a piece of software doesn't really have much to do with the discussion about the quantity or kinds of tests that should be written for it.

Every test is another thing that has the potential to require debugging.

Re:Why Most Unit Testing is Waste [pdf] by camus2 on Friday March 07, 2014 @09:07AM (#7360228)
So true, debugging "tests" is infernal. Peaple always tell you testing should be easy and quick,it is neither of them.
Re:Why Most Unit Testing is Waste [pdf] by skrebbel on Thursday March 06, 2014 @10:01AM (#7354005)
You might like http://blog.testdouble.com/posts/2014-01-25-the-failures-of-...

It's a tad long, but worth it. tl;dr: the first half agrees with you, and the second half describes a process that does help you test useful stuff (and design your software decently along with it)

Re:Why Most Unit Testing is Waste [pdf] by collyw on Thursday March 06, 2014 @10:13AM (#7354085)
I have been adding integration tests. Its an in house app, so constantly changing, and constantly in beta.

I wanted to start adding unit tests a couple of years back, but looking back, I don't think it would have gained very much, and cost a lot of time (creating the data to test the parts).

If there is a functional unit that does one specific thing, I could see it being useful to test. But most of my app basically queries a database and displays the results. The bugs I do get would rarely have been caught by unit tests.

Re:Why Most Unit Testing is Waste [pdf] by gaius on Thursday March 06, 2014 @03:20PM (#7356317)
Well, you have missed the point of TDD. It exists to sell books, seminars, training and consulting. Not to help in the efficient creation of useful software.
Re:Why Most Unit Testing is Waste [pdf] by Anderkent on Thursday March 06, 2014 @09:59AM (#7353989)
Look for TDD tutorials for less trivial examples of what you should test. You want a general 'how do I know what to test' tutorial, rather than 'how do I use testing framework X' (which is what you were probably reading, if they show you how to test 1+1).

Other than that, just be explicit about your api contracts and test those.