unit-testing

FTPListener in .NET

I am unittesting a bit of code that can fetch files either from the local file system, or from http or ftp. To unittest it I created a simple method that uses the HTTPListener class from the BCL to run a one-off webserver on a different thread, it just serves a byte array that I send in and then shuts down. (See code for this below). I...

RhinoMocks - Specifying return for functions called later

Using RhinoMocks - how can I say "whenever some function is called from now on - it should return some value". I'd like to say something like this: fakeCalculator.WhenCalled(factory => factory.AddNumbers(1, 2)).Return(3); And then - when the AddNumbers function is called with 1 and 2 - it will return 3. I.e. I want to define this ...

How do you solve the infinite regress problem in TDD?

If I write test code to test my code, the test code might have bugs so it needs to be tested and when my code changes my test code may have to change. Repeat ad infinitum. How is this problem solved (in practice and in theory)? ...

Unit testing asynchronous function

In the following code sample I have an Async Calculator class. This is injected with an ICalc, which will be a syncronous calculator. I use dependency injecting and mock the ICalc because this resembles my true scenario, though I guess the mocking isn't really of relevance to the question. The AsyncCalc has a function which will call ano...

How to compare two lists of objects using moq with mspec (BDD style)

I've just started to explore BDD for my current project. I'm using moq with mspec to get nice test outputs. However, i can't find enough examples of what i'm trying to do, maybe i'm using the wrong approach or perhaps just don't understand the syntax enough, please advise. The problem is i'm trying to verify whether a property has been ...

Autotest equivalent for PHP?

I have been using autotest for unit testing in ruby. Is there an equivalent for PHP that will run my unit tests after my code has been updated? I am using PHPUnit and Eclipse. ...

Testing recommendations for LAMP web apps

I need help testing! :) I work at a small webdev company and am responsible for the quality of our applications. We build e-commerce sites every now and then, and since our customers rely on the site to make money, the have to be completely bug free. Sadly, we've had issues with that in the past and we're looking to tighten up our tes...

How to BDD with GWT using MSpec? The correct way to write this scenario...

I'm just starting to practice BDD using the GWT approach to the following code exert and just realised that I can't do the second test. My GWT goes something like Given there exists an open query When the user replies to the query Then it should save the reply if the reply is not blank Then it should notify the user and not save the ...

Kohana 3 and SimpleTest using autorun.php

How do I go about integrating Simpletest with Kohana 3? I have checked out this answer but I like to use the autorun.php functionality from SimpleTest. ...

How can I use different JARs for compiling and testing in maven?

I compile my programm against javaee-api. But for Junit testing I must use a specific implementation like glassfish's javaee.jar to avoid errors like java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/Persistence (see also 1). So avoid using methods, that are only a...

Is it possible to run only subsets of a Boost unit test module?

I am using the Boost 1.34.1 unit test framework. (I know the version is ancient, but right now updating or switching frameworks is not an option for technical reasons.) I have a single test module (#define BOOST_TEST_MODULE UnitTests) that consists of three test suites (BOOST_AUTO_TEST_SUITE( Suite1 );) which in turn consist of several ...

Unit Tests on a 32bit/64bit Application

We have an application that now has a 64 bit target, as well as the old 32 bit target. My question concerns our Unit Tests. Should we compile and run our Unit Tests in both as well? Is there any chance we will find flaws this way? Am I being overly paranoid? ...

Unit Testing ASP.Net MVC Action result with call to Server.UrlDecode

We are trying to write Unit Tests in our ASP.Net MVC project. Some of the methods in the controller contain a call to Server.UrlDecode This fails with a null reference exception when called from a unit test. Anybody have a solution for this? ...

VC++ project never up-to-date

I'm using Visual Studio 2008. I have a solution with two projects. One builds a DLL, which is my "production code". The other builds a console app exe, which is my unit test suite. For my unit test project, I have listed as linker inputs the names of the source modules from the DLL. I.e., I have a DLLMain.cpp in the DLL project, and...

JUnit Test a Database Failure?

I'm trying to create a test that simulates a system failure to ensure the integrity of a Oracle Berkeley DB XML database. Data loss is currently being experienced during an insert operation so I'd like to setup a test that starts inserting an arbitrary number of documents and sack the process along the way (akin to someone yanking the po...

Are there any automated white box testing tools for T-SQL stored procedures and/or functions?

I was wondering if there are any tools similar to Pex that analyze T-SQL stored procedures and functions (instead of managed code) in order to generate meaningful and interesting input values for parameterized unit tests. ...

Unit testing for downloads

I am writing a Java program that downloads and then processes many webpages. What is the best practice for testing a component of the program that downloads a page without hitting the remote servers? ...

To Constructor Inject Or Not With TDD?

I have a method that I'm trying to unit test that uses a query object, I would like to Stub this query object for my unit tests. This query object does has a dependency (UnitOfWork). I am using a IOC/DI container to instantiate my objects in the app. However I DO NOT want to use the container while TDD. The way I see it is I have 2 optio...

At what point do you reach Unit Testing overkill?

I'm currently working on a project where I'm unit testing with NUnit, mocking with Moq, writing specifications with MSpec and playing around with testing the UI with WebAii. While I'm enjoying the experience on the whole and learning plenty about what and how to test, I can help wondering if all four of these tools is going a bit overbo...

Is Unit Testing Suitable for BPM Development?

I'm currently working on a large BPM project at work which uses the Global 360 BPM tool-set called Process 360. Just to give some background; this product works like a lot of other BPM solutions in that you design multiple "process maps" which define the flow of a particular business process you're trying to model, and each process map ...