The three pillars of unit tests: A helpful guide for beginners(blog.goyello.com)

submitted by dpetersondpeterson(4397) 7 months, 15 days ago

If you're new to TDD, then this short but sweet article by Pawel Olesiejuk is just what the doctor ordered. It covers the three pillars of test-driven development, which should push anyone just learning TDD in the right direction.

7 comments |category: |Views: 574

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by BlackWaspBlackWasp(4212) 7 months, 15 days ago 0

Useful points on TDD.

One point 1 I'd make a slight amendment. If you can remove a line without breaking a test, I wouldn't advocate not using the tests. Instead I'd recommend adding tests to give you the reliability you need. Otherwise, good information.

Reply

posted by dpetersondpeterson(4397) replied to BlackWaspBlackWasp(4212), 7 months, 14 days ago 0

Point well taken. I think rather than do something destructive to the code, just add something unexpected. Return something you know should make the test fail, etc. If the test still passes then fix the test, just as you advocated.

Reply

posted by vijaystvijayst(1311) 7 months, 14 days ago 0

Most developers I have seen do not create mocks or stubs to do separation of concerns - Creating mocks or stubs can be very time consuming if the layers are tightly coupled.

Reply

posted by dpetersondpeterson(4397) replied to vijaystvijayst(1311), 7 months, 14 days ago 0

I think in that case it highlights the problems of tight-coupling when separation of concerns is not preserved. If your tests can easily break when components change, so will your code. I don't know that mocks/stubs are always a necessity, but separation of concerns is IMO.

Reply

posted by blanciqblanciq(7) 7 months, 14 days ago 0

"I wouldn't advocate not using the tests. Instead I'd recommend adding tests to give you the reliability you need."

I completely agree with that but if tests has leak in this place it could has leak in another as well. So in most cases you basically have to write all of them from scratch.

"I think rather than do something destructive to the code, just add something unexpected."

It's very good idea.

"Most developers I have seen do not create mocks or stubs to do separation of concerns - Creating mocks or stubs can be very time consuming if the layers are tightly coupled."

You're right. I'll be writing about isolation in one of my next posts.

Cheers, Paweł Olesiejuk.

Reply

posted by bradygasterbradygaster(4897) 7 months, 14 days ago 0

For people who are just getting started in TDD, the nebulousness of it can be confusing sometimes. I think this post gives some clarity into how the individual steps and benefits of TDD.

Reply

posted by alonesharkaloneshark(31) 6 months, 20 days ago 0

It's worth pointing out a lot of this information comes from Clean Code by Uncle Bob and Roy Osherove's The Art of Unit Testing. Both are worth a read if you subscribe to the TDD philosophy.

Reply

information Login or create an account to comment on this story