background preloader

Test Driven Development

Facebook Twitter

What’s in a Story? [This article has been translated into Korean by HongJoo Lee, French by Philippe Poumaroux and Spanish by Adrian Moya.]

What’s in a Story?

Behaviour-driven development is an “outside-in” methodology. It starts at the outside by identifying business outcomes, and then drills down into the feature set that will achieve those outcomes. Each feature is captured as a “story”, which defines the scope of the feature along with its acceptance criteria. This article introduces the BDD approach to defining and identifying stories and their acceptance criteria. Introduction Software delivery is about writing software to achieve business outcomes. Usually, the business outcomes are too coarse-grained to be used to directly write software (where do you start coding when the outcome is “save 5% of my operating costs”?) Painless Functional Specifications - Part 1: Why Bother? By Joel Spolsky Monday, October 02, 2000 When The Joel Test first appeared, one of the biggest sore points readers reported had to do with writing specs.

Painless Functional Specifications - Part 1: Why Bother?

It seems that specs are like flossing: everybody knows they should be writing them, but nobody does. Bookshelf v7.7: Functional Test Cases. Step by Step guide to Test Case Development. Test case in simple terms refers to a documentation which specifies input, pre-conditions, set of execution steps and expected result.

Step by Step guide to Test Case Development

A good test case is the one which is effective at finding defects and also covers most of the scenarios/combinations on the system under test. Here is the step by step guide on how to develop test cases. Top 13 Tips for Writing Effective Test Cases. Test cases are very important for any project as this is the first step in any testing cycle, and if anything goes wrong at this step, the impacts get extrapolated as you move forward in the software testing life-cycle.

Top 13 Tips for Writing Effective Test Cases

Knowing how to write good test cases is extremely important for you as a testing resource and believe you me, it doesn’t take too much of your effort and time! You just need to follow certain guidelines while writing test cases or as they call it – follow “test case writing best practices.” In this article, I am going to talk about some simple yet effective tips which you could use for writing effective test cases. Writing Test Cases for Functional Testing » Game-based learning. What is a Test Case?

Writing Test Cases for Functional Testing » Game-based learning

In software testing, a test case is an ordered sequence of inputs with conditions and variables that determine whether a piece of an application is functioning properly. In functional testing, test cases are used to test the application’s interface and determine how an application and the user interact. You could think of test cases for functional testing as similar to unit tests for code. Test cases usually include the following:

Refactoring BDD scenarios. On December 16th I attended a Madriagil meetup.

Refactoring BDD scenarios

Whose domain is it anyway? The brittleness of tests or specs is a recurring topic in BDD (or acceptance test-driven development, specification-by-example, or whatever you choose to call the thing where you write acceptance criteria, automate them and then make the application match).

Whose domain is it anyway?

This is a tricky area, and there are probably as many styles of defining and grouping acceptance criteria as there are teams automating them. The aspect I want to focus on in this article is domain language, because there’s a failure mode I encounter surprisingly often, which seems to have a common root cause. Here’s an example: Specification by Example versus Behaviour Driven Development. Personally I favour the phrase “Specification by Example” over the more commonly used term “Behaviour Driven Development” (BDD).

Specification by Example versus Behaviour Driven Development

BehaviourDrivenDevelopment - BDD Wiki. Specification-Driven Development. In the last couple of years, there's been a lot of debate in the community on the philosophy behind TDD and where to put the emphasis - even to the point of debating whether the acronym stands for Test-Driven Development or Test-Driven Design.

Specification-Driven Development

Other people don't like the emphasis on tests, since that makes TDD sound like a Testing discipline, and not a Development discipline. Instead, they prefer terms like Example-Driven Design/Development (EDD) or even Design by Example (DbE). This view seems to me to be particularly prevalent in Microsoft, where there's a rather sharp distinction between developers and testers (job titles to the contrary) - I guess that's one of the reasons why (a project initiated by Microsoft employees) uses the attribute Fact instead of Test or TestMethod. For people used to SCRUM or other agile methodologies, this distinction is more blurred, and they also seem to accept the T in TDD more willingly. To me, the tests are also important. Specification by example notes. BDD with intent. Charles Simonyi introduced himself at a recent workshop with the words: “I was at Xerox PARC in the 70s, Microsoft in the 80s, and working on intentional software in the 90s”.

BDD with intent

He wasn’t showing off, he was just there. He pioneered WYSIWYG, created Microsoft Word, Excel and Access (as a data visualization tool), championed OO and invented metaprogramming. What this tells me is that when Charles Simonyi thinks he is on to something, it’s probably worth listening. (Ok, I’ll forgive him szHungarian notation.) For the last 15 years, Charles has been on to intentional programming. BDD is like TDD if… I’ve noticed a number of people recently declaring that BDD really is just TDD, such as Robert Martin on Twitter and Ron Jeffries on the XP list. I can understand where this mindset comes from and I’d like to offer my perspective. Is BDD the same as TDD? Yes. If you’re a programmer, and your entire team is programmers, and all your stakeholders are programmers and you have a single Subject Matter Expert embedded in the team.

Which was true of the Chrysler C3 team and other early XP teams. BDD is the same thing but for a broader audience: testers, analysts, project and program managers, multiple SMEs covering multiple interrelated domains. It can be argued that the team shouldn’t be anything other than programmers – in the polyglot roles of tester, analyst, etc. – in which case BDD and TDD again collapse into the same space. I’ve been entirely embedded in small teams of programmers for the last couple of years which is why I’ve taken much more of a back seat in the BDD community.

BDD by example. Tl;dr: Send us your examples of real world BDD. Read on to find out why. The panel. BDD – TDD done well? Someone on the XP thread suggested, “BDD is just TDD done well with different words.” Here’s my take. An application is the end-product, and the value of the application is delivered through its behaviour, as perceived through its user interface.

BDD uses descriptions of behaviour and executable examples (or exemplars; examples carefully chosen to illustrate a particular behaviour). These exemplars, whether in code or plain English, are an aid to communication, to driving a clean, simple design, to understanding the domain, to focusing on and delivering the business value, and to giving everyone involved clarity and confidence that the value is being delivered. Is doing the above merely ‘doing TDD well’? Here are some of the practices I use in BDD. Behavior Driven Development — behave 1.2.5 documentation. Behavior-driven development (or BDD) is an agile software development technique that encourages collaboration between developers, QA and non-technical or business participants in a software project. It was originally named in 2003 by Dan North as a response to test-driven development (TDD), including acceptance test or customer test driven development practices as found in extreme programming.

It has evolved over the last few years. On the “Agile specifications, BDD and Testing eXchange” in November 2009 in London, Dan North gave the following definition of BDD: BDD is a second-generation, outside–in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. BDD vs TDD: A Behavior-Driven Development Example. Testing. It often gets left to the last minute, then cut because you’re out of time, over-budget, or whatever else. Management wonders why developers can’t just “get it right the first time”, and developers (especially on large systems) can be taken off-guard when different stakeholders describe different parts of the system, like the story of the blind men describing an elephant.

It’s inevitable, however, that the first step in every project is a discussion about the behaviors of the software or feature to be built. A client or business person comes up to someone on the development team and explains what they want. Sometimes these interactions come in form of an Agile user story. Introducing BDD. Test Behavior, Not Implementation. While I was reading the Ruby Pickaxe book I came across an example of Unit Testing which – in my opinion – is testing implementation rather than behavior.

This particular example was used to explain Duck Typing in Ruby, but I think it illustrates that it’s pretty easy to write tests which end up testing the wrong thing. Test First. 8th Light.