bdd

Best way to implement Repository Pattern?

I've been exploring BDD/DDD and as a consequence trying to come up with a proper implementation of the Repository pattern. So far, it's been hard to find a consensus over the best way to implement this. I've tried to boil it down to the following variations, but I'm unsure which is the best approach. For reference I'm building an ASP.MV...

How much do you test your controllers?

I am currently beginning with BDD - I have not written any tests before. I always try to keep my models fat and my controllers skinny. What do you think - are controller specs necessary? Best regards ...

How do I check that a form is pre-populated with values using Cucumber and Webrat?

I am learning Cucumber and Webrat with Rails and would like some advice on the best way to test an "edit" form. When I browse to a user's profile I am presented with an edit form with the user's information pre-populated in the form fields. I would like to be able to test that the fields do in fact contain the information I expect. Here'...

How to avoid anemic domain models, or when to move methods from the entities into services

I have a common scenario that I am looking for some guidance from people more experienced with DDD and Domain Modeling in general. Say I start out building a blog engine, and the first requirement is that after an Article is posted, users can start posting Comments on it. This starts fine, and leads to the following design: public clas...

Repository of "standard" BDD specs

Do you know of any resources or libraries of BDD specs? For example, almost every web app has a login process. Some "standard" features might be handling of forgotten passwords, reset password, etc. I'm thinking of something like a code snippet archive of BDD specs so we don't all have to write them from scratch. ...

ASP.net MVC RTM Test naming conventions

I am working on an asp.net mvc application and writing my unit tests BDD style. Eg. GetResource_WhenResourceFileExists_ShouldReturnResources() But when I am writing tests for my controllers, I usually have two Methods with the same name. One without parameters for get requests and one with for posts. Does anybody have a good naming...

Domain Driven Design: When to make an Aggregate Root?

I'm attempting to implement DDD for the first time with a ASP.NET MVC project and I'm struggling with a few things. I have 2 related entities, a Company and a Supplier. My initial thought was that Company was an aggregate root and that Supplier was a value object for Company. So I have a Repository for company and none for Supplier. Bu...

BDD/DDD Where to put specifications for basic entity validation?

Alternatively, is basic entity validation considered a specification(s)? In general, is it better to keep basic entity validation (name cannot be null or empty, date must be greater than xxx) in the actual entity, or outside of it in a specification? If in a specification, what would that look like? Would you have a spec for each fiel...

Fluent NHibernate HasMany Collection Problems

Update: It appears that changing my mapping from Cascade.All() to Cascade.AllDeleteOrphan() fixes most of my issues. I still have to explicitly set the Company property on the OperatingState, which seems unnecessary as it's being added to the Company entity, but at least I can work with that during an update. I still need to test that wi...

What are the good frameworks for unit-testing and mock objects in Perl?

What frameworks and tools would you recommend for unit-testing and mock objects in Perl? I have an existing Perl application, that mainly does database access, reading and writing files. The application is basically a batch job type of application, it reads in bunch of stuff from files and database and writes a bunch of new files and so...

How to write unit tests in spec form?

I have difficulty in many situations to come up with a good unit test names for classes and methods. Typically, I try to follow the form: public class TestContext { [Fact] public void WhenThis_DoThat() { } } Some put words Given, When, and Then on the parts to be explicit. I like it because it seems to make the unit ...

What is the definition of BDD?

BBD is referenced in this thread (Karl Seguin's answer). What is BDD? ...

Tell me what is stupid about my Entity Validation (and how to improve it)

I have an IEntity interface that implements an interface, IValidatable public interface IValidatable { bool IsValid { get; } bool IsValidForPersistence { get; } // Rules applied at UI time (please enter your name, etc) IEnumerable<RuleViolation> GetRuleViolations(); // Rules to be applied only at persistence time ...

How (strategy) to unit test properties (get/set) in BDD style?

I have a class (of many) that have properties. Some have logic in them and some don't. Assuming I want to test these properties, how do I go about doing that? Recently, I've been interested in BDD style for creating unit tests. see here and here. So I'd do a setup of the context - basically create the SUT and load up whatever is nee...

Testing Pagination Features with Cucumber

I am learning and liking cucumber, and now have a feature I'm not sure of the best way to proceed on via BDD: pagination. I have scenarios (in my mind) where there are zero pages, one page, several pages, etc. and where I want to make sure certain records are on certain pages, make sure the "next" button is not a link when on the last pa...

Test::Unit tests passing on OS X, erroring out on CentOS

I have a set of Test::Unit tests for a Rails application. It was developed on OS X under Ruby 1.8.6, Rails 2.3.4. I'm also using thoughtbot-shoulda 2.10.2. I'm using standard Rails fixtures, not factories. I've checked out the project onto a CentOS Linux 5 workstation for another developer to work on. He's running Ruby 1.8.7. (The ap...

check for (the absence of) `puts` in RSpec

I am using rspec for my test in a ruby project, and I want to spec that my program should not output anything when the -q option is used. I tried: Kernel.should_not_receive :puts That did not result in a failed test when there was output to the console. How do I verify the absents of text output? ...

Practicing BDD with integration tests -- do I need unit tests too?

At present, my development process flows like this: I describe the expected behaviour as an integration test using using WebRat I write the Ruby on Rails code to provide that behaviour, so passing the test I refactor, ensuring the tests still pass at the end of the process I write the next integration test It seems to me that by defi...

How to unit test private methods in BDD / TDD?

I am trying to program according to Behavior Driven Development, which states that no line of code should be written without writing failing unit test first. My question is, how to use BDD with private methods? How can I unit test private methods? Is there better solution than: - making private methods public first and then making th...

MD5 code kata and BDD

I was thinking to implement MD5 as a code kata and wanted to use BDD to drive the design (I am a BDD newb). However, the only test I can think of starting with is to pass in an empty string, and the simplest thing that will work is embedding the hash in my program and returning that. The logical extension of this is that I end up embed...