tdd

Testing rails partial views standalone

Hi, I'm using Test/Unit with a standard rails 2.1 project. I would like to be able to test Partial Views in isolation from any particular controller / action. It seemed as though ZenTest's Test::Rails::ViewTestCase would help, but I couldn't get it working, similarly with view_test http://www.continuousthinking.com/tags/view_test Mos...

Should I practice "mockist" or "classical" TDD?

I've read (and re-read) Martin Fowler's Mocks Aren't Stubs. In it, he defines two different approaches to TDD: "Classical" and "Mockist". He attempts to answer the question "So should I be a classicist or a mockist?", but he admits that he has never tried mockist TDD on "anything more than toys." So I thought I'd ask the question here...

As a "mockist" TDD practitioner, should I mock other methods in the same class as the method under test?

After reading Martin Fowler's Mocks Aren't Stubs, I've discovered I've been practicing TDD in the "mockist" fashion. But I'm wondering if even in mockist TDD if one can take mocking too far. Here's an updated example in Python-style pseudo-code: def sync_path(self): if self.confirm_or_create_connection(): self.sync(self.di...

How to make junit testing to stop after first failing test

Is there a way to make running junit test to stop after a test fails? ...

What techniques do you use when you are designing an Object Model alone?

So no doubt that building a domain model is something that I think happens best when you approach it as as team. Even going so far as to involve someone who is not technical and a member of the 'business' in the modeling sessions. So much can get done quickly when you put the right people in a room and hammer out things on a whiteboard...

Quick Rhinomocks Help

Can someone take a look at this code and tell me if there's any obvious reason it shouldn't be working? When service.getResponse is called within my code the mocking framework only returns null, not the object I specified. [Test] public void Get_All_Milestones() { var mockRepo = new MockRepository(); var serv...

Test Driven Design for iPhone Native apps

I'm experimenting with the iPhone SDK and doing some TDD ala Dr. Nic's rbiPhoneTest project. I'm wondering how many, if any, have been successful using this or any other testing framework for iPhone/Cocoa? More important, I'd like to know how to best assert a proprietary binary request/response protocol. The idea is to send a binary requ...

Unit Testing a Data Structure

I'm writing a data structure in C# (a priority queue using a fibonacci heap) and I'm trying to use it as a learning experience for TDD which I'm quite new to. I understand that each test should only test one piece of the class so that a failure in one unit doesn't confuse me with multiple test failures, but I'm not sure how to do this...

Managing the maintenance burden of unit tests

Coding test-first, I find that perhaps 3/4 of my code is unit tests; if I were truly extreme, and didn't write a line of code except to fix a failing unit test, this ratio would be even higher. Maintaining all these unit tests adds a huge amount of inertia to code changes. Early on, I suck it up and fix them. As soon as there's pressu...

How do you do TDD in a non-trivial application?

I've read a number of books and websites on the subject of TDD, and they all make a lot of sense, especially Kent Beck's book. However, when I try to do TDD myself, i find myself staring at the keyboard wondering how to begin. Is there a process you use? What is your thought process? How do you identify your first tests? The majorit...

Do you use Unit Testing in your professional projects?

We are about to start a new part of the project and there doesn't seem to be a lot of interest in unit testing (and it doesn't feel like they have experienced TDD). I believe it's nearly essential and it makes maintainance much easier. So what are your views? Thanks BTW: this is a language agnostic question, however the new project is ...

Should my unit tests be touching an API directly when testing a wrapper for that API?

I have some written a number of unit tests that test a wrapper around a FTP server API. Both the unit tests and the FTP server are on the same machine. The wrapper API gets deployed to our platform and are used in both remoting and web service scenarios. The wrapper API essentially takes XML messages to perform tasks such as adding/del...

Unit testing with C/C++: Lessons, what to remember?

Unit testing with C/C++: What do you teach people who either did not do unit testing before or come from Java/Junit? What is the single most important lesson / thing to remember/ practice from your point of view that saves a lot of time or stress (especially regarding C/C++)? ...

Shoulda testing workflow from the trenches

Everyone is talking about TDD (BDD) in Rails (and not just Rails) development world today. It's easy to find plenty of good general information about it, there are quite a few tools you can use for this purpose and there are many (good) examples of how to use them. Now, I'm already on the train. I like the idea (never did TDD before) a...

How do you use debugging to step into a class in a web application from a test project in the same solution?

When using NUnit and the test project, we haven't been able to find a way to step into the class we are testing in a web application. We are using TestDriven.NET add-in for Visual Studio 2008. We are able to hit a breakpoint in the test project, but not step into the web app class that is being tested. ...

GWT Unit Testing TDD and Tooling

hi there I m just starting using gwt and so far so good, however after reading some sample code I wonder is it necesary to have a high level of test coverage? (I can see that most code is declarative and then add some attributes I can see the sense in checking so me particular attributes are there but not all) Also i would be intereste...

How to mock classes instantiated as local variables

I'm writing tests for a business method that invokes some DAO classes to perform operations over a database. This method, firstly retrieves a JDBC connection from a DataSource object, The same connection is passed to all DAO instances, so I can use it to control the transaction. So, if everything works properly, I must invoke commit() o...

Do polymorphism or conditionals promote better design?

I recently stumbled across this entry in the google testing blog about guidelines for writing more testable code. I was in agreement with the author until this point: Favor polymorphism over conditionals: If you see a switch statement you should think polymorphisms. If you see the same if condition repeated in many places in your cl...

How to convert a software shop to TDD?

I would really love to push for TDD development inside the shop I'm working in. Lots of the seniors over there didn't work with unit testing or did unit testing that was hitting the database. I would love to bring some good arguments, books for training, possible coach to ease the transition. ...

Is it possible to throw a MessageQueueException?

I am using a mock object in RhinoMocks to represent a class that makes calls to MessageQueue.GetPublicQueues. I want to simulate the exception thrown when message queueing is operating in workgroup mode, which is a MessageQueueException, to ensure that I am catching the exception correctly The MessageQueueException has no public constru...