unit-testing

TraceSource in TestDriven.NET AppDomain

I'm running tests using the TestDriven.NET VS add-in, and the class library I'm testing is instrumented using TraceSource. How can I get the output of that TraceSource to show up in the Output window in Visual Studio? The DefaultTraceListener doesn't appear to be working quite right. Do I need to manually add a ConsoleListener or some...

Why are functional tests not enough? What do unit tests offer?

I just had a conversation with my lead developer who disagreed that unit tests are all that necessary or important. In his view, functional tests with a high enough code coverage should be enough since any inner refactorings (interface changes, etc.) will not lead to the tests being needed to be rewritten or looked over again. I tried e...

WorkFlow Unit Testing

How to unit test the windows workflows? ...

Build C project automaticly

I'm working on a free software (bsd license) project with others. We're searching for a system that check out our source code (svn) and build it also as test it (unit tests with Check / other tools). It should have a webbased interface and generate reports. I hope we don't have to write such a system from null by ourselves... ...

Code coverage tools for VS 2008

We're getting our feet wet with unit testing in VS 2008 Professional Edition and have hit what might be a pretty large snag: there appears to be no way to determine code coverage in this particular VS edition. It seems that this is something only available in VS Team System Development Edition. In other words, VS 2008 Professional Editi...

Rhino Mocks: good tutorials

I'm looking for a good tutorial on mock objects in general and Rhino Mocks in particular. I'd like to recommend it to co-workers to help bring them up to speed. One co-worker is an experienced developer with some experience writing unit tests, while the other is less experienced. ...

C++ testing framework: recommendation sought

I'm looking for a "quick and dirty" C++ testing framework I can use on my Windows/Visual Studio box. It's just me developing, so it doesn't have to be enterprise class software. Staring at a list of testing frameworks, I am somewhat befuddled... http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B ...

Design for test OR Stop designing for test

Hi! So which is better. Do we start letting Tests design our code. Do we start introducing constructor injection for dependencies just to make code testable? or do we use the "override" protected method & sub class the class under test. ...

How to unit test a pseudo random number generator?

Hi all, I have a pseudo random number generator (PRNG) class that I want to unit test. There are two approaches: write a test case that takes a large amount of samples and test whether they are properly distributed. This approach may lead to a fairly long execution time for the test case; calculate a small series of samples 'by hand'...

How to organize C++ test apps and related files?

I'm working on a C++ library that (among other stuff) has functions to read config files; and I want to add tests for this. So far, this has lead me to create lots of valid and invalid config files, each with only a few lines that test one specific functionality. But it has now got very unwieldy, as there are so many files, and also lots...

Unit test Custom membership provider with NUnit throws null reference error

Trying to create a user account in a test. But getting a Object reference is not set to an instanve of an object error when running it. Here's my MemberShip provider class, it's in a class library MyCompany.MyApp.Domain.dll: using System; using System.Collections.Generic; using System.Web.Security; namespace MyCompany.MyApp.Domain { ...

VS 2008 #if conditional statement for unit testing

Is there a "#if DEBUG"-like conditional statement which can be used in VS 2008 for determining if the code is being run from a unit test? (We're using MS's built-in unit testing.) For example: #if !UNITTEST // Do some GUI stuff we don't want to see when unit testing #endif ...

Test Data Builder pattern: more useful or more upkeep?

Let me start by saying I'm a huge fan of the elegance of this pattern -- I have a group of basic entities that I have implemented builders for (specifically for testing). However I have found (and this may be the caveat) that as my program evolved I kept having to go back and re-work the builders. In the end, it really hasn't seemed wo...

How should one unit test the hashCode-equals contract?

In a nutshell, the hashCode contract, according to Java's object.hashCode(): The hash code shouldn't change unless something affecting equals() changes equals() implies hash codes are == Let's assume interest primarily in immutable data objects - their information never changes after they're constructed, so #1 is assumed to hold. Th...

How to run included tests on deployed pylons application

I have installed pylons based application from egg, so it sits somewhere under /usr/lib/python2.5/site-packages. I see that the tests are packaged too and I would like to run them (to catch a problem that shows up on deployed application but not on development version). So how do I run them? Doing "nosetests" from directory containing ...

Visual Studio MSTest run failing to even start

I've got a bunch of unit tests built using Visual Studio 2005's built-in unit testing functionality. For the last little while, it's been taking absolutely forever to start the tests... Everything just sits there at "Pending" for two minutes or more. Now Visual Studio's decided to take things to a new level and never even start the tes...

Automagic unit tests for upholding Object method contracts in Java?

When developing Java applications, I often override Object methods (usually equals and hashCode). I would like some way to systematically check that I'm adhering to the contract for Object methods for every one of my classes. For example, I want tests that assert that for equal objects, the hash code is also equal. I'm using the JUnit...

JUnit and junit.framework.TestSuite - No runnable methods

I've made some unit tests (in test class). The tutorial I've read said that I should make a TestSuite for the unittests. Odd is that when I'm running the unit test directly (selecting the test class - Run as jUnit test) everything is working fine, altough when I'm trying the same thing with the test suite there's always an exception: ja...

PHPUnit - Unit Testing with items that need to send headers

I'm currently working with PHPUnit to try and develop tests alongside what I'm writing, however, I'm currently working on writing the Session Manager, and am having issues doing so... The constructor for the Session handling class is private function __construct() { if (!headers_sent()) { session_start(); self::$session_id = sess...

PHPUnit - Testing abstract Classes

How do I test an abstract class works in PHPUnit? I'd expect that I'd have to create some sort of object as part of the test? though - I've no idea the best practice for this, or if phpunit allows for this ...