Tagged Questions
1
vote
2answers
261 views
Fundamental TDD: stuck with writing a test so I can write code that I want
I have a Season class. This Season has a few properties: among them, a list of Games. This should be populated from the same source that populated the rest of the Season properties.
I have a test ...
2
votes
1answer
87 views
Shared factories: good or bad?
RSpec allows users to share factories across tests / examples, which would reduce the number of code lines in my app by a significant amount.
On the other hand, one of the reasons why I'm using ...
-2
votes
1answer
153 views
Do you unit-test your PODs? [closed]
do you create unit-tests for PODs (Plain Old Data Structure)? And why?
I'm interested in your opinions.
Regards
Tobias
1
vote
2answers
121 views
How do you test database abstraction in PHP?
I apologise in advance if this question is too subjective but I'm struggling to find a good answer, probably as there is not really a correct answer to give.
I'm currently writing a database ...
1
vote
1answer
125 views
Why do we write our specs in different files from our source?
The D Programming Language supports writing unit tests inline with source. There's a Ruby gem called test_inline that lets you write specs in the same file as your code.
Why is it generally ...
2
votes
5answers
364 views
Understanding unit tests/TDD for ASP.NET webforms [closed]
I'm the lead programmer at a small software firm (currently 4 developers including myself), we develop bespoke ASP.NET WebForms applications for businesses. I joined there in 2010 just after ...
4
votes
3answers
320 views
In TDD, if I write a test case that passes without modifying production code, what does that mean?
These are Robert C. Martin's rules for TDD:
You are not allowed to write any production code unless it is to
make a failing unit test pass.
You are not allowed to write any more
of a unit test than ...
0
votes
2answers
203 views
Should I use TDD and BDD if my project is changing fast?
I have my own little project I am creating using RoR, I plan it to have small-medium load.
With no doubt I started with BDD and TDD (Cucumber and RSpec to be exact, but I am also experienced with ...
4
votes
1answer
141 views
Is there a modern replacement for a mutation testing tool like Jester for Java?
“Why just think your tests are good when you can know for sure?
Sometimes Jester tells me my tests are airtight, but sometimes the
changes it finds come as a bolt out of the blue. Highly ...
3
votes
2answers
180 views
Do I need to learn python first to understand the part 2 of the book Test Driven development?
It seems like Python is used as a coding language for part 2 of Kent Beck's book Test Driven Development. I have read the first part of that book and started appreciating the value of TDD . First part ...
8
votes
1answer
274 views
Unit testing on visualization (3D graphics) frameworks
This is a follow up to this question. There I was asking how to do unit testing when you have a library of scientific algorithms. I have a similar problem now but with a different project.
I'm ...
11
votes
1answer
743 views
Should I write a test to prove that deleting code fixes a bug?
Occasionally I'll run into the situation where fixing a bug requires that I delete a section of code. The TDD purist would (I assume) advocate writing a failing test, deleting the code, then watching ...
8
votes
1answer
131 views
Should I refactor my unit tests when I extract a class out of the System Under Test?
I wrote this class that does a few things (perhaps this is a violation of the Single Responsibility Principle). I realize now that some other part of the project needs a piece of that logic and the ...
5
votes
2answers
254 views
Helper static methods in TDD
I am creating an application which will be testable(unit + integration). In this application I have a FileHelper static class,
public static class FileHelper
{
public static void ...
5
votes
2answers
305 views
Write tests for unit tests in TDD?
In an answer to another question, I suggested creating a randomized value for input to a specific method. In my experience this has been useful for making tests more readable and it lets you skip the ...
125
votes
23answers
6k views
Why does automated testing keep failing in my company?
We have tried to introduce developer automated testing several times at my company. Our QA team uses Selenium to automate UI tests, but I always wanted to introduce unit tests and integration tests. ...
26
votes
6answers
2k views
How should you TDD a Yahtzee game?
Let's say you're writing a Yahtzee game TDD style. You want to test the part of the code that determines whether or not a set of five die rolls is a full house. As far as I know, when doing TDD, you ...
2
votes
3answers
163 views
Test driven development when implementing a flexible length list
According to the commonly used TDD strategy, to implement something, you write a test that fail the code first, write the simplest code, refactor, and then repeat. I am trying to imagine this scenario ...
5
votes
2answers
204 views
Unit Test Friendly Domain Driven Design
Many of the readings I've done on DDD, both in books and online, seem to represent code that, often times, is difficult or impossible to unit test. For example, there are numerous samples with static ...
25
votes
11answers
2k views
How do we make unit tests run fast?
We have reached the point in our project where we have almost a thousand tests and people have stopped bothering with running them before doing a check in because it takes so long. At best they run ...
5
votes
3answers
362 views
How much to test in TDD?
I am newbie to TDD (writing first project following TDD practices).
I have fairly basic interface IProfiler and an implementation Profiler.
interface IProfiler
{
bool IsBusy {get;}
long Elapsed ...
10
votes
2answers
180 views
How would type errors be detected while creating mocks in a dynamic language?
The problem occurs while doing TDD. After a couple of test pass, the return types of some class/module change. In a statically typed programming language, if a previous mocked object was used in the ...
3
votes
1answer
254 views
TDD and test automation in applications heavily dependent on databases and user input [closed]
Recently I have been reading online about eXtreme programming and agile practices. I wish to adapt them. However most of my code is all in PHP which is the normal CRUD type web applications. Moreover ...
2
votes
2answers
129 views
Unit test and Code Coverage of Ant build scripts
In our development environment We have more and more build scripts for ant to perform the build tasks for several different build jobs.
These build scripts sometimes become large and do a lot of ...
7
votes
5answers
393 views
How to TDD test that objects are being added to a collection if the collection is private?
Assume that I planned to write a class that worked something like this:
public class GameCharacter {
private Collection<CharacterEffect> _collection;
public void Add(CharacterEffect e) ...
-2
votes
2answers
193 views
How can I test database access methods in Java? [closed]
I want to write a test for a method that accesses a database such as following.
public class MyClass{
public String getAddress(Int id){
String query = "Select * from Address where ...
3
votes
3answers
265 views
What if I can't make my unit test fail in “Red, Green, Refactor” of TDD?
So let's say that I have a test:
@Test
public void MoveY_MoveZero_DoesNotMove() {
Point p = new Point(50.0, 50.0);
p.MoveY(0.0);
Assert.assertAreEqual(50.0, p.Y);
}
This test then ...
6
votes
3answers
279 views
What to do when TDD tests reveal new functionality that is needed that also needs tests?
What do you do when you are writing a test and you get to the point where you need to make the test pass and you realize that you need an additional piece of functionality that should be separated ...
4
votes
1answer
283 views
Is wrapping a third party code the only solution to unit test its consumers?
I'm doing unit testing and in one of my classes I need to send a mail from one of the methods, so using constructor injection I inject an instance of Zend_Mail class which is in Zend framework.
Now ...
5
votes
4answers
278 views
Are injectable classes allowed to have constructor parameters in DI?
Given the following code:
class ClientClass{
public function print(){
//some code to calculate $inputString
$parser= new Parser($inputString);
$result= ...
17
votes
4answers
748 views
Do unit tests sometimes break encapsulation?
I very often hear the following: "If you want to test private methods, you'd better put that in another class and expose it."
While sometimes that's the case and we have a hiding concept inside our ...
2
votes
2answers
186 views
Returning a mock object from a mock object
I'm trying to return an object when mocking a parser class. This is the test code using PHPUnit 3.7
//set up the result object that I want to be returned from the call to parse method
...
4
votes
4answers
146 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) {
...
3
votes
5answers
488 views
“TDD is about design, not verification”; concretely, what does that mean?
I've been wondering about this. What do we exactly mean by design and verification.
Should I just apply TDD to make sure my code is SOLID and not check if it's external behaviour is correct?
Should ...
0
votes
1answer
257 views
GUI Test Runner for Boost.Test
Does a Boost.Test have a GUI version of a test runner? The closest thing what I found is a Boost.Adapter for Galio (https://github.com/ndl/Gallio.BoostAdapter), but as that project been dead for two ...
0
votes
3answers
250 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 ...
2
votes
1answer
445 views
How to unit test image processing code?
I'm working in image processing (mainly OCR) and I wonder how I should integrate unit tests in my development.
I'm already using unit tests for more "common" type of code but when dealing with image ...
14
votes
4answers
773 views
TDD - Outside In vs Inside Out
What is the difference between building an application Outside In vs building it Inside Out using TDD?
These are the books I read about TDD and unit testing:
Test Driven Development: By Example
...
8
votes
4answers
564 views
Unit testing and Test Driven Development questions
I'm working on an ASP.NET MVC website which performs relatively complex calculations as one of its functions.
This functionality was developed some time ago (before I started working on the ...
0
votes
3answers
277 views
What's wrong performing unit test against concrete implementation if your frameworks are not going to change?
First a bit of background: We are re-architecting our product suite that was written 10 years ago and served its purpose. One thing that we cannot change is the database schema as we have 500+ client ...
1
vote
3answers
403 views
TDD, BDD or both?
I'm a little bit confused about BDD. I'm doing TDD currently.
My question is whether BDD is complementary to TDD or it's a whole new thing and my team should do both TDD and BDD? Or is it enough to ...
3
votes
3answers
405 views
How do I make code bound to an ORM testable?
In Test Driven Development, how do I make code bound to an ORM testable?
I am using a Micro-ORM (PetaPoco) and I have several methods that interact with the database like:
AddCustomer
UpdateRecord
...
1
vote
2answers
225 views
Any pre-rolled System.IO abstraction libraries out there for Unit Testing?
To test methods that use the file system we need to basically put System.IO behind a set of interfaces that we can then mock, I do this with a DiskIO class and interface.
As my DiskIO code gets ...
9
votes
4answers
417 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":
...
7
votes
1answer
195 views
Who should initialize dependencies in a TDD application?
I'm trying to learn implementing TDD with mocking/fake objects. One of the questions I have is how to initialize a dependency in an application which implements TDD? An example from this article
...
7
votes
5answers
489 views
Is it typical for a unit test suite to be larger than the code it tests? [duplicate]
Possible Duplicate:
What is a normal “functional lines of code” to “test lines of code” ratio?
I've found that more often than not, when you write lots of unit ...
5
votes
6answers
385 views
Sporadic unittests or TDD?
I've read some basics about unit tests and TDD, but I find it hard to convince myself why TDD can have an advantage over only selected unittests.
I've read common arguments for TDD, but don't see the ...
11
votes
3answers
1k views
Unit testing C++: What to test?
TL;DR
Writing good, useful tests is hard, and has a high cost in C++. Can you experienced developers share your rationale on what and when to test?
Long story
I used to do test-driven development, ...
8
votes
5answers
742 views
What is a normal “functional lines of code” to “test lines of code” ratio?
I'm pretty new to TDD approach and my first experiments say that writing 1 line of functional code means writing about 2-3 lines of testing code. So, in case I'm going to write 1000 LOC, the whole ...
17
votes
4answers
768 views
Implementing unit testing at a company that doesn't do it
My company's head of software development just "resigned" (i.e. fired) and we are now looking into improving the development practices at our company. We want to implement unit testing in all ...