1
vote
1answer
64 views

Question about mocking externals [duplicate]

at company we're developing quite a big project and we're arguing at the testing strategy. The question is: should all of the tests be executed in isolation of external services like database or APIs ...
3
votes
4answers
175 views

How to identify and run the most relevant automated tests?

Suppose you have a reasonably large codebase (0.5 - 1 msloc) with a large test-suite (6-7hr single-threaded runtime; with a mix of unit-tests and integration-tests built with different tools). You ...
0
votes
1answer
75 views

How to unit test models in MVC / MVR app?

I'm building a node.js web app and am trying to do so for the first time in a test driven fashion. I'm using nodeunit for testing, which I find allows me to write tests quickly and painlessly. In this ...
0
votes
1answer
120 views

Is there a name for this technique in testing? [closed]

When I've written tests for some code and want to make sure that it's actually testing what it's supposed to, I'll mess up or remove the code-under-test, and see if the tests fail. If they don't, I've ...
1
vote
4answers
161 views

Help in ensuring unit tests are meaningful

I've just written a unit test for this function, which loops through a collection of dates and sets properties equal to true or false depending on whether they're before or after a given comparison ...
3
votes
2answers
77 views

How to pick the testing values for parameterized tests for stateless functions?

When writing (parameterized) tests for stateless functions, how do I determine the most ideal set of values to test with? I'm writing a class with mathematical functions in C#, and I want to write ...
1
vote
4answers
133 views

Implementing TDD for existing code [duplicate]

I've just been learning Unit Testing and I'm trying to understand how I could incorporate it with a project with existing code. Say I wanted to write tests for a specific class in that project, but ...
4
votes
5answers
286 views

Are there any cases when one should not use Test Driven Development? [duplicate]

Is it recommended that TDD be always practiced in a project, or are there cases when it should be avoided? Should we all adopt TDD? Is it standard practice in major software companies?
0
votes
2answers
120 views

Characterization in Testing: Unit test or Functional test [duplicate]

So I'm trying to push for more automated testing in my company, which focus a lot on prototype and proof of concept systems. We currently use Google Test for unit testing. This tests specific test ...
8
votes
5answers
713 views

Why write tests for code that I will refactor?

I am refactoring a huge legacy code class. Refactoring (I presume) advocates this: write tests for the legacy class refactor the heck out of the class Problem: once I refactor the class, my ...
6
votes
3answers
397 views

Are “Stocks” a TDD/Unit testing anti pattern?

From Martin Fowler's Mocks Aren't Stubs he states that Stubs provide canned answers to calls made during the test while Mocks objects pre-programmed with expectations which form a specification of the ...
0
votes
1answer
142 views

In TDD, is it bad practice to pass a test with code that would pass more than one test? [duplicate]

When using TDD, is it bad practice to pass a newly written test with code that could also pass another test? For example, take the following test (in PHP) public function ...
29
votes
7answers
2k views

Is it sufficient to use acceptance and integration tests instead of unit test?

Short introduction to this question. I have used now TDD and lately BDD for over one year now. I use techniques like mocking to make writing my tests more efficiently. Lately I have started a ...
5
votes
1answer
168 views

Managing false positives in TDD or BDD

I'm relatively new to TDD and have been thinking a lot about how to manage the perpetually growing pool of tests that comes with it. One of my biggest concerns is about false positives. In my ...
5
votes
3answers
4k views

How to test the data access layer?

I have a DAO method that utilizes Spring for JDBC access. It calculates a seller's success rate of selling an item. Here is the code: public BigDecimal getSellingSuccessRate(long seller_id) { ...
20
votes
2answers
600 views

How do I create an environment where fixing tests is seen as a priority?

I am a software engineer at a medium sized company. We have a fairly robust testing platform running on TeamCity. It does unit tests on every checkin, and a daily unit test/BVT run. The problem is ...
0
votes
1answer
77 views

Test Doubles : Do they go in “source packages” or “test packages”?

I've got a couple of data access objects (DefaultPersonServices.class, DefaultAddressServices.class) which is responsible for various CRUD operations in a database. A few different classes use these ...
3
votes
1answer
161 views

How to deal with the notion of time in UI/Integration tests

There are some well-known techniques for dealing with the notion of time in unit tests. These allow you to write unittests that always work with a specific time so the outcome of the test is ...
0
votes
0answers
267 views

Test Driven Development vs Behavior Driven Development [duplicate]

I am a developer for 3 years and preparing to dive in TDD but then I heard about BDD and the world is talking about it. I don't know which is suitable for which time? Is BDD only applicable for ...
5
votes
3answers
1k views

Who should be responsible to write test cases? [duplicate]

Should tests in some project be written by the actual person that does the coding (usually senior in our team) or it can be done by junior coders with less experience?
2
votes
4answers
650 views

How to practice ATDD if design is not yet emerged from TDD?

Despite being very stakeholders friendly, ATDD aimed to provide a "stop" line when a feature has just been done. This avoids wasting time to add non-focused (and sometimes useless) code. That's why ...
2
votes
1answer
268 views

How do I test this?

I've attempted test first in Ruby on Rails using Test Unit and RSpec. I'm wondering how to do test first in situations that are more closely tied to the OS/filesystem. Problem: Building a USB stick ...
9
votes
5answers
922 views

Do I need unit test if I already have integration test?

If I already have integration test for my program, and they all passed, then I have a good feel that it will work. Then what are the reasons to write/add unit tests? Since I already have to write ...
6
votes
2answers
483 views

Unit test SHA256 wrapper queries

I have the following SHA256 wrapper. public static string SHA256(string plainText) { StringBuilder sb = new StringBuilder(); SHA256CryptoServiceProvider provider = new ...
3
votes
3answers
171 views

When to write tests for a new class using BDD?

I've been practicing behaviour driven development (BDD). I understand that you have to write tests that test the behaviour of the code, and this will allow the design of your code to evolve and take ...
1
vote
1answer
94 views

Production or Custom Test Data for Unit Testing?

I've recently had a little disagreement with fellow developers. We're transforming various ontologies from the original source format (Pica+, RDF, etc) into our data format and have several converters ...
3
votes
1answer
172 views

Shared context: good or bad?

RSpec allows users to share context across tests / examples, which would reduce the number of code lines in my app by a significant amount. On the other hand, somehow related to the question of ...
3
votes
1answer
118 views

Stubbing and mocking boundaries

Suppose I'm building a JSON API and would like to include an endpoint that returns a list of recently created posts. Somewhere in my system is an existing Post model with the following test: create ...
3
votes
5answers
3k 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 ...
5
votes
3answers
697 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 ...
4
votes
2answers
310 views

Can I start with a passing unit test?

Uncle Bob's rules for TDD are specified here. 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 ...
17
votes
4answers
2k views

Why is test driven development missing from Joel's Test?

I was reading this blog by Joel Spolsky about 12 steps to better code. The absence of Test Driven Development really surprised me. So I want to throw the question to the Gurus. Is TDD not really worth ...
2
votes
2answers
571 views

Functional testing and Acceptance testing leading to redundant code

What I know is: A Functional test aims to test a single component (like a WebApp's Controller) from the point of view of the developer. => Did I achieve all the requirements to make it work well? ...
6
votes
2answers
1k 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 ...
26
votes
5answers
3k views

Why is it often said that the test cases need to be made before we start coding? [duplicate]

Why is it often said that the test cases need to be made before we start coding? What are its pros and what the cons if we don't listen to this advice? Moreover, does that advice refer to black box ...
-2
votes
2answers
472 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 ...
21
votes
5answers
2k views

Do unit tests sometimes break encapsulation? [duplicate]

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 ...
3
votes
1answer
1k 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 ...
2
votes
3answers
567 views

TDD, BDD or both? [duplicate]

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 ...
10
votes
5answers
487 views

Methods for testing a very large application

I have a PHP app which is very large. There are usually 2-3 developers working on it full time and we are getting to the point where we are making changes and creating bugs (cough features!). The ...
11
votes
5answers
2k 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 ...
5
votes
4answers
295 views

Testing To Prevent Cascading Bugs

Yesterday, Twitter was hit with a "Cascading Bug" as described in this blog post: A “cascading bug” is a bug with an effect that isn’t confined to a particular software element, but rather its ...
16
votes
9answers
1k views

Are too many assertions code smell?

I've really fallen in love with unit testing and TDD - I am test infected. However, unit testing is normally used for public methods. Sometimes though I do have to test some assumptions-assertions ...
3
votes
4answers
486 views

Should you exercise TDD on prototype applications?

I'm developing an iOS app, which is a prototype for a customer. They're expecting it to not be of production standard and are happy for a few rough edges here and there. Since this is my first ...
6
votes
2answers
832 views

Test Driven Development, has it reduced stress for developers?

I understand the benefits of test driven development, but have there been any studies that reveal the level of satisfaction with the product or stress levels of the authoring developers with the ...
18
votes
4answers
773 views

Should we always unit test bugs when correcting them?

When correcting bugs, it is encouraged where I work to first write a test that fails with the given bug, and then to fix the code until the test passes. This follows TDD practices, and is supposed to ...
66
votes
16answers
9k views

When is unit testing inappropriate or unnecessary? [duplicate]

It seems to be generally assumed (on Stack Overflow at least) that there should always be unit tests, and they should be kept up to date. But I suspect the programmers making these assertions ...
41
votes
6answers
6k views

How to deal with static utility classes when designing for testability

We are trying to design our system to be testable and in most parts developed using TDD. Currently we are trying to solve the following problem: In various places it is necessary for us to use static ...
36
votes
14answers
2k views

If you had two projects with the same specification and only one was developed using TDD how could you tell?

I was asked this question in an interview and it has been bugging me ever since. You have two projects, both with the same specification but only one of these projects was developed using Test ...
27
votes
11answers
2k views

Do I need to test everything?

I'm going to start my first real project in Ruby on Rails, and I'm forcing myself to write TDD tests. I don't see real advantages in writing tests, but since it seems very important, I'll try. Is it ...