tdd

Correctly Unit Test Service / Repository Interaction

I have a method CreateAccount(...) that I want to unit test. Basically it creates an Account Entity and saves it to the DB, then returns the newly created Account. I am mocking the Repository and expecting an Insert(...) call. But the Insert method expects an Account object. This test passes, but it just does not seem correct, becaus...

Resources for Unit Testing Cocoa Applications

I'm looking into unit testing and TDD for a Cocoa desktop application and I'd like to find some code examples. I am aware of Chris Hanson's excellent articles, but I'd like to crowdsource finding some examples of actual tests in a code base. ...

How to refactor this constructor so it is testable?

I have a class that is a container for a bunch of module objects. Right now the container takes in an array of file paths, then includes the files and instantiates the modules class module { function execute(); } class container { public $Name; public $Modules; public __construct($Obj){ $this->Name = $Obj->Name;...

Are some logical paths inherently untestable?

I have been using TDD to drive the project that I am currently working on and the results have been fairly satisfying. I did run into a problem (described here; still without a solution or any suggestions!) where there are some aspects of a particular method which may not be able to be tested (as in my example; briefly, I want to be able...

TDD : Any pattern for constant testing ?

Constants are beautiful people - they can hold in a unique place a value that is used everywhere in your code. Changing that value requires only one simple modification. Life is cool. Well, this is the promise. Reality is sometime different : You change the LogCompleteFileName constant value from L:\LOGS\MyApp.log to \\Traces\App208....

Best practices for HttpContext and testable controlers in ASP.Net MVC

Update: Based on a couple of the answers I have received, I just want to make clear that I am well aware how to go about mocking HttpContext using a mocking framework. I am more interested knowing what the pros and cons of mocking HttpContext are when compared to using wrapper classes around HttpContext. I'm looking for opinions on h...

TDD and development time

We are a small group of PHP developers contemplating on integrating or not TDD in our work flow to raise the quality of our web applications and at the same time eliminate the frustrating manual regression testing. My question is on the average how much development time would be added if we start using TDD? ...

When stop testing using TDD?

I don't know so much about Test-Driven Development (TDD), but I always hear that i need to start the development with some test cases. Then, I need to make this tests pass with the most simple solution. And then create more tests to make my tests fail again... But the question is: When stop creating new tests? When I know that my applic...

Unit Testing of private methods in Xcode

I'm trying out test driven development in a toy project. I can get the tests working for the public interface to my classes (although I'm still on the fence because I'm writing more testing code than there is in the methods being tested). I tend to use a lot of private methods becuase I like to keep the public interfaces clean; however,...

What code don't you test?

Possible Duplicate: How deep are your unit tests? Ok, so it's common wisdom that it's impractical (and maybe not even preferable) to get 100% test coverage. In my experience, there's some code that's simply more trouble to test than it is practical to do so. I've kind of developed an intuition about this. But my team is sort ...

Exercises to enforce good practices such as TDD and Mocking.

I'm looking for resources that provide an actual lesson plan or path to encourage and reinforce programming practices such as TDD and mocking. There are plenty of resources that show examples, but I'm looking for something that actually provides a progression that allows the concepts to be learned instead of forcing emulation. My pri...

When to Expect and When to Stub?

I use NMock2, and I've drafted the following NMock classes to represent some common mock framework concepts: Expect: this specifies what a mocked method should return and says that the call must occur or the test fails (when accompanied by a call to VerifyAllExpectationsHaveBeenMet()). Stub: this specifies what a mocked method should r...

How much testing is enough?

I recently spent about 70% of the time coding a feature writing integration tests. At one point, I was thinking “Damn, all this hard work testing it, I know I don’t have bugs here, why do I work so hard on this? Let’s just skim on the tests and finish it already…” Five minutes later a test fails. Detailed inspection shows it’s an import...

Is it normal to have a long list of arguments in the constructor of a Presenter class?

Warning acronym overload approaching!!! I'm doing TDD and DDD with an MVP passive view pattern and DI. I'm finding myself adding dependency after dependency to the constructor of my presenter class as I write each new test. Most are domain objects. I'm using factories for dependency injection though I will likely be moving to an IoC cont...

TDD - Test Existence of Interface

Getting started with TDD and I want to ground up a Repository-driven Model. However, how can I use NUnit to effectively say: SomeInterfaceExists() I want to create tests for each domain model (E.g. ICarRepository, IDriverRepository), etc.) Does this actually make sense? Regards ...

Should I run Unit Tests against my SQLRepository as well?

I'm developing a Domain Model based on the Repository Pattern and all of my Unit Tests as part of TDD are going against a Test Repository. My question is: at what point do I create integration tests against the SQL version of the Repository? My concern is that the code to access data from objects (Test Repository) will work fine. ...

Given the recent trends in TDD and so on, is a "manager" object always a bad idea?

I write applications for various platforms, but chiefly OS X and Windows. On both, I've been influenced by recent trends in test-driven development (TDD), SOLID, and so on. Most of this I've found to be great advice. I've found that if I have excellent test coverage, I'm more likely to refactor as needed, because I'm more confident that ...

Cucumber: Automatic step file creation?

When i run cucumber it displays the possible steps that i should define, an example from the RSpec book: 1 scenario (1 undefined) 4 steps (4 undefined) 0m0.001s You can implement step definitions for undefined steps with these snippets: Given /^I am not yet playing$/ do pending end When /^I start a new game$/ do pending end Then /^t...

Unit testing with multiple collaborators

Today I ran into a very difficult TDD problem. I need to interact with a server through HTTP POSTs. I found the the Apache Commons HttpClient, which does what I need. However, I end up with a bunch of collaborating objects from Apache Commons: public void postMessage(String url, String message) throws Exception { PostMethod post =...

Are there any good online tutorials to TDD for an experienced programmer who is new to testing?

I'm working with a Python development team who is experienced with programming in Python, but is just now trying to pick up TDD. Since I have some experience working with TDD myself, I've been asked to give a presentation on it. Mainly, I'm just wanting to see articles on this so that I can see how other people are teaching TDD and get...