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
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 ...
Tomas Jansson's user avatar
38 votes
13 answers
7k 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 ...
CraigTP's user avatar
  • 1,564
62 votes
9 answers
23k 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 ...
Jens's user avatar
  • 729
57 votes
3 answers
16k 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 ...
dsimcha's user avatar
  • 17.2k
12 votes
3 answers
2k 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 ...
Bill's user avatar
  • 8,350
15 votes
4 answers
2k 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 ...
imgx64's user avatar
  • 2,168
22 votes
6 answers
10k 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 ...
EpsilonVector's user avatar
12 votes
1 answer
2k 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 ...
Neale's user avatar
  • 325
5 votes
2 answers
1k 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 ...
Tatu Ulmanen's user avatar
7 votes
3 answers
5k 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 ...
Joseph's user avatar
  • 533
11 votes
3 answers
250 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 ...
Richard J. Ross III's user avatar
27 votes
5 answers
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 ...
Mike42's user avatar
  • 932
58 votes
12 answers
6k 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 ...
Ryszard Szopa's user avatar
3 votes
2 answers
803 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 ...
endrendum's user avatar
  • 391
38 votes
7 answers
3k 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 ...
Walter's user avatar
  • 16.1k
21 votes
7 answers
13k 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 ...
Wizard79's user avatar
  • 7,347
15 votes
7 answers
1k 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 ...
Wizard79's user avatar
  • 7,347
34 votes
8 answers
22k 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...
Tamara Wijsman's user avatar
539 votes
18 answers
483k 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 tests ...
7 votes
6 answers
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?
codeyoung's user avatar
  • 2,056
93 votes
11 answers
86k 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.0, ...
Vaccano's user avatar
  • 4,048
19 votes
1 answer
15k 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, ...
Rachel's user avatar
  • 24k
23 votes
16 answers
11k 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 ...
19 votes
9 answers
4k views

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
25k 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? ...
Vaccano's user avatar
  • 4,048
143 votes
7 answers
64k 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. ...
zneak's user avatar
  • 2,596
31 votes
5 answers
3k 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 ...
Casebash's user avatar
  • 7,672

1
32 33 34 35
36