background preloader

Introducing BDD «

Introducing BDD «
History: This article first appeared in Better Software magazine in March 2006. It has been translated into Japanese by Yukei Wachi, Korean by HongJoo Lee, Italian by Arialdo Martini and French by Philippe Poumaroux and most recently into Spanish by Oscar Zárate, Turkish by Selim Öber and Russian. I had a problem. The deeper I got into TDD, the more I felt that my own journey had been less of a wax-on, wax-off process of gradual mastery than a series of blind alleys. My response is behaviour-driven development (BDD). Test method names should be sentences My first “Aha!” renders something like this: The word “test” is stripped from both the class name and the method names, and the camel-case method name is converted into regular text. Developers discovered it could do at least some of their documentation for them, so they started to write test methods that were real sentences. A simple sentence template keeps test methods focused An expressive test name is helpful when a test fails

How We Build Features x Access to videos, talks, and worksheetsInvitation to private Google Plus CommunityJoin in on live Q&A webinars and fireside chats What’s in a Story? | Dan North [This article has been translated into Korean by HongJoo Lee, French by Philippe Poumaroux, Spanish by Adrian Moya, Russian by Denis Oleynik, and German by Julia Kadauke.] 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. 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”?) Behaviour-driven development (BDD) takes the position that you can turn an idea for a requirement into implemented, tested, production-ready code simply and effectively, as long as the requirement is specific enough that everyone knows what’s going on. This, then, is the role of a Story. The structure of a story BDD provides a structure for a story. Telling the story 1.

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. Sometimes these interactions come in form of an Agile user story. From these communications alone, a developer is responsible for constructing a system that "just works". From these communications alone, a developer is responsible for constructing a system that “just works”. Why does testing get cut? How do we make tests this shared capital, this list of system behaviors? What is BDD? The business person specifies behaviors they want to see in the system. a = 42a.should == 42

JUnit Testing Spring Service and DAO (with In-Memory Database) This post describes how to implement JUnit tests for a Spring Web Application’s Services and DAO. It is built on top of the Spring MVC-Service-DAO-Persistence Architecture Example. This example is available from Github in the Spring-Web-JPA-Testing directory. Reminder Test Fixture – The fixed state used as a baseline for running tests.Unit test – These tests verify that pieces of code (components) perform some functionalities as expected. Configuration We need a JPA Hibernate configuration for in-memory testing: We need to exclude the production configuration from package scanning (no ‘com.jverstry’ scanning): Spring Testing Tools @RunWith – This is a JUnit annotation allowing one to run a test with a different runner than the one provided by JUnit.SpringJUnit4ClassRunner – This is a JUnit test runner for Spring applications. Service Testing The following class tests the createAndRetrieve() method of our injected MyService implementation: DAO Testing Caveat It should be replaced with:

TDD y Casos de Uso - Angel "Java" Lopez TDD y Casos de Uso Ya saben que me importa mucho usar Test-Driven Delopment. Yo diría que es lo primero a adoptar en un desarrollo, como “tecnología nueva”. Por ejemplo, hay una idea flotando, que leí hace poco en una lista: “no uso TDD porque el sistema lo tengo que entregar en tres semanas”. Hace dos semanas, tuve el gusto de dar una charla aplicando TDD desde un “File, New Project”, gracias a la gente de @AltNetHispano ( Algo de ese “approach” aparece en la serie de post TDD paso a paso donde se ve cómo se va construyendo el software a partir de un problema planteado por el bueno de @hernanwilkinson. En la charla de @AltNetHispano se preguntó: ¿pero qué hacemos si en la primera iteración el cliente/”product owner” nos pide un diagrama de entidad-relación como entregable? De ahí mi énfasis en usar TDD guiado a su vez por CASOS DE USO. No DB Un párrafo importante: The center of your application is not the database. Sigo: A ver, repitan conmigo:

Hacking: Always Design the UX First | systemizer Over my four years of coding, I have gone through many phases. Each phase was the result of me wanting to acquire some deeper understanding about computing. Today, I am realizing that I am entering yet another phase: Systems Operations. However, to give you some context as to where I've come from, let me outline how I've arrived at this phase... starting from the beginning: Writing my first code I didn't start writing actual code until I arrived at MIT. As an extracurricular activity, I wrote for the student newspaper. One day, upon entering the office, I saw a student sitting at a computer. Of course, I was intrigued. I wanted to be that cool, too. In the terminal. In my free time after classes, I would open up a terminal and start poking at commands. When I was introduced to SSH, my mind was blown: if I could learn how to operate my own computer from the Terminal, then SSH can enable me to operate any computer that is connected to the network through Terminal. Javascript and Patience

Mocks Aren't Stubs The term 'Mock Objects' has become a popular one to describe special case objects that mimic real objects for testing. Most language environments now have frameworks that make it easy to create mock objects. What's often not realized, however, is that mock objects are but one form of special case test object, one that enables a different style of testing. In this article I'll explain how mock objects work, how they encourage testing based on behavior verification, and how the community around them uses them to develop a different style of testing. I first came across the term "mock object" a few years ago in the XP community. Since then I've run into mock objects more and more. But as often as not I see mock objects described poorly. This difference is actually two separate differences. (In the earlier version of this essay I had realized there was a difference, but combined the two differences together. Regular Tests I'll begin by illustrating the two styles with a simple example.

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. BDD focuses on obtaining a clear understanding of desired software behavior through discussion with stakeholders. BDD practices The practices of BDD include: Outside–in BDD is driven by business value; that is, the benefit to the business which accrues once the application is in production. Using mocks

John Ewart » DAO Testing with Hibernate I’m currently building some web services using Dropwizard (Jetty, Jersey, Jackson, Hibernate all bundled up), and needed to test the DAO. Dropwizard has some convenient interfaces to load configuriation files and bring up hibernate sessions, etc. when the service boots up; however, this does not translate well to JUnit tests (there’s a lot of plumbing involved in making a Service that doesn’t translate to tests.) Fortunately, though, since it’s all just sugar coating you can just as easily setup your own sessions and transactions. I found that creating a parent class for my DAO tests that does all the setup is a convenient way of handling all the plumbing you need. Setting up Hibernate Then each test suite for the DAO in question can just deal with the things it cares about, and any Hibernate-related mojo sits in the superclass. Example DAO test

10 Agile Bloggers You Should Know About, But Don’t - Agile Bench Paul Dolman-Darral over at Value Flow Quality recently published a list of The Top 20 Most Influential Agile People. This is a great list of established Agile Bloggers, many of whom are book authors. But these people get all of the attention. There are lots of hard working, throughful bloggers out there that you haven’t heard of and should start paying attention to. Not everyone on our list blogs regularly, but when they do you should listen. Agile Bloggers gotta keep bloggin’ 1. All About Agile by Kelly Waters has been writing about agile since 2007 and has a great collection of articles. 2. Leading Answers by Mike Griffiths focuses on leadership and agile project management ideas. 3. Mark Levison is a Canadian who writes Notes from a Tool User. 4. Their articles are quirky, fund and loud! 5. BrainsLink is a blog written by Vin D’Amico about enterprise agile and its use in software development and business operations. 6. 7. 8. 9. This one is for the testers. 10. Bonus!

RESS: Responsive Design + Server Side Components There's no shortage of debate about the best way to develop Web sites that work well across many networked devices. Some teams favor a client-side approach while others lean towards server-side solutions. But I'm increasingly interested in solutions that try to bring together the best of both worlds. RESS (Responsive Web Design + Server Side Components) is one such proposal. In Responsive Web Design implementations, Web URLs are consistent across devices and adapt their content based on the capabilities of the browser in which they are displayed. Server side solutions, on the other hand, only send what a client needs. So both client and server side adaptations have benefits but a few limitations. In a nutshell, RESS combines adaptive layouts with server side component (not full page) optimization. How's it Work? Let's assume we want a different navigation solution for mobile and desktop devices. On the desktop, however, we want the same navigation at the top of the page. Is it Effective?

Get started with testing from top to bottom Image via We are regularly talking to teams who are just starting out with testing their application. Some of them have a few tests, but don’t know where to go next. Others don’t test at all and need help to get started. One team mentioned they felt overwhelmed as there is so much they could test. By starting to test your application from top to bottom you can get over this easily. Start from the top By testing your application you can always be sure the most important steps users can take in your application work. As easy as this sounds we’ve seen teams struggle with coming to that conclusion and then following through. You should start by defining what the most important steps in your product are. Get everyone in your team to write down 8 scenarios they think are the most important ones in your application. All of them should be structured with Given, When and Then steps. Another example would be And one more This should only be the beginning of testing your application.

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. A story is a narrative from a customer in a particular role, describing a particular feature and a value that will be delivered through the use of that feature. (This isn’t a practice; it’s just how stories and scenarios work.) Like this: Related