Tag Archives: Unit Test
My team at Bazaarvoice has been spending a lot of time lately thinking about quality and how we can have greater confidence that our software is working as it should.
We’ve long had functional tests in place that attempt to ask questions like “When a user clicks a button, will The Widget do The Thing?” These tests tell us a fair amount about the state of our product, but we’ve found that they’re brittle – even after we abstracted away the CSS selectors that they rely on – and that they take approximately forever to run, especially if we want to run them in all of the browsers we support. The quality of the tests themselves is all over the map, too – some of them are in fact unit tests, not really testing anything functional at all.
BDD and Jasmine
I’m a big fan of Test-Driven Development (TDD). And I always want to write unit test for my code. But not everyone agrees with me. There is a cost to write unit tests, and the benefit is in the long term, so it is not easy to convince others, especially managers or clients, that time spent on unit test will improve software quality and save money in the future. It is harder when developers write unit tests which don’t make sense. Sometime I even got frustrated when I tried to write unit test code for the sake of unit testing.
So what exactly shall I test? How shall I write unit tests? Dan North introduced Behavior-driven development, and he answered lots of my questions regarding the unit test. So what is Behavior-Driven Development?
Behavior-driven development is about implementing an application by describing its behavior from the perspective of its stakeholders.
This post is part of a daily series of posts introducing the most exciting new parts of iOS8 for developers – #iOS8DayByDay. To see the posts you’ve missed check out the index page, but have a read through the rest of this post first!
To enjoy each of the 39 posts all in one place, you can now also download the iOS8 Day-by-Day eBook free from our website!
A few years ago I was one of those developers who write unit tests for my data access code. I was testing everything in isolation, and I was pretty pleased with myself. I honestly thought that I was doing a good job.
Oh boy was I wrong!
This blog post describes why we shouldn’t write unit tests for our data access code and explains why we should replace unit tests with integration tests.
Let’s get started.