tdd

TDD as a defect-reduction strategy

Can TDD be successful as a defect-reduction strategy without incorporating guidance on test case construction and evaluation? ...

C#: How to TDD a file downloader

I would like to create a simple downloading tool. Give it a list of urls, a target directory and hit go. It would then download those files and dump them in the target directory. Simple enough. But, I would like to practice TDD as well. But how would you do TDD in such an application? I can see 4 main parts of application: A download ...

TDD: Does it get in the way of good API design?

I've never written TDD code, but I've seen a decent amount of discussion about it here on SO. My biggest concern with it is that it seems like general good API design (for flexibility, ease of use, simplicity of interface, and performance) takes a back seat sometimes to making code mockable, ultra-modular beyond what is necessary for an...

Should I document my unit test methods?

As it happens with private methods, unit test methods documentation can only be seen by who has access to the source code. Is it worth the effort spent on it? By documentation I mean something like (but more descriptive): /// <summary> ///A test for SomeClass.SomeMethod ///</summary> [TestMethod()] public void SomeMethodTest() { } ...

How do you maintain discipline when doing TDD?

When I get excited about a new feature I'm just about to implement or about a bug that I've just "understood", there is the urge to just jump into the code and get hacking. It takes some effort to stop myself from doing that and to write the corresponding test first. Later the test often turns out to be trivial 4-liner, but before writin...

cakephp unit testing models, fixtures problem

Hey all, So i'm working with CakePHP v1.2.5. On my current project, I decided to start writing tests as I code the functionality (yay TDD). I'm having trouble with fixture loading though. To aid in the process, I'll describe my code (Really quite simple right now). My model is defined like so // app/models/newsitem.php <?php class New...

Should I create a new test method for each assertion?

I know that this is subjective, but I'd like to follow the most common practice. Do you normally create one test method for each class method and stuff it with multiple assertions, or do you create one test method per assertion? For example, if I am testing a bank account's withdraw method, and I want make sure that an exception is thro...

Testing the User.IsInRole in MVC.NET

Dear All, I am trying to test the User.IsInRole("Administrator") in my application, and actually trying to assign the User Role to ("Administrator") so that my test will pass. I am using Scott Hanselman's MvcMockHelpers to do this, and at the moment I have the following test. [Test] public void Create_CanInsertNewArticleView_I...

Test Driven Development/Integration Testing in RIA development

Hi! When working with RIA development, there's at least three critical levels that should be tested: RIA application classes - in Flash/Flex these could be tested using AsUnit, FlexUnit or any other JUnit-like solution RIA application interface - in Flash/Flex this could be done using FlexMonkey RIA application server integration - ? ...

Unit testing and TDD, OCUnit vs Google Tool Box.

Hi, I'm trying to choose between OCUnit and Google Tool Box, do you have any preferences, would recommend one or the other, why ? I would be very interested to hear about your experiences with any of the 2. The main problem i have with both of them is the managment of crashes in tested methods (ex: BAD ACCESS) None of them was able to ...

Infrastructure required for TDD?

Hi all, I am 'relatively new' to unit-testing and TDD. Only more recently have I completed my first production application that has (at least in theory) 100% code coverage. I have done unit-testing in previous projects as well for some time, but not in true TDD fashion and with good code coverage. It had always been an after-thought. I ...

Testing the Create in a Controller

Hi All, I am very new to Testing and MVC.NET, and I have some code in the Create of the ArticleController which I wish to test, however I need some help because at the moment I am kind of stuck. My Code is as follows :- if(ModelState.IsValid) { try { if (!User.IsInRole("Administr...

ISO public Django apps developed Agile / BDD style with Doctest, Unitests and Selenium

I've found several blog posts where TDD/BDD is explained, but the examples are usually really basic. Usually they are just for Models. I want to see how people are really using BDD in Real Life. I'd love be pointed towards some Django apps that were built test first style so I can learn from them. I know that Rails had many examples, s...

Test Driven Development - What exactly is the test?

I've been learning what TDD is, and one question that comes to mind is what exactly is the "test". For example, do you call the webservice and then build the code to make it work? or is it more unit testing oriented? ...

Recommend good online sample walkthrough of TDD?

I find unit testing vital. Several times I have tried the TDD but given up on it as sitting down with a piece of paper and drawing out a few diagrams first always seem more productive. As so many advocate the TDD I will keep trying. I looked at this http://xprogramming.com/xpmag/sudoku5 (the last article of 5) but this seemed to high...

Why would I unit test this controller's action?

I have a ArticleController that displays a list of articles according to a category. public ActionResult List(string categoryname) { MyStronglyTypedViewData vd = new MyStronglyTypedViewData(); DBFactory factory = new DBFactory(); categoryDao = factory.GetCategoryDao(); articleDao = factory.GetArticleDao(); ...

How to stub abstract collection with Moq?

Let's say I have this class: public abstract class CustomerCollectionBase : Collection<Customer>{} One of my classes under test accepts CustomerCollectionBase instance (it will be some subclass). In the method under test, this collection is enumerated via for loop and results are examined and processed. like follows: for(int i=0;i<_c...

A BDD example - why test "happy path" only?

I've accidentally stumbled upon an old article by Luke Redpath that presents a very simple BDD example (very short and easy to follow even for non-Ruby programmers like me). I found the end result very incomplete, thus making the example pretty useless. The end result is a single test which verifies that a user with preset attributes is...

No colors when using autospec

When I'm using autospec to test a non-Rails Ruby project, I always have trouble getting my tests to show up red or green. When I run a regular 'spec spec/ --color' command I get normal red/green responses. I've tried putting all sorts of commands in the .autotest file and I can't get that to work. Also, in my Rails projects, I don't ge...

Is anyone actually succesfully using MSTest across the team??

Hi, I've been using MSTest so far for my unit-tests, and found that it would sometimes randomly break my builds for no reason. The builds would fail in VS but compile fine in MSBuild - with error like 'option strict does not allow IFoo to cast to type IFoo'. I believe I have finally fixed it, but after the bug coming back and struggling...