tdd

Good example/reference of using TDD with Model View Presenter using Rhino Mocks.

Appreciate any good example or references to websites which has useful information of using TDD with Model-View-Presenter pattern using Rhino Mocks. What I am looking for is with respect to the following points What to mock (view and presenter) The new AAA syntax How to mock UI behaviour? e.g. if "firstName" and "lastName" entered in...

How to do TDD and unit testing in powershell?

With MS ramming powershell into all new server products, I'm starting to (reluctantly) think I need to take it seriously. Part of "taking it seriously" is TDD. Have you found good methods to unit test power shell scripts? I've found samples of mocking from Mr Geek Noise - but I'd really like something like RhinoMocks. Brian Hartsock ha...

Which community (language/framework) embraces agile practices the most?

I have been practicing TDD and (some) XP for a few years now and have found that it solves many of the problems I had in my career previous to it's adoption. By removing so many headaches, my love of coding has been rejuvenated. The problem is I have also found it difficult to find .NET (my current stack) projects utilizing these pract...

Test and Mock framework for Java and .NET

I'd like to know your thoughts about test/mocking frameworks that are widely used and have a good level of compatibility between Java and .NET. I mean, I want to learn those tools to use in a .NET project, but I still wanna be able to apply that knowledge in Java projects. I know there're many questions about test/mocking frameworks to...

Does YAGNI also apply when writing tests?

When I write code I only write the functions I need as I need them. Does this approach also apply to writing tests? Should I write a test in advance for every use-case I can think of just to play it safe or should I only write tests for a use-case as I come upon it? ...

Version control and test-driven development

The standard process for test-driven development seems to be to add a test, see it fail, write production code, see the test pass, refactor, and check it all into source control. Is there anything that allows you to check out revision x of the test code, and revision x-1 of the production code, and see that the tests you've written in ...

Unit Testing a Login in ASP.NET

I'm very new to TDD and I'm having trouble with one of my unit tests. I just can't seem to understand what to do next. :( I'm trying to unit test a service of mine called AccountService and I'm testing a method called DoLogin(username, password). Here's some example code: [Test] public void User_With_Correct_Username_And_Pass_Sh...

[MBUnit 3] Is there any good way to run one set of tests with two different AssemblyStartups

I'm working on a pretty standed ASP.NET MVC application. We've got the core logic behind a set of services and we're using StructureMap to inject appropriate instances of appropriate IRepositories to abstract communications with the data layer proper. We've also got a rather exhaustive series of unit tests on these services. But, as thin...

When is it preferable to store data members as references instead of pointers?

Let's say I have an object Employee_Storage that contains a database connection data member. Should this data member be stored as a pointer or as a reference? If I store it as a reference, I don't have to do any NULL checking. (Just how important is NULL checking anyway?) If I store it as a pointer, it's easier to setup E...

How Much Should Each Unit Test Test?

How much should each of my unit tests examine? For instance I have this test [TestMethod] public void IndexReturnsAView() { IActivityRepository repository = GetPopulatedRepository(); ActivityController activityController = GetActivityController(repository); ActionResult result = activityController.Index(); Assert.IsInst...

In TDD and DDD, how do you handle read-only properties in fakes?

Question How do you handle read-only fields when creating fakes? Background I'm in the beginner stages of using ASP.Net MVC and am using Steven Sanderson's Sports Store and Scott Gu's Nerd Dinner as examples. One small problem that I've just hit is how to work with read-only properties when doing fakes. I'm using LINQToSQL. My interf...

Mocking Membership

I'm writing a custom Profile provider, but I still intend to use the default AspNetSqlMembershipProvider as my Membership provider. My GetAllProfiles() method in my Profile provider looks like this: 1 public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, o...

Client changes in a TDD/BDD process

I'm coming from a big design background, and just learning TDD/BDD so bear with me if this is a simple question. It seems that many client decisions aren't actually recorded anywhere - they're just documented in the code and tests. So my question is: what happens when the client changes some of these undocumented decisions? How do yo...

Literals or expressions in unit test asserts?

Do you prefer literal values or expressions in your Asserts in your unit tests? This little example demonstrates what I mean - please pay attention to the comments: [Test] public function fromXML_works() : void { var slideshow : Slideshow = SlideshowConverter.fromXML(xmlSample); // do you prefer literal value "1": assertEqu...

Rails: Unit testing a before_create?

I am trying to test that a field is being generated properly by a callback, but I can't figure this one out. album.rb before_create :generate_permalink private def generate_permalink @title = album.downcase.gsub(/\W/, '_') @artist = artist.downcase.gsub(/\W/, '_') self.permalink = @artist + "-" + @title end albu...

[AssemblyInitialize] and TestDriven.Net

Has anyone experienced any issues with using the mstest attribute [AssemblyInitialize] when running tests with TestDriven.Net? I've tried 2.14 RTM and 2.22 RTM and neither seem to work for me. When I execute the test, the assembly init method isn't being executed. It's like TD.Net doesn't recongize the attribute. Any tips/ideas/clues i...

Functional testing Authlogic?

In a few of my controllers I have a before_filter that checks if a user is logged in? for CRUD actions. application.rb def logged_in? unless current_user redirect_to root_path end end private def current_user_session return @current_user_session if defined?(@current_user_session) @current_user_session = U...

The Purpose of Mocking

What is the purpose of mocking? I have been following some ASP.NET MVC tutorials that use NUnit for testing and Moq for mocking. I am a little unclear about the mocking part of it though. ...

Taking unit testing to the next level

Over the past year or so I have been developing my TDD chops so that I am now fairly good at the essentials - writing tests first, mocking frameworks, testing as small things as possible, DI etc. However I feel like there are still a lot of things that I am not getting out of unit testing. For example, I often find that unit testing in...

Is edit-triggered testing the next step?

I have just read Michael C. Feathers great book Working Effectively with Legacy Code, the bible of introducing tests to legacy code. In this book he describes something called Edit-triggered testing: If it isn't out by the time this book is released, I suspect that someone will soon develop an IDE that allows you to specify a set of ...