0
votes
1answer
59 views

testing: which code layers should I aim to test?

Say I have this code: Design { public function load() { $this->loadProduct(); $this->loadService(); ... } public function loadProduct() { ...
56
votes
9answers
3k views

Does it make sense to write tests for legacy code when there is no time for a complete refactoring?

I usually try to follow the advice of the book Working Effectively with Legacy Code, so I break dependencies, move parts of the code to @VisibleForTesting public static methods and new classes to make ...
0
votes
1answer
113 views

unit level testing, agile, and refactoring [duplicate]

I'm working on a very agile development system, a small number of people with my doing the vast majority of progaming myself. I've gotten to the testing phase and find myself writing mostly ...
19
votes
3answers
1k views

Difficulties With TDD & Refactoring (Or - Why Is This More Painful Than It Should Be?)

I wanted to teach myself to use the TDD approach and I had a project I had been wanting to work on for a while. It wasn't a large project so I thought it would be a good candidate for TDD. However, I ...
57
votes
11answers
6k views

Is it a bad practice to modify code strictly for testing purposes

I have a debate with a programmer colleague about whether it is a good or bad practice to modify a working piece of code only to make it testable (via unit tests for example). My opinion is that it ...
8
votes
3answers
520 views

What would help when refactoring a large method to ensure that I don't break anything?

I'm currently refactoring a part of a large codebase with no unit tests whatsoever. I tried to refactor code the brute way, i.e. by trying to guess what the code is doing and what changes wouldn't ...
5
votes
2answers
213 views

How to do unit tests on a method that takes the elapsed time into account?

I'm currently in the middle of refactoring an important method in a legacy-system. There were almost zero test until I've started working on it, and I've added quite a lot to ensure the correct work ...
4
votes
4answers
171 views

How to implement isValid correctly?

I'm trying to provide a mechanism for validating my object like this: class SomeObject { private $_inputString; private $_errors=array(); public function __construct($inputString) { ...
0
votes
3answers
370 views

Introduce unit testing when codebase is already available [duplicate]

Possible Duplicate: Best practices for retrofitting legacy code with automated tests I've been working on a project in Flex for three years now without unit testing. The simple reason for ...
9
votes
4answers
649 views

How to unit test a function that is refactored to strategy pattern?

If I have a function in my code that goes like: class Employee{ public string calculateTax(string name, int salary) { switch (name) { case "Chris": ...
4
votes
1answer
568 views

How to unit test large legacy systems? [duplicate]

Possible Duplicate: Best practices for retrofitting legacy code with automated tests When working in large legacy systems (large systems with no unit testing ever) I often come across ...
17
votes
7answers
647 views

What can you do about the quality of existing integration and unit tests while being the new guy in a team ?

A recurring theme that I came across in my career is being the new developer to arrive in a team, and quickly having an inherent distrust of the existing unit and integration test suites. During the ...
11
votes
2answers
689 views

Adding unit tests to a legacy, plain C project

The title says it all. My company is reusing a legacy firmware project for a microcontroller device, written completely in plain C. There are parts which are obviously wrong and need changing, and ...
7
votes
1answer
646 views

Looking for statistics on automated testing, continuous integration and refactoring usage

Are there any credible sources of information on the adoption of agile techniques like automated testing, continuous integration and refactoring? Of those that are using unit testing, how many ...
24
votes
12answers
1k views

Colleague unwilling to use unit tests “as it's more to code”

A colleague is unwilling to use unit tests and instead opting for a quick test, pass it to the users, and if all is well it is published live. Needless to say some bugs do get through. I mentioned ...