What are the good resource to learn BDD & TDD (ruby , C#, javascript).
What are the good framework using now?
See
Why should I practice Test Driven Development and how should I start?
Beginning TDD - Challenges? Solutions? Recommendations?
Good C# Unit testing book
Introducing BDD
What is the Path to Learn BDD on Ruby On Rails?
Jasmine
Hanselminutes - Understanding BDD and NSpec
I can't really speak with too much authority on this subject, nor will I speak with too greater vigour given how storongly people feel about those two acronyms but it seams as though you are new to BDD / TDD so I will tell you what I wish someonehad told me when I first encoubtered them.
Tests and tools are one component of the overall process and methodology behind TDD, it is arguably one of the more visible aspects and so it is likely that you will see a lot of references to testing being an importabt part of TDD, and it is, I'm just saying, if you are interested in learning about TDD, don't forget the other aspects of it as well.
Resources I have found helpful:
The Pragmatic Programmer: doesn't
really talk about TDD per se, but it
does emphisise a lot of other good
practices that will help you.
Hanselminutes Episode 169
Tools I find helpful
TestDriven.NET - test runner in
visual studio
xUnit.NET - Test Framework
Rhino Mocks - Isolation (mocking)
framework
Here are a few links that may be helpful to you.
What is the most mature BDD Framework for .NET?
Introduction to BDD and Mocking
BDD using NUnit and Moq
RSpec vs Cucumber (RSpec stories)
BDD with Cucumber and rspec - when is this redundant?
NSpec Project Site
Continuous Testing
IMO, the best way to learn these days is with plurasight
http://www.pluralsight-training.net/microsoft/
my boss pays for me and my fellow developer to access the videos, but even if he didnt, its thats good id pay for it myself.
Related
Should I keep using Mocks with Visual Studio 2010 Ultimate?, I mean, all the information I'm gathering about mocks is kinda old, from like 2 or 3 years ago, more specific, I'm gathering info about the next frameworks Rhino Mocks and Moq.
But then, I don't know if I'm looking for something old or deprecated or that it's not used nowdays... I'm making a new project and I want to used the last frameworks to implement the TDD in the best way possible, and since we recently acquired the Ultimate version of VS2010, which has a lot info and utilities about testing, I wanna do the things the way they should be done.
Oh, I almost forgot, I have to use VB, and most of the info about these frameworks are in C#, I don't know if that could be relevant...
Thanks in advice!
EDIT
Moq along with AutoFixture did the job
Moq is my mocking framework of choice, but that's just a personal preference. And it doesn't really matter that the samples are typically written in C#, provided you can read C#, since you can use all the same methods, but with a slightly different syntax.
You really can't go wrong with either Moq or RhinoMocks.
Rhino and Moq will both give you what you need. If money is not an issue I would also suggest Typemock.
Rhino, Moq and (my favorite) FakeItEasy are nice mocking/faking frameworks.
It shouldn't matter which language you're testing in (VB or C#), but to be safe check the docs for all these frameworks. I know FakeItEasy supports VB.NET. You should also look into Roy Osherove's book about unit testing in .NET, highly recommended.
I tend to look at the activity on the web site where the source is hosted and try to work out whether a project is being actively maintained. If there is good developer velocity then that's usually a sign of a well-supported project. All of the mocking frameworks mentioned here are fairly good bets, my personal favourite is Moq and I like to use it with MSpec (Machine.Specifications), but of course each developer or team needs to make those choices for themselves.
If you haven't already, get the NuGet plugin for Visual Studio and use that to install all your frameworks. If you are using a CI build and don't want to check these items into your version control, there is a 'no-commit workflow' for NuGet that uses the NuGetPowerTools package.
Regarding the examples being in C#, you can use the Telerik Code Converter to easily translate them into VB.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am interested in Behavior Driven Development (BDD)
Are there any good frameworks and/or tooling available for the .Net platform (preferably C# and ASP.Net)?
And when has BDD proved most appropriate to use in real world scenarios? (auxiliary question)
+1 for people's recommendation of SpecFlow for scenarios; never used it but heard many good things about it. I've been using plain old NUnit with a little DSL like this. MSTest would work similarly.
You can also do BDD in the unit space, which is what MSpec is designed to do. I'm personally hating MSpec, but the rest of the team here love it. They like writing examples of how the code works. I like to show why the behavior is valuable. It's a subtle distinction and if you're not worried about doing this at a unit level it won't hit you.
Other frameworks to look at include Concordion, Fitnesse.NET (please put FitSharp behind it!) and TickSpec.
In the real world, the most valuable bit of BDD by a long way is the conversations, not the automated tests. Here's a couple of quick hints and tips for making it work:
Don't write automated tests over things which are in flux. It just commits you to stuff you got wrong. Wait until the UI has settled a bit then do it.
If you don't care much about your UI, but do care about data integrity, write the scenarios over the controller / presenter layer (eg: for admin screens).
Don't start with login. Start by describing a valuable part of the application for which you might log in. Do that first (assume you only have one user). You'll get quicker feedback on the risky bits.
Seek quick feedback on the risky bits, which will usually be the bits which you've never done before. Use scenarios to have conversations around them. Write anything interesting you discover down, but forget the scenarios which are obvious - they're obvious! Don't worry about automating them to start with. Having conversations is more important than writing down conversations is more important than automating conversations.
Good luck! If you want to know more about BDD, I put together a page of relevant links here.
On googling I found Behavior Driven Development (BDD) with SpecFlow and ASP.NET MVC. You might find it useful, take a look. Also go through Behavior-Driven Development with SpecFlow and WatiN
A nice presentation on Pros and Cons of BDD
A channel 9 video Behavior-Driven Development in the Real World
and last but not least an InfoQ article Behavior Driven Development In .NET
LightBDD is an open source framework allowing to write BDD tests that are easy to read but also easy to maintain and extend when project grows larger.
The main features that it offers are:
easy to read scenarios,
easy maintenance of tests,
integration with well known testing frameworks (NUnit / MbUnit / MsTest / xUnit),
scenario steps execution tracking and execution time measurement,
test execution summary report generation in HTML (an example report), XML and plain text format.
It bases on tests that are written purely in code, which means native support for refactoring, code analysis, test running and all other features that Visual Studio / Intellisense / Resharper offers.
An example test written in this framework looks as follows:
[TestFixture]
[FeatureDescription(
#"In order to access personal data
As an user
I want to login into system")] //feature description
[Label("Story-1")]
public partial class Login_feature //feature name
{
[Test]
[Label("Ticket-1")]
public void Successful_login() //scenario name
{
Runner.RunScenario(
Given_user_is_about_to_login, //steps
Given_user_entered_valid_login,
Given_user_entered_valid_password,
When_user_clicked_login_button,
Then_login_is_successful,
Then_welcome_message_is_returned_containing_user_name);
}
}
More information about framework could be found on project wiki page and project main page.
Also MSpec is a good framework.
I use it in the Microsoft stack you mention (C#, ASP.Net and MVC) and I like his syntax.
BDD helps you thinking in business/feature oriented way not just in a code way.
So you are most focused on business value.
It also helps in user acceptance test to create a trust between you and customer.
There is a great tool, called SpecFlow.
SpecFlow is inspired by Cucumber — the well known BDD framework for Ruby on Rails. And has a huge amount of advantages.
You should definitely check it out.
One interesting BDD frameworks is Concordion.NET. It is an open source BDD framework for the Microsoft stack that uses NUnit to execute the Concordion.NET tests: https://github.com/concordion/concordion-net
As Concordion specifications are written in simple HTML, it provides a good basis for a living documentation system. You can use a what-you-see-is-what-you-get (WYSIWYG) editor like BlueGriffon to describe your intended behavior of your software in simple HTML documents and instrument them to verify your system under test.
According to the excellent classification of BDD tools, Concordion.NET focuses on business readable input (and reaches business readable output as well). It moves even beyond BDD and supports ATDD: http://assertselenium.com/2012/11/05/difference-between-tdd-bdd-atdd/
Spec4Net (https://bitbucket.org/fthomsen/spec4net/) is a nice framework too. We use it extensively at work. The learning curve is almost non-existing and the natural flow seems intuitive.
In a previous question found here, I asked a question about BDD and SpecFlow. The best answer was to use nSpec instead of SpecFlow.
I found nSpec, but I am having trouble finding tutorials on how to use it with C#. My google mojo isn't working for this topic.
Apart from the small instructional on the nSpec github site on how to install nSpec, does anyone have any links to good beginning tutorials on using nSpec?
I'm not sure if we are talking about the same framework (whether you meant nStep or NSpec). But here is some information on NSpec.
NSpec Project Site
There is an NSpec Project Site that has a good set of features showcased to help you get started.
Sample NSpec Usage
On github, the NSpec Samples Project will give you greater insight into the framework.
Additional Resources
It's important to be aware that there are two flavors of BDD. The following link explains the two different forms, their pros and cons, and how you can benefit from each:
What is the most mature BDD Framework for .NET?
NSpec Project Site
Continuous Testing
Introduction to BDD and Mocking
BDD using NUnit and Moq
You can see the Cuke4nuke (nStep's cousin) screen cast here:
http://www.richardlawrence.info/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/
I think they're quite similar, so watching the screencast should get you the basic idea.
(You can also checkout Cuke4nuke's wiki)
If you have trouble in getting started, why don't you switch to a framework that has a tutorial available?
I have written a complete run-through for my own BDD engine, called Aubergine; you can see it here:
http://www.corebvba.be/blog/post/Getting-started-quickly-with-BDD-in-Net.aspx
I'm looking for a good introduction/tutorial for unit testing C#. Most tutorials I've come across so far have either been too basic to be useful or too complex for someone new to unit testing.
(Using Visual Studio 2008 Professional for Windows applications)
Read The Art of Unit Testing by Roy Osherove. It is very good.
Is it just a specific tool for which you're having trouble finding good tutorials? When I was new to the subject I found the NUnit tutorial to be a good starting point:
http://www.nunit.org/index.php?p=quickStart&r=2.4
Rhino Mocks would be good to learn as well to complement the unit testing framework:
https://stackoverflow.com/questions/185021/rhino-mocks-good-tutorials
Perhaps a book? I would recommend you the Pragmatic Unit Testing in C# with NUnit.
It's very complete in my opinion.
It was when I started reading about Moq that I realized unit testing didn't have to be painful. There are some good links near the bottom of the page as to how unit tests can be built with mocking.
One nice thing about using interfaces for controlled coupling and testing is that adding an interface to an existing code base is not a breaking change. I'm adding new features to some legacy code and I've been creating interfaces for existing classes so that the new features can be developed and tested in isolation. It's been working well so far and I plan to continue this style of testing on other projects. For me, the key was to avoid designing complex stub classes with lots of ugly conditional code to expose different cases for my tests. It got to the point where the test code was so complex that I couldn't be sure if it was the code or the test that was broken.
Can any one suggest a step by step example for using moQ framework.
any guidelines or thumbrules that has to be followed while mocking objetcs . can be much help.
thanks.
Here's the moq quick-start
Update: To address your comment... A large part of writing testable code involves removing dependencies on classes/resources outside the scope of your control. A very common approach to doing this is by talking to interfaces instead of concrete examples.
It's a little much to describe properly (especially since I just rolled out of bed), so let suggest you pick up a copy of Roy Osherove's 'The Art of Unit Testing'. It's a fairly short book and is filled with good advice and lots of summary information to get you familiar with many of the approaches to unit testing.
I only started to use Moq recently and I am not sure how much help this will be but if you can get your hands on Chapter 3 of Pro ASP.NET MVC Framework there is a really good step-by-step example of using moq and NUnit with ASP.NET MVC.