Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

learn more… | top users | synonyms (1)

1
vote
1answer
317 views

Looking for resources on TDD and BDD [closed]

I'm doing a presentation this week for Uni on the application of TDD and BDD. I'm trying to focus on types of code (such as algorithms, business logic or crud) and which methodology (if at any at all) ...
13
votes
4answers
2k views

How can I properly compare double values for equality in a unit test?

I recently designed a time series module where my time series is essentially a SortedDictionnary<DateTime, double>. Now I would like to create unit tests to make sure that this module is always ...
18
votes
5answers
8k views

What's the best way to build a factory using NInject?

I am pretty comfortable with dependency injection using NInject in MVC3. While working in an MVC3 application, I developed a custom Controller Creation Factory using NInject, so any controller that is ...
9
votes
5answers
594 views

Writing Testable Code vs Avoiding Speculative Generality

I was reading some blog posts this morning, and stumbled across this one: If the only class that ever implements the Customer interface is CustomerImpl, you don't really have polymorphism and ...
3
votes
3answers
832 views

Unit/Integration Testing my DAL

So I've done some research on this but I couldn't quite come to a conclusion, so I figured I'd ask you guys to see if I could get some other opinions. All of my database access is currently done ...
32
votes
13answers
3k views

Unit-testing of inherently random/non-deterministic algorithms

My current project, succinctly, involves the creation of "constrainably-random events". I'm basically generating a schedule of inspections. Some of them are based on strict schedule constraints; you ...
0
votes
3answers
524 views

Testing an IRC Bot [closed]

I'm using Autumn gem to create a Ruby IRC bot for a game. However, it makes me feel rather embarrassed because I don't know how to test this kind of program... I think I should mock the IO process to ...
6
votes
2answers
2k views

Is there a unit testing framework for HTML markup? [closed]

I work at a web design shop. Our workflow is divided into two parts: frontend programmers make static html and css templates of the site design, then backend programmers tie the templates into a CMS. ...
1
vote
2answers
269 views

Is it a good idea to use an unit test framework for another purpose than test code?

I'm about to write a simple script to test a dataset for certain conditions. I was designing it as a set of functions each one describing the condition to be tested and pass them to the test engine: ...
8
votes
2answers
342 views

What should I be looking for when evaluating unit testing libraries and tools?

I'm in the process of choosing new unit testing tools for soon to be started project. There are plenty of them! The basic requirements I have would be that it can run tests on at least Windows and ...
340
votes
12answers
11k views

Should I intentionally break the build when a bug is found in production?

It seems reasonable to me that if a serious bug is found in production by end-users, a failing unit test should be added to cover that bug, thus intentionally breaking the build until the bug is ...
19
votes
9answers
2k views

Should we test all our methods?

So today I had a talk with my teammate about unit testing. The whole thing started when he asked me "hey, where are the tests for that class, I see only one?". The whole class was a manager (or a ...
3
votes
3answers
252 views

Is the MIT license suitable for an open source library that is only used in unit testing scenarios?

Some time ago I developed a small project for use in unit testing scenario's and published it on Codeplex. Back then I choose the GPL license but I didn't really understand it. Today I changed it to ...
8
votes
9answers
2k views

Should I pass an object into a constructor, or instantiate in class?

Consider these two examples: Passing an object to a constructor class ExampleA { private $config; public function __construct($config) { $this->config = $config; } } $config = new ...
9
votes
4answers
253 views

Is it a good idea to measure the performance of a method by using unit test timeout?

In a project where there are non-functional requirements which specify the maximum execution time for a specific action, QA must check the performance of this action on a dedicated machine using ...
10
votes
3answers
386 views

What is the relevance of Unit Testing in an “Release early release often” environment?

Over last one year or so, I have driven my team towards the release-early-release-often mode of development (AKA: Rapid Application Development, not Agile). For more information about the manner in ...
5
votes
2answers
2k views

Write Unit test for heavily-database application? [duplicate]

I'm currently developing a Spring-based web-application, in which almost every operation create/update/delete something in the database. The logic mostly about checking condition so as to we should ...
3
votes
2answers
816 views

Never written much unit tests, how can I practice more of it?

I have an interview coming up soon next week and there's a few things on their list of responsibilties for this software development job (the job position title is vague, it says java developer) that ...
37
votes
6answers
2k views

Should unit tests be stored in the repository?

I'm a growing programmer who's finally putting unit testing into practice for a library that I'm storing on GitHub. It occurred to me that I might include the test suites in the repo, but as I look ...
8
votes
1answer
515 views

I've unit tested my class, now how do I get started with an integration test?

I've written a class that manages recipients on a MailChimp list, called MailChimpRecipient. It uses the MCAPI class, which is an third-party API wrapper. http://apidocs.mailchimp.com/api/1.3/ ...
25
votes
11answers
1k views

Unit testing methods with indeterminate output

I have a class that is meant to generate a random password of a length that's also random, but limited to be between a defined min and max length. I'm constructing unit tests, and ran into an ...
20
votes
12answers
3k views

How does unit testing work?

I am trying to make my code more robust and I have been reading about unit testing, but I find it very hard to find an actual useful use. For instance, the Wikipedia example: public class TestAdder { ...
5
votes
4answers
524 views

How to Write Unit Tests When One Fix Will Make Many Failing Tests Pass?

I have two test cases to test a fix to code that is using the wrong criteria for selecting objects from a collection: Given one object in the collection matching the bad criteria, ensure that no ...
12
votes
5answers
3k views

Should unit test expected results be hardcoded?

Should the expected results of a unit test be hardcoded, or can they be dependant on initialised variables? Do hardcoded or calculated results increase the risk of introducing errors in the unit ...
10
votes
5answers
2k views

Would you rather make private stuff internal/public for tests, or use some kind of hack like PrivateObject?

I am quite a beginner in code testing, and was an assert whore before. One thing worrying me in unit testing is that is often requires you to make public (or at least internal) fields that would have ...
7
votes
8answers
1k views

Advantages and disadvantages to making common unit test scaffolding code

For the project my team and me are working on we often find that we need large pieces of scaffolding code. Creating domain objects with correct values, setting up mocks for repositories, dealing with ...
5
votes
4answers
927 views

Ease the pains of unit testing C# when you are the only person on the team unit testing

I have ran into this a few times where you get put on a project and you want to do unit testing of some type, but the project isn't setup right to allow for this and you might not have buy-in from ...
1
vote
2answers
724 views

A good code coverage framework for groovy/java?

Currently, I am working on a very complex product. Unit testing is something unknown to this product till date. Hence the code base is too complex to keep it compatible with unit tests. I am supposed ...
9
votes
6answers
2k views

Single or multiple files for unit testing a single class?

In researching unit testing best practices to help put together guidelines for my organization, I've run into the question of whether it is better or useful to separate test fixtures (test classes) or ...
3
votes
3answers
125 views

migrating product and team from startup race to quality development [duplicate]

Possible Duplicate: A simple ways to improve the release quality in RAD environment This is year 3 and product is selling good enough. Now we need to enforce good software development ...
13
votes
4answers
913 views

Unit testing statically typed functional code

I wanted to ask you people, in which cases it makes sense to unit test statically typed functional code, as written in haskell, scala, ocaml, nemerle, f# or haXe (the last is what I am really ...
14
votes
5answers
491 views

Unit testing - getting started

I am just getting started with unit testing but I am not sure if I really understand the point of it all. I read tutorials and books on it all, but I just have two quick questions: I thought the ...
9
votes
4answers
518 views

Are there any language agnostic unit testing frameworks?

I have always been skeptical of rewriting working code - porting code is no exception to this. However, with the advent of TDD and automated testing it is much more reasonable to rewrite and refactor ...
2
votes
2answers
492 views

How to populate a private container for unit test?

I have a class that defines a private (well, __container to be exact since it is python) container. I am using the information within said container as part of the logic of what the class does and ...
8
votes
3answers
703 views

What should be tested in Javascript?

At work, we've just started on a heavily Javascript based application (actually using Coffeescript, but still), of which I've been implementing an automated test system using JsTestDriver and fabric. ...
18
votes
5answers
657 views

Does unit testing lead to premature generalization (specifically in the context of C++)?

Preliminary notes I'll not go into the distinction of the different kinds of test there are, there are already a few questions on these sites regarding that. I'll take what's there and that says: ...
3
votes
2answers
146 views

Should service test classes connect to the database [duplicate]

I want to know if the service test classes should use real DAO objects and connect to the database or it should use mock objects to test only the business logic it do?
3
votes
1answer
91 views

How to deal with changes that need further testing while working on another test?

TDD means to test before you start writing production code. So I start writing a test for MyClass called MyClassTest. It fails and I start to implement the wanted functionality in MyClass. During the ...
0
votes
1answer
569 views

Unit testing external dependencies

When writing a program, should I write tests that ensure that the dependencies I use are working? Those might help to check my assumptions about them, and may also help when deciding to upgrade said ...
7
votes
3answers
702 views

What elements of my JUnits should I mock?

My classes are following this structure Service Tier (creates and maps InputDTO to DB Data) -> DAO Tier (actually executes DB calls) When I write the service tier JUnits, and when it calls DAO ...
1
vote
4answers
337 views

How can I convince my colleague to unit test his code? [duplicate]

Possible Duplicate: Colleague unwilling to use unit tests “as it's more to code” I've been trying in the last couple of months to convince one of my colleagues to start unit ...
9
votes
8answers
393 views

Does it make sense to license unit tests?

I am wondering if there are any benefits / risks of (not) putting a licence on test code which mostly consists of unit tests. What do you think? I am particularly interested in licensing under ...
12
votes
1answer
277 views

Are there any studies on the relationship between software testing practices and developer productivity? [closed]

Are there any studies on the relationship between software testing practices (unit and/or integration tests) and developer productivity?
8
votes
3answers
434 views

How do you structure unit tests for multiple objects that exhibit the same behavior?

In a lot of cases I might have an existing class with some behavior: class Lion { public void Eat(Herbivore herbivore) { ... } } ...and I have a unit test... [TestMethod] public void ...
3
votes
1answer
775 views

What is an inconsistent state?

I've been trying to experiment with coded user interface testing (CUITS) lately and I get the following error whenever I try to create one. The following package failed to load: C:\Users[File Path ...
37
votes
11answers
9k views

What are the disadvantages of automated testing?

There are a number of questions on this site that give plenty of information about the benefits that can be gained from automated testing. But I didn't see anything that represented the other side of ...
7
votes
7answers
4k views

Is is possible to unit test a web forms site

Is is possible (and sensible) to unit test a web forms site? It seems to me that as so much of it depends on state and user input it wouldn't be fesable. If it's not feasible is there a valid ...
6
votes
4answers
1k views

Why use phpunit when traditional manual testing can be used

When I make a web app I test my work on the browser to see if I receive any errors and fix them. I have made complex applications and testing this way has been easy and fast. I have watched many ...
10
votes
5answers
890 views

When you should and should not use the 'new' keyword?

I watched a Google Tech Talk presentation on Unit Testing, given by Misko Hevery, and he said to avoid using the new keyword in business logic code. I wrote a program, and I did end up using the new ...
18
votes
6answers
780 views

Does adding unit tests make sense for well-known legacy code?

I'm talking about unit tests in the TDD sense. (Not automated "integration", or what you like to call it tests.) Legacy code as in: (C++) code without tests. (see: Michael Feathers' Working ...