12

If you can answer the question, "Can you give me an example of how X should behave?" then you can do BDD. So, if you want to do BDD at a unit level, think of some examples of how that class or unit of code behaves, then describe that example using code. You don't have to use Cucumber for that. I find it's enough to just put the Given / When / Then in ...


8

I made the mistake of stripping a room down to the studs when I replaced its windows. It's an old house. The room was in bad shape. At every step along the way, I ran into issues. An old pipe crumbled in my hand. The now-dangling twenty five pound plumbing vent fell and crashed through the kitchen ceiling. (Luckily, no one was hurt but my girlfriend's ...


8

You are correct. BDD does not eliminate problems with language ambiguity - not at all. As others pointed out, the snippets that get translated need to be matched by properly defining them, but this also does not address the underlying ambiguity problem. Now why is BDD actually worthwhile despite not solving this problem? There are some reasons and this list ...


5

The simple answer is probably "you can't unit test this code". You say yourself that the functions are too long and that they're doing multiple tasks. Therefore you have two choices: Don't write unit tests. Contrary to what some people might tell you, it is possible to write high quality code without unit tests. Refactor so that you can write unit tests. I ...


4

Traditionally in BDD we'd start with the outside and move in, so we'd have a web page, then from there move to the actual DB connections until the scenario worked with the web page. However, your question about whether you can use the same feature file with different steps at different levels is appropriate and applicable. I don't think at the moment that ...


4

'In general if there are more than about five or six scenarios, a story can probably be broken down by grouping similar scenarios together.' Dan North (http://dannorth.net/whats-in-a-story/)


4

When something is written in “natural language” this can mean a number of things: This is literally English. As English is a very ambiguous and imprecise language, this input mode is unsatisfying in the context of software development. This is English, but relevant terms are precisely defined. Such language is used in legal documents, or mathematical texts. ...


3

-- This answer was written in response to the origional version of the question which read : "So, is using Cucumber to (near)exhaustively define complex interactions of requirements by example an abuse of the tool?" -- I would say not. As you point out, business rules which interact with each other can lead to unexpected outcomes. I've lost track ...


3

Like in all testing, it depends on what you are testing. Complex features, which require lots of steps and preperations for example, will need multiple scenarios to be tested thoroughly, where a simple calculation feature may do with only the happy flow and two erroneous scenarios. If you find yourself writing too many scenarios for one feature, it may be ...


3

There is no "should". Testing is a tool. It's like asking "Should an artist always use oil-based paint". The answer is (of course!) "it depends". The goal of tests are to a) test the product, and b) be well engineered. You can write well-engineered tests in many styles. Your team should do what is most compatible with their skills.


3

Test code is code that needs to be read, executed and maintained, just like production code, so it should be subjected to the same standards as production code. Just use inheritance, interfaces, whatnot, where it makes sense and where it helps you build a maintainable selenium script. P.S.: the PageObject is a commonly used pattern for Selenium, where you ...


2

I was wondering if its a requirement to consider BDD the use of Cucumber framework or other framework of test abstraction. I will start by answering this question. Cucumber (or SpecFlow or any similar tool) is an implementation of the Gherkin language. Behavior Driven Development has two important components that Gherkin satisfies: Specification by ...


2

What I personally believe is that RSpec testing is a definite must. Let's say for example that you want to write a new feature, and which also has reference to some other feature, and that feature might be referenced with some other module or methods. So how can you make sure that what you are writing is not breaking any other part of the application? ...


2

I believe you've misunderstood a fundamental concept. Behavior Driven Development is not unit testing. If you're waiting until after you've written your code before you create your feature file, you're doing it wrong. The benefit BDD provides is that you get your business partner to tell you how they will evaluate whether or not the code meets their ...


1

I use BDD at as many levels as possible, using the same scenarios. First I start with writing and validating the scenarios with stakeholders. Then I use the scenarios to drive development of the backend (e.g. a REST API). When those tests pass, the steps code serves as great reference material for the UI developers. So the next phase is I have the UI ...


1

What levels to test on with BDD/Cucumber? if possible prefer to implement automated tests via an api layer instead of gui layer because gui tests are often more expensive-to-maintain/fragile than api tests. if you have to write automated gui-tests because logic is already implemented in gui-dependant code instead of a seperate gui-independant-business-api ...


1

Ask yourself, what does the BDD acronym stand for? Behaviour Driven Development is not a testing methodology, it is development methodology that includes testing as a first class capability; specifically it uses the requirements as a script for automated testing. It should be used for testing at the level of abstraction expressed by the requirements and ...


1

I would say no, for the same reason you don't write unit tests for unit tests. Tests are written to verify functionality. They should be considered part of the functionality itself: when you change the functionality, you change the tests. There's no point in writing a test of the test when you can just fix the test itself. To answer your implied question of ...


1

It is difficult to compare development methods this way. You can have two teams, each of which uses a different method, both of which are developing the same software, and measure the total amount of time (with comprable defects) from start to finish. Then you have to account for the fact that the larger amount of software produced is a worse result. But ...


1

All software is meant to eventually serve at the behest of some human user, and a user story caters to that. Consequently, any reference in a user story to a machine or other technological item is generally going to be an implementation detail. Look at this commerce example: Story: Returns go to stock In order to keep track of stock As a store owner I ...


1

My understanding is that Cucumber in Java uses step files that are POJOs and has the ability to do dependency injection via various cucumber extensions - at least, that's what it says in their documentation. As such, unless your specs are very simple and always going to remain that way, you really want to use real instances. Static is contagious - if you ...


Only top voted, non community-wiki answers of a minimum length are eligible