tdd

How do you unit test Subsonic lazy-loaded properties?

Let's say I have the following function I want to test: public void CancelOrder(Order order) { order.Status = "Cancelled"; _emailService.SendEmail(order.User.Email, "Your order has been cancelled!"); } Now, the Order class is a SubSonic generated class and the User property on it is lazy-loaded, meaning that when I call order...

How to start with Rspec?

I have been into rails for the last 3 months. Now I wish to start BDD or TDD. I want to start with RSpec. How do I start with it? ...

Interface Insanity

I'm drinking the coolade and loving it - interfaces, IoC, DI, TDD, etc. etc. Working out pretty well. But I'm finding I have to fight a tendency to make everything an interface! I have a factory which is an interface. Its methods return objects which could be interfaces (might make testing easier). Those objects are DI'ed interfaces to t...

Testing the persistence layer in a DDD/TDD application

If I have the following domain object: public class Customer { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual ISet<Order> Orders { get; set; } public Customer() { Orders = new HashedSet<Order>(); } public virtual void AddOrder(Order order) { ...

Writing Unit Tests Later

I know that TDD style is writing the test first, see it fails then go and make it green, which is good stuff. Sometimes it really works for me. However especially when I was experimenting with some stuff (i.e. not sure about the design, not sure if it's going to work) or frantically writing code, I don't want to write unit tests, it bre...

"messy-polymorphism" anti-pattern

In fairly large Ruby application, we have a situation where a given object is identified by a couple of things: name and id, say. Each of these value types serves a somewhat different purpose and so are not exactly equivalent (id and name persist in different places). So we wind-up with a variety of values being passed around the applica...

Is there a tool for software engineers to track their Requirements -> Design Docs -> Source?

So I recently finish my 3rd year software engineering project. The project was a game. It was not easy in the least. The most challenging project I have done. After some reflection I noticed that the major problem our group had was: Our SRS rarely matched our Design Diagrams Our architecture was not well defined And Lastly our c...

Help me get started with unit testing in Visual Studio 2008

After spending some hours reading about Unit Testing and test driven development here on StackOverflow and on other sites posts pointed me to, I know two things: I want to use it I don't know where to start There are lots of good posts here about details, best practices etc, but what I am looking for is a beginners tutorial/introduct...

How do you write a functional / controller test to check for content added via an AJAX call?

Test def test_generateCashFlowStmt get :getDateRangeForCashFlowStmt xhr :post, :generate_cash_flow_stmt, {:fromDate => {:year=>"2009", :month => "3", :day=>"1"}, :toDate => {:year=>"2009", :month => "3", :day=>"31"} } table = [ .... ] assert_equal table, formatCashFlowStatementAsTable( assigns(...

How to vet an Agile/TDD/DDD coach?

Although I am fairly comfortable (certainly not an expert) with TDD, DDD, and Agile concepts, I am working with some contractors who are not. They're smart guys though and given the limitations of our project they agree that techniques from these schools would increase our chances of success. We are not looking to go full blown but TDD...

NUnit best practice

Environment: (C# WinForms application in Visual Studio Professional 2008) I've been digging around a little for guidance on NUnit best practices. As a solo programmer working in a relatively isolated environment I'm hoping that collective wisdom here can help me. Scott White has a few good starting points here but I'm not sure I totall...

Verify value of reference parameter with Moq

I just switched to Moq and have run into a problem. I'm testing a method that creates a new instance of a business object, sets the properties of the object from user input values and calls a method (SaveCustomerContact ) to save the new object. The business object is passed as a ref argument because it goes through a remoting layer. ...

Unit testing a LINQ2SQL repository

Dear gurus, I am taking my first steps with MsTest and Moq and would like to unit test a Linq2SQL repository class. The problem is that I do not want the unit tests to permantly modify my development database. Which would be the best approach for this scenario? Let each test operate on my real development database, but make sure eac...

Are those unit tests fine?

Hi! I'm trying to grasp test driven development, and I'm wondering if those unit tests is fine. I have a interface which looks like this: public interface IEntryRepository { IEnumerable<Entry> FetchAll(); Entry Fetch(int id); void Add(Entry entry); void Delete(Entry entry); } And then this class which implements that ...

Refactoring a method having dependencies within the same object into something more testable (PHP)

I currently have a method within my class that has to call other methods, some in the same object and others from other objects. class MyClass { public function myMethod() { $var1 = $this->otherMethod1(); $var2 = $this->otherMethod2(); $var3 = $this->otherMethod3(); $otherObject = new OtherClas...

How to use TDD when the fix involves changing the method under test's signature?

I'm trying to get my head around TDD methodology and have run into - what I think is - a chicken-and-egg problem: what to do if a bug fix involves the changing of a method's signature. Consider the following method signature: string RemoveTokenFromString (string delimited, string token) As the name suggests, this method removes all ...

Is Unit Testing your SQL taking TDD Too far?

There is an article out on www.sqlservercentral.com about unit testing your SQL. The TDD Guy in me said good, we can test the database stuff. The System Architect in me said, what logic are we testing? There shouldn't be any logic in the database, the only thing you should be doing in the data base is selecting, updating, or inserting....

Unit testing against large databases

I would like to ask about your suggestions concerning unit testing against large databases. I want to write unit tests for an application which is mostly implemented in T-SQL so mocking the database is not an option. The database is quite large (approx. 10GB) so restoring the database after a test run is also practically impossible. T...

TDD ...how ?

Hi, I'm about to start out my first TDD (test-driven development) program, and I (naturally) have a TDD mental block..so I was wondering if someone could help guide me on where I should start a bit. I'm creating a function that will read binary data from socket and parses its data into a class object. As far as I see, there are 3 part...

Unit testing Scala

Hi! I just recently started learning the Scala language and would like to do it in TDD-way. Could you share your experiences on the unit testing frameworks there are for Scala and the pros/cons of them. I'm using IntelliJ IDEA for Scala development, so it would be nice to be able to run the tests with IDE-support. ...