unit-testing

Testing a function that throws on failure

What is the best way of testing a function that throws on failure? Or testing a function that is fairly immune to failure? For instance; I have a I/O Completion Port class that throws in the constructor if it can't initialise the port correctly. This uses the Win32 function of CreateIoCompletionPort in the initialiser list. If the handl...

Run PHPUnit Tests in Certain Order

Is there a way to get the tests inside of a TestCase to run in a certain order? For example, I want to seperate the lifecycle of an object from creation to use to destruction but need to make sure that the object is set up first before I run the other tests. ...

Unit test execution speed (how many tests per second?)

What kind of execution rate do you aim for with your unit tests (# test per second)? How long is too long for an individual unit test? I'd be interested in knowing if people have any specific thresholds for determining whether their tests are too slow, or is it just when the friction of a long running test suite gets the better of you?...

What is the difference between integration and unit tests?

I know the so-called textbook definition of unit tests and integration tests. What I am curious about is when it is time to write unit tests... I will write them to cover as many sets of classes as possible. For example, if I have a Word class, I will write some unit tests for the Word class. Then, I begin writing my Sentence class, a...

Unit tests for deep cloning

Let's say I have a complex .NET class, with lots of arrays and other class object members. I need to be able to generate a deep clone of this object - so I write a Clone() method, and implement it with a simple BinaryFormatter serialize/deserialize - or perhaps I do the deep clone using some other technique which is more error prone and...

How should I unit test a code-generator?

This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions. I have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did i...

Unit testing a timer based application?

I am currently writing a simple, timer based mini app in C# that performs an action n times every k seconds. I am trying to adopt a test driven development style, so my goal is to unit test all parts of the app. So, my question is: Is there a good way to unit test a timer based class? The problem, as I see it, is that there is a big ri...

How should I unit test threaded code?

Hot-on-the-heels of of my previous unit testing related question, here's another toughie: I have thus far avoided the nightmare that is testing multi-threaded code since it just seems like too much of a minefield. I'd like to ask how people have gone about testing code that relies on threads for successful execution, or just how people...

Has anyone had any success in unit testing SQL stored procedures?

We’ve found that the unit tests we’ve written for our C#/C++ code have really paid off. But we still have thousands of lines of business logic in stored procedures, which only really get tested in anger when our product is rolled out to a large number of users. What makes this worse is that some of these stored procedures end up being...

Rigor in capturing test cases for unit testing

Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers> unsorted, bool ascending); We pass in an unsorted list of numbers and a boolean specifying ascending or descending sort order. In return, we get a sorted list of numbers. In my experience, some people are better at capturing boun...

Choosing a C++ unit testing tool/framework

Could you recommend a testing tool/framework to use for testing C++ code in a UNIX environment? ...

How do I run (unit) tests in different folders/projects separately in Visual Studio?

I need some advice as to how I easily can separate test runs for unit tests and integration test in Visual Studio. Often, or always, I structure the solution as presented in the above picture: separate projects for unit tests and integration tests. The unit tests is run very frequently while the integration tests naturally is run when ...

Developer testing vs. QA team testing - What is the right division of work?

While trying to advocate more developer testing, I find the argument "Isn't that QA's job?" is used a lot. In my mind, it doesn't make sense to give the QA team all testing responsibilities, but at the same time Spolsky and others say you shouldn't be using the $100/hr developers to do something a $30/hr tester could be doing. What are...

Automated testing a game

Question How would you go adding automated testing to a game? I believe you can unit test a lot of the game engine's functionality (networking, object creation, memory management, etc), but is it possible to automate test the actual game itself? I'm not talking about gameplay elements (like Protoss would beat Zerg in map X), but I'm t...

Has anyone used NUnitLite with any success?

I've recently started work on the Compact Framework and I was wondering if anyone had some recommendations for unit testing beyond what's in VS 2008. MSTest is ok, but debugging the tests is a nightmare and the test runner is so slow. I see that NUnitLite on codeplex is an option, but it doesn't look very active; it's also in the roadma...

Getting Started with Unit Testing

Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are: Running the tests becomes automate-able and repeatable You can test at a much more granular level than point-and-click testing via a GUI Rytmis My question is, what are the curre...

Unit testing kernel drivers

I'm looking for a testing framework for the Windows kernel environment. So far, I've found cfix. Has any one tried it? Are there alternatives? ...

Unit testing in Delphi - how are you doing it ?

Hi, I'm wondering how the few Delphi users here are doing unit testing, if any ? Is there anything that integrates with the IDE that you've found works well ? If not, what tools are you using and do you have or know of example mini-projects that demonstrate how it all works ? ...

Best practice for integrating TDD with web application development?

Hi all, Unit testing and ASP.NET web applications are an ambiguous point in my group. More often than not, good testing practices fall through the cracks and web applications end up going live for several years with no tests. The cause of this pain point generally revolves around the hassle of writing UI automation mid-development. ...

How do you unit test web apps hosted remotely?

I'm familiar with TDD and use it in both my workplace and my home-brewed web applications. However, every time I have used TDD in a web application, I have had the luxury of having full access to the web server. That means that I can update the server then run my unit tests directly from the server. My question is, if you are using a ...