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)

10
votes
1answer
725 views

Have unit test generators helped you when working with legacy code?

I am looking at a small (~70kLOC including generated) C# (.NET 4.0, some Silverlight) code-base that has very low test coverage. The code itself works in that it has passed user acceptance testing, ...
8
votes
4answers
716 views

A new name for unit tests [closed]

I never used to like unit testing. I always thought it increased the amount of work I had to do. Turns out, that's only true in terms of the actual number of lines of code you write and furthermore, ...
10
votes
3answers
2k views

How does NUnit for C# compare with Unit Test facility integrated with Visual Studio

I need to work in a team to develop a mid scale Desktop application developed using C# .NET. Prior to this, I have not applied Unit Testing and Test Driven Development. I am aware that there exists ...
3
votes
5answers
1k views

Do you test your SQL/HQL/Criteria?

Do you test your SQL or SQL generated by your database framework? There are frameworks like DbUnit that allow you to create real in-memory database and execute real SQL. But its very hard to use(not ...
6
votes
1answer
460 views

Dependency injection: what belongs in the constructor?

I'm evaluating my current PHP practices in an effort to write more testable code. Generally speaking, I'm fishing for opinions on what types of actions belong in the constructor. Should I limit things ...
10
votes
2answers
2k views

design pattern for unit testing? [duplicate]

I am beginner in developing test cases, and want to follow good patterns for developing test cases rather than following some person or company's specific ideas. Some people don't make test cases and ...
9
votes
2answers
1k views

What is an “assertion framework”?

I was reading about the js-test-driver unit-testing framework, when I found out that the guys behind the framework intend it to be integrated with an assertion framework. What is an assertion ...
2
votes
4answers
4k views

Can I test effectively javascript functions with a PHP unit-testing framework?

If I want to unit-test some of my javascript functions, would it be more efficient (and doable) to use the already installed PHP unit-testing framework, or should I use a javascript unit-testing ...
10
votes
2answers
2k views

How do you unit test Application and UI code?

I love writing unit tests and agree they are an excellent way to test code, prevent regressions, etc. However, I find myself unable to write them much as the vast majority of the code I work on day-in ...
11
votes
2answers
6k views

RSpec vs Test::Unit in Rails

I've never been really convinced of the advantages that you get by switching over to RSpec from Test::Unit in Ruby on Rails (despite reading from time to time about RSpec). What is it about RSpec ...
14
votes
6answers
577 views

Writing Unit Tests in the Middle

Is unit testing a 100% or not at all kind of deal? I was browsing through my old projects and started adding features, this time with unit testing. However, is this ultimately worthless if I'm going ...
-1
votes
7answers
451 views

What percent of your college course work is unit-tested code? [closed]

As a college student do you write unit-test for the project code you write? Do you know how to properly use TDD? Have you been taught to use testing frameworks (jUnit for example)? I've just ...
6
votes
3answers
600 views

Should a unit/integration test that may result in an infinite loop have a clear assertion?

Unit: A multithreaded unit reads data of a queue and processes it, sending it off to another queue. When the last item is processed (null value found) the process stops. Test: Place a set of known ...
10
votes
6answers
2k views

Do you really have to do BDD/TDD in a test first manner?

Even though I haven't been in a TDD or BDD project, or I have been in some that say they are doing TDD but are pretty far from it, these are things that I think about and really try to read as much as ...
30
votes
11answers
3k views

Writing the minimum code to pass a unit test - without cheating!

When doing TDD and writing a unit test, how does one resist the urge to "cheat" when writing the first iteration of "implementation" code that you're testing? For example: Let's I need to calculate ...
46
votes
9answers
13k views

How to write “good” unit tests?

Triggered by this thread, I (again) am thinking about finally using unit tests in my projects. A few posters there say something like "Tests are cool, if they are good tests". My question now: What ...
35
votes
3answers
5k views

Are asserts or unit tests more important?

Both asserts and unit tests serve as documentation for a codebase, and a means of discovering bugs. The main differences are that asserts function as sanity checks and see real inputs, whereas unit ...
10
votes
3answers
949 views

Is it a good idea to do TDD on low level components?

I'm considering writing a low level driver or OS components/kernels. The osdev.org folks seem to think that the important bits are not meaningfully testable this way, but I have read some discussions ...
11
votes
4answers
712 views

Unit testing internal components

To what extent do you unit test internal/private components of a class/module/package/etc? Do you test them at all or do you just test the interface to the outside world? An example of these internal ...
17
votes
7answers
5k views

Unit test coding standards

Usually when talking about coding standards we refer to the code of the program itself, but what about the unit tests? Are there certain coding standards guidelines that are unique to unit tests? What ...
10
votes
1answer
992 views

How would I unit test database logic?

I am still having a issue getting over a small issue when it comes to TDD. I need a method that will get a certain record set of filtered data from the data layer (linq2SQL). Please note that i am ...
5
votes
2answers
718 views

Good example of a properly unit tested PHP project? [closed]

In hopes of getting myself and my coworkers to adopt automated unit testing methods in future projects, I would like to see a proper example on how it's done. Simple introductionary lessons to unit ...
7
votes
3answers
2k views

What is the best practice for refactoring a static method in order to make it more testable?

Let's say you have a static method that looks something like this: public static bool Foo() { var bar = new Bar(); //do some stuff here } This method as it stands can be a real headache to ...
10
votes
3answers
211 views

Unit tests, write them before or after the framework? [closed]

This is my first question here, so i'll make it short and to the point. When Writing unit tests, should you write them before or after you have made the underlying framework for them? This came up in ...
26
votes
5answers
4k views

I want to start using TDD. Any tips for a beginner? [closed]

I never used an automated test mechanism in any of my projects and I feel I'm missing a lot. I want to improve myself, so I have to start tackling some issues I've been neglecting like this and trying ...
42
votes
9answers
1k views

How to test the tests?

We test our code to make it more correct (actually, less likely to be incorrect). However, the tests are also code -- they can also contain errors. And if your tests are buggy, they hardly make your ...
3
votes
2answers
293 views

Is testing the easiest way to contribute to an Open Source Project?

I want to contribute to an open source project, but I don't know much about unit testing. I want to learn how to test and then practice my skills on an open source. Will this also be acknowledged as ...
31
votes
7answers
2k views

Unit testing newbie team needs to unit test

I'm working with a new team that has historically not done ANY unit testing. My goal is for the team to eventually employ TDD (Test Driven Development) as their natural process. But since TDD is ...
21
votes
7answers
8k views

Best book, articles and literature on unit testing [closed]

In my battle to introduce unit testing in my workgroup, I find a lot of people that have little to none knowledge of the concept. Can you suggest: best articles or tutorials for quickly introducing ...
15
votes
7answers
891 views

How can I advocate unit testing on private code?

I'm trying to advocate unit testing in my workgroup, but an objection I often get is that it should be used only for externally exported API (which is only a minimal and non critical part of our ...
28
votes
8answers
6k views

How do I unit test multi-threaded code? [duplicate]

Are there ways to unit test your multi-threaded code for race conditions and deadlocks? To see if they are performing the way they should be...
189
votes
13answers
93k views

Is it OK to have multiple asserts in a single unit test?

In the comment to this great post, Roy Osherove mentioned the OAPT project that is designed to run each assert in a single test. The following is written on the project's home page: Proper unit ...
7
votes
6answers
3k views

What unit test frameworks exist for Java?

I've used TestNG and JUnit. What other frameworks are out there? What makes them special and/or different from the rest?
8
votes
3answers
17k views

What does Software Engineer in Test do? [closed]

Normally unit tests were written by developer who write the code, i.e. Test Driven Development. So what does Software Engineer in Test do?
59
votes
11answers
34k views

Is static universally “evil” for unit testing and if so why does resharper recommend it? [closed]

I have found that there are only 3 ways to unit test (mock/stub) dependencies that are static in C#.NET: Moles TypeMock JustMock Given that two of these are not free and one has not hit release 1....
18
votes
1answer
10k views

How to set up Unit Testing in Visual Studio 2010? [closed]

I'm doing my first big project and I don't have a lot of experience in a professional programming environment. While researching anything programming-related I often see references to Unit Testing, ...
23
votes
16answers
7k views

Who does test-driven development?

I've been working in the enterprise space for the past 4½ years and have noticed that generally speaking, enterprises are not conducive environments for the test-first style of development. Projects ...
16
votes
8answers
878 views

How have you made unit testing more enjoyable?

If you've always loved unit testing, good for you! But for the unfortunate ones who weren't born with a liking for it, how have you managed to make this task more enjoyable ? This is not a "what is ...
29
votes
12answers
7k views

How much Code Coverage is “enough”?

We are starting a push for code coverage here at my work, and it has got me to thinking.... How much code coverage is enough? When do you get to the point of diminishing returns on code coverage? ...
58
votes
7answers
12k views

What should you test with unit tests?

I'm freshly out of college, and starting university somewhere next week. We've seen unit tests, but we kinda not used them much; and everyone talks about them, so I figured maybe I should do some. ...
30
votes
5answers
2k views

Test driven development - convince me! [closed]

I know some people are massive proponents of test driven development. I have used unit tests in the past, but only to test operations that can be tested easily or which I believe will quite possibly ...