bdd

BDD And Unit Testing

I have been doing TDD and was using it more as unit testing than to drive my design. Recently I have read a lot about BDD; now that I have a better idea about them both, I was trying to figure out how to use BDD and unit testing concurrently. For example I would drive my design using BDD Dan North style ,and lets say am working on app...

Should I test if a stubbed method was called?

I'm just starting out with BDD/TDD using MSpec (with AutoMocking by James Broome) and RhinoMocks. Here's an excerpt from my practice project: namespace Tests.VideoStore.Controllers { public abstract class context_for_movie_controller : Specification<MovieController> { private static IList<Movie> movies; prote...

BDD and API calls you don't want to make during tests

I am working on a Rails app that allows you to create a configuration and then launch a server at EC2 with this configuration. So far I've been using cucumber for BDD and was very happy with that. However, now I want to pick a configuration and actually launch the server. Due to cost and performance issues I don't want to actually launch...

What BDD frameworks are popular in .net?

I've recently been getting into BDD and think it holds great promise as a way to get a stakeholder's voice back in the apps we, as developers, create for them. What's your favorite BDD framework and why? ...

Why doesn't every class in the .Net framework have a corresponding interface?

Since I started to develop in a test/behavior driven style, I appreciated the ability to mock out every dependency. Since mocking frameworks like Moq work best when told to mock an interface, I now implement an interface for almost every class I create b/c most likely I will have to mock it out in a test eventually. Well, and programmin...

Create new test suite with Rspec or extend current Test::Unit setup?

So I'm extending a friend's project and he's done all the development with TDD using Test::Unit I use Rspec in all my projects and want to avoid having to learn a new tool. Is it bad practice to have 2 separate test suites, one in Test::Unit and one in Rspec? I've also considered using Shoulda to extend Test::Unit to sort of feel like ...

how to test or describe endless possibilities?

Example class in pseudocode: class SumCalculator method calculate(int1, int2) returns int What is a good way to test this? In other words how should I describe the behavior I need? test1: canDetermineSumOfTwoIntegers or test2: returnsSumOfTwoIntegers or test3: knowsFivePlusThreeIsEight Test1 and Test2 seem vague and it woul...

Testing a scoped find in a Rails controller with RSpec

I've got a controller called SolutionsController whose index action is different depending on the value of params[:user_id]. If its nil, then it simply displays all of the solutions on my site, but if its not nil, then it displays all of the solutions for the given user id. Here it is: def index if(params[:user_id]) @solutio...

RSpec: Stubbing out calls for certain parameters

I want to stub out a method only for a certain parameter. Say I have a class class Foo def bar(i) i*2 end end Now I want to stub out the method bar only for calls with a value of say 3 and return the method return value in all other cases: >> foo = Foo.new >> foo.bar(2) => 4 >> foo.stub!(:bar).with(3).and_return(:borked) >> f...

Could UML use User Scenario diagrams?

Surely you are familiar with UML class diagrams and object diagrams and their relationships. Object diagrams are used to model objects and their relations in a system, which for class based object oriented programming languages means modeling concrete objects of different classes. When working on a project I had to create use cases (dia...

Convert C# unit test names to English (testdox style)

I have a whole bunch of unit tests written in MbUnit and I would like to generate plain English sentences from test names. The concept is introduced here: http://dannorth.net/introducing-bdd This is from the article: public class CustomerLookupTest extends TestCase { testFindsCustomerById() { ... } testFailsForDupl...

SpeckFlow vs Cuke4Nuke vs Cucumber+IR

Hi all: Having a look at BDD frmaeworks and I can't help but wonder which one would suit us better. I like cucumber because, they have been there doing bdd for a good while(since early 2008) and I like ruby, however, we are a .net shop and although I find Ruby very friendly, other people doesn't; and I think that is fair enough (to a p...

Trouble mocking on cucumber + rails

I'm having a lot of trouble trying to define a mock for a rails models on cucumber. It seems like the method is creating a bunch of message expectations and i keep getting errors like these: Given I have only a product named "Sushi de Pato" # features/step_definitions/product_ steps.rb:19 unexpected invocation: #<Mock:ProductCate...

When using a mocking framework and MSPEC where do you set your stubs

I am relatively new to using MSpec and as I write more and more tests it becomes obvious to reduce duplication you often have to use a base class for your setup as per Rob Conery's article I am happy with using the AssertWasCalled method to verify my expectations, but where do you set up a stub's return value, I find it useful to set th...

RSpec, stubbing nested resource methods

I've got two models: class Solution < ActiveRecord::Base belongs_to :owner, :class_name => "User", :foreign_key => :user_id end class User < ActiveRecord::Base has_many :solutions end and I nest solutions within users like this: ActionController::Routing::Routes.draw do |map| map.resources :users, :has_many => :solutions end ...

Spork servers super slow (>3m) to start for RSpec & Cucumber BDD

I recently installed a fresh development setup on my laptop and now notice that my instances of spork take several minutes to start up. This is also most likely of the RSpec and Cucumber tests start up times running super slow. I ran in diagnostic mode with the -d flag and received the output below. Anyone have a clue why this is sudd...

When should the BDD test scenarios be written?

I am looking into BDD testing within a scrum scenario and realise that the BDD scenarios are more akin to specifications than tests. Therefore should they be written before the developers go into pre-planning so that all of the functionality has been identified which would allow better estimating, prioritisation etc in that meeting? ...

How can I decide what to test manually, and what to trust to automated tests?

We have a ton of developers and only a few QA folks. The developers have been getting more involved in qa throughout the development process by writing automated tests, but our QA practices are mostly manual. What I'd love is if our development practices were BDD and TDD and we grew a robust test suite. The question is: While building s...

Rails BDD with Cucumber: no such file to load -- cucumber-rails

I have project on Rails (2.3.5). I add into environment.rb same sting: config.gem "cucumber-rails", run "rake gems:unpack:dependencies". Output of "rake gems": [F] cucumber-rails [F] cucumber >= 0.6.2 [F] term-ansicolor >= 1.0.4 [F] treetop >= 1.4.2 [F] polyglot >= 0.3.1 [F] polyglot >= 0.2.9 [F] builder >= 2.1.2 [F] diff-lcs >=...

Checking ActiveRecord Associations in RSpec.

I am learning how to write test cases using Rspec. I have a simple Post Comments Scaffold where a Post can have many Comments. I am testing this using Rspec. How should i go about checking for Post :has_many :comments. Should I stub Post.comments method and then check this with by returning a mock object of array of comment objects? Is t...