unit-testing

Resources on methodologies for testable C++ GUI applications

What resources would you recommend on the subject? What I am looking for is practical advice on the differences of different approaches (MVC, MVP, Presenter First, Humble Dialog), their implementation details (setting it up, passing messages around, connecting) and unit / automated integration testing approaches. My main interest would b...

TFS UnitTesting not deploying local copy assembly to test dir when on build server

I have an assembly that needs to be in the test output dir for my tests to run. I have the assembly referenced as a local copy in the project but on the build server this gets ignored. The two ways I have found to fix this are Add a special attribute to test method that will make sure the file is there for each test. [DeploymentItem("...

Using Lambda in Unit Test in VB.NET 2008 with Rhino.Mocks

Hi, I am trying to create a unit test similar to how I would have done one in C# but am struggling with the lambdas in vb. Bascially I am trying to mock a class and then create a stub and return. In C# I would have done something like; MockedPersonRepository .Stub(x => x.Find(id)) .Return(person) But in visual basic I am t...

Testing a web service for missing mandatory fields in .NET

Part of my current work involves using an external web service, for which I have generated client proxy code (using the WSDL.exe tool). I need to test that the web service correctly handles the absence of mandatory fields. For instance, Surname and Forename are mandatory - if they are absent from the call, then a SOAP fault block should...

is it reasonable/possible to use Nunit's Configurations to change test behavior?

I've got a suite of about 20 tests that I run on my Development server. I'd like an easy way to switch over to the Alpha server and run those same 20 tests. But I don't want to run them on all servers every time. Typically I'd run the tests on Dev until they are all green, then roll code to Alpha, run tests, etc. Many iterations on Dev, ...

Should one test internal implementation, or only test public behaviour?

Given software where ... The system consists of a few subsystems Each subsystem consists of a few components Each component is implemented using many classes ... I like to write automated tests of each subsystem or component. I don't write a test for each internal class of a component (except inasmuch as each class contributes to th...

Beginning unit tests long after the project has begun?

I have taken on a project that has been underway for months. I've yet to ever do unit tests and figured it would be a decent time to start. However, normally unit tests are written as you go and you plan for them when beginning the project. Is it reasonable for me to start now? Are there any decent resources for setting up unit tests...

EasyMock: Void Methods

I have a method that returns void in a class that is a dependency of the class I want to test. This class is huge and I'm only using this single method from it. I need to replace the implementation of this method for the test as I want it to do something different and I need to be able to access the parameters this method receives. I c...

NUnit example code?

I would like to learn how to use NUnit. I learn best by reading then playing with real code. Where can I find a small, simple C# project that uses NUnit in an exemplary manner? ...

Unit testing with -fno-access-control

I have seen many crazy methods to get access to private variables when unit testing. The most mind blowing I've seen is #define private public. However, I've never seen anyone suggest turning off private variables at the compiler level. I had always just assumed that you couldn't. I've complained to many a developer that unit testing...

unit test build files

What are the best policies for unit testing build files? The reason I ask is my company produces highly reliable embedded devices. Software patches are just not an option, as they cost our customers thousands to distribute. Because of this we have very strict code quality procedures(unit tests, code reviews, tracability, etc). Those ...

Parameter constraints

Hello, I am using the Rhino Mocks framework. I referenced the Rhinomocks dll and everything worked fine.. but when I was trying to use the LastCall.Constraints(Is.Anything()) it says: Error The name 'Is' does not exist in the current context The same happens with Text and List constraints.. any help?? ...

How does unit testing on the iPhone work?

Do I need special libraries for this, or can I just create a huge class that trys to instantiate every object of my project and test all the methods in there? How's that done in theory? ...

Automated way to find JUnit tests that leak memory

The root of our problem is Singletons. But Singletons are hard to break and in the meantime we have a lot of unit tests that use Singletons without being careful to completely clear them in the tearDown() method. If figure that a good way to detect tests like these is to look for memory leaks. If the memory used after tearDown() and S...

Generic Test harness for java.util.Map?

I have a custom implementation of the Map interface which does some fancy stuff, like lazy evaluation of functions. the implementation should appear immutable after construction from outside (e.g. no put() and putAll() methods are supported) I it looks like it works in the most basic conditions. Since it is quite complex, i am sure ther...

How do I unit test for machine specific behaviour?

I am testing a static method that builds a URL string after checking proxies and hostnames and all kinds of things. This method internally relies on the static flag System.Net.Sockets.Socket.OSSupportsIPv6. Because it's static, I cannot mock this dependency. EDIT: (This is simplified down a lot... I can't modify the structure of the met...

"Echo" device for Unit Testing

I'm currently writing up some CPPunit tests for a program that tests a hardware communication port (yes, I'm writing unit tests for a tester app ;-) ). One of the classes I'm testing is basically a wrapper around the device's file descriptor; I make read() and write() calls on the file descriptor. Is there a device file/driver on Linux...

Magic numbers - Reading from a config file the same as global space? Bad for unit testing?

Consider the following class: class Something : ISomething { public void DoesSomething(int x) { if (x == 0) { x = 1; } } } I want to of course remove the magic number - my unit tests are passing etc... but I want to refactor the horrible magic number out. I'm using C# but I guess this problem is p...

Use an alternative Maven Profile during test phase

I'm trying to build an application starting from an Appfuse Archetype, but I get some strange problems. For once I'd like to use a hsqldb for automated unit tests and integration tests, and a mysql db for my manual testing so that I can easily manipulate the data when I need to, so it would be nice to automatically switch profiles during...

Dynamically create tests in NUnit

Using Nunit, I want to be able to write a test fixture that will read all the filenames in a particular directory and create a test for each file. I could quite easily write one test method that scans through the directory and just does all the tests, but when I run NUnit I want to be able to see each of the tests individually. Is this...