Skip to main content

Questions tagged [unit-testing]

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

Filter by
Sorted by
Tagged with
11 votes
6 answers

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 ...
Tomas Jansson's user avatar
38 votes
13 answers

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 ...
CraigTP's user avatar
  • 1,564
62 votes
9 answers

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 ...
Jens's user avatar
  • 729
57 votes
3 answers

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 ...
dsimcha's user avatar
  • 17.2k
12 votes
3 answers

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 folks seem to think that the important bits are not meaningfully testable this way, but I have read some discussions ...
Bill's user avatar
  • 8,350
15 votes
4 answers

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 ...
imgx64's user avatar
  • 2,168
22 votes
6 answers

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 ...
EpsilonVector's user avatar
12 votes
1 answer

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 ...
Neale's user avatar
  • 325
5 votes
2 answers

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 ...
Tatu Ulmanen's user avatar
7 votes
3 answers

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 ...
Joseph's user avatar
  • 533
11 votes
3 answers

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 ...
Richard J. Ross III's user avatar
27 votes
5 answers

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 ...
Mike42's user avatar
  • 932
58 votes
12 answers

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 ...
Ryszard Szopa's user avatar
3 votes
2 answers

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 ...
endrendum's user avatar
  • 391
38 votes
7 answers

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 ...
Walter's user avatar
  • 16.1k
21 votes
7 answers

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 ...
Wizard79's user avatar
  • 7,347
15 votes
7 answers

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 ...
Wizard79's user avatar
  • 7,347
34 votes
8 answers

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...
Tamara Wijsman's user avatar
539 votes
18 answers

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 tests ...
7 votes
6 answers

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?
codeyoung's user avatar
  • 2,056
93 votes
11 answers

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.0, ...
Vaccano's user avatar
  • 4,048
19 votes
1 answer

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, ...
Rachel's user avatar
  • 24k
23 votes
16 answers

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 ...
19 votes
9 answers

How have you made unit testing more enjoyable? [closed]

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 ...
Preets's user avatar
  • 1,415
41 votes
12 answers

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? ...
Vaccano's user avatar
  • 4,048
143 votes
7 answers

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. ...
zneak's user avatar
  • 2,596
31 votes
5 answers

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 ...
Casebash's user avatar
  • 7,672

32 33 34 35