Test Driven Development involves writing a failing automated test to specify what is to be built. The test is then made to pass by writing code which satisfies the tested condition. Finally, the code is refactored.

learn more… | top users | synonyms

10
votes
4answers
172 views

TDD svino Problem #4 - largest value from concatenated integers?

From this blog post: Write a function that given a list of non negative integers, arranges them such that they form the largest possible number. For example, given [50, 2, 1, 9], the largest ...
5
votes
3answers
137 views

Random letter test

My first test (randomUpperCaseLetter) checks if the returned random letter is an uppercase ASCII one. The second one (...
10
votes
5answers
642 views

TDD for Euler Problem #4

I am in the process of learning Java and going through the Euler problems. For Problem 4 I decided to also implement a TDD approach with JUnit. My questions are: Is there a better TDD approach to ...
2
votes
2answers
124 views

Diamond kata in JavaScript

I'm just starting to learn JavaScript. I implemented the Diamond kata, and I would appreciate if anybody could give me some feedback. I'm particularly concerned about learning the most 'idiomatic' way ...
4
votes
1answer
80 views

Simple Pizza Factory with tests

I implemented the Simple Factory Pattern with some unit tests, but I'm with a feeling that I did something wrong and that I can improve it. Tell me what you think about the code (source and tests). ...
3
votes
1answer
85 views

Disjoint-set data structure in Python 3

Inspired by this question, I decided to implement a Disjoint-set data structure in Python 3. I mainly followed this description for understanding the algorithm (but did not do the optimizations for ...
4
votes
1answer
49 views

Test many sorting algorithms using Python and Nose

I'm trying to learn how to build a good test suite, using simple sorting as an example. Particularly, I am using Nose to generate all the tests based on a simple list of lists, where each sublist is a ...
3
votes
2answers
96 views

Correct way to cover dependencies in unit tests

My approach to unit testing feels very wrong. I feel like I am missing something very basic, and I'm looking for some insight please. Let's assume that I am testing a method (I'm using NUnit) that ...
5
votes
3answers
90 views

Cautious File Writer

I'm trying to follow the path of Sandi Metz and others who state that aiming for small and simple is good for writing understandable code. I've written a method that takes care of writing content to a ...
5
votes
2answers
320 views

Gift aid calculator task

I have recently taken a small technical test in C# and the following were expected: All stories to be completed with an appropriate level of testing. No actual database implementation is required, ...
3
votes
2answers
374 views

Read Lines From IIS Log

The purpose of this class is to read an IIS log (or multiple ones). One thing to note is that the columns can differ based on settings in IIS. So a couple of concerns that I have: Is The ILogReader ...
14
votes
3answers
2k views

Interview task - SOLID Principle and TDD

I had a small technical C# task using SOLID principle and TDD. But I failed to prove my coding skill through the test. Can anyone offer any small advice for me? I am really eager to learn what my ...
7
votes
2answers
233 views

Am I implementing BDD correctly?

I'm writing a utility that validates fields on a web site. I decided I'd give Behaviour Driven Development (BDD) a try. The validator utilises rules to determine if a value the user provided is valid. ...
3
votes
4answers
478 views

How to (really) unit test an adapter?

My question is really simple: shall an adapter (design pattern) class be unit tested, and how? Example: I want to create a class ClientSocket with PHP, which is ...
4
votes
1answer
142 views

Simple class to represent progress

Progress class was written using TDD. Interface of this class (pseudo-code): ...
2
votes
1answer
74 views

Using RSpec subject to setup a test

I find myself using subject blocks in my tests to setup example because it is succinct. However is this considered bad form and can it have undesired consequences? ...
0
votes
1answer
419 views

How to write simple code using TDD

Me and my colleagues do a small TDD-Kata practice everyday for 30 minutes. For reference this is the link for the excercise http://osherove.com/tdd-kata-1/ The objective is to write better code ...
2
votes
1answer
87 views

A C# class to check if one JSON tree (de-serialised as ExpandoObject / Array etc) contains another

I wrote this partly as a learning exercise in TDD. Could I please have feedback on both how to improve the quality of the code and the completeness of the tests? I used LinqPad as my IDE for this, ...
2
votes
1answer
137 views

General thoughts on the style of this rspec-rails test

Here's a test from a Rails app I'm working on. I want to know if I'm using describe, let, ...
1
vote
1answer
183 views
1
vote
2answers
145 views

TDD Approach and Simple Solution

How many tests could you write for the enum class below. I am looking for the following output given the following command: ...
5
votes
3answers
1k views

Maximum Sub-array Problem

I started taking a look at a programming challenge I had read about earlier today on 8thlight. Unfortunately, it seems to have been taken down and all I could remember about it was the problem posed: ...
3
votes
3answers
136 views

Test Driving Interface Design [closed]

I have been doing TDD since I have started my first job out of university (about 5 months ago), most of which is working with legacy code. I started a personal project today and thought I would TDD ...