unit-testing

Unit Testing a service with System libraries required

I'm currently tdding a "PluginsService" that I'm writing. I'm needing to use the System libraries of Assembly, AssemblyName, Directory and File. Currently I'm creating wrapper interfaces for each of these so I can mock them in the tests. This does mean however that I'm having to inject quite a few wrappers into the service. So for ex...

What are the pros and cons of automated Unit Tests vs automated Integration tests?

Recently we have been adding automated tests to our existing java applications. What we have The majority of these tests are integration tests, which may cover a stack of calls like:- HTTP post into a servlet The servlet validates the request and calls the business layer The business layer does a bunch of stuff via hibernate etc and ...

Skipping tests in some modules in Maven

I would like my Maven builds to run most unit tests. But there are unit tests in one project which are slower and I'd like to generally exclude them; and occasionally turn them on. How do I do this? I know about -Dmaven.test.skip=true, but that turns off all unit tests. I also know about skipping integration tests, described here. ...

What is the AAA syntax equivalent to using Ordered() in Rhino Mocks

I can't for the life of me find the proper syntax using the Fluent/AAA syntax in Rhino for validating order of operations. I know how to do this with the old school record/playback syntax: MockRepository repository = new MockRepository(); using (repository.Ordered()) { // set some ordered expectation...

Unit testing in asp.net MVC, how do I mock a page request?

How do I mock a page request for a .net MVC page? ...

Testing an object's state at save

I'm looking to write unit tests for a method such as this one: public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) { ISPMembershipUserDao userDao = GetISPMembershipUserDao(); if (ValidateUser(username, password)) { SPMembershipU...

Equivalent of CppUnit protectors for boost::test ?

I've used both CppUnit and boost::test for C++ unittesting. Generally I prefer boost::test, mainly because the auto-test macros minimise the effort to setup tests. But there's one thing I really miss from CppUnit: the ability to register your own "protectors", instances of which automatically wrap all the run tests. (Technically, you ...

How can I unit test Arduino code?

I'd like to be able to unit test my Arduino code. Ideally I would be able to run any tests without having to upload the code to the Arduino. Are there any tools or libraries out there which can help me with this? Update: There is an Arduino emulator in development which could be useful but it doesn't yet seem to be ready for use. Updat...

Using randomness and/or iterations in unit tests?

In unit tests, I have become used to test methods applying some regular values, some values offending the method contract, and all border-cases I can come up with. But is it very bad-practice to test on random values, this is a value within a range you think should never give any trouble, so that each time the test runs, another va...

Unit testing tools for generating boundary conditions

Hi, i just wondered if there are any alternative tools out there like Pex for automatic generating boundary conditions for unit tests (should work with NUnit)? Personally i would prefer using Pex, but the license conditions from Microsoft Research Labs do not allow commercial use under Visuals Studio 2008 Professional (what does not mak...

A software testing book from an engineering perspective?

I'm looking for a book that includes methods of testing software from a software engineering perspective. Specifically, I'm looking for a book that includes black box testing techniques (such as how to test software against different input, etc.), but also includes information about test-driven development/design, unit testing, etc. Wh...

How do you mock the caching object in asp.net mvc?

How would I mock the caching object on the ControllerContext object for my unit tests? I have tried creating a wrapper class like the following (since the cache object is a sealed class) with no luck. var mockControllerContext = new Mock<ControllerContext>(); var mockhttpContext = new Mock<HttpContextBase>(); mockhttpConte...

Where to store application settings/state in a MVVM application

I'm experimenting with MVVM for the first time and really like the separation of responsibilities. Of course any design pattern only solves many problems - not all. So I'm trying to figure out where to store application state and where to store application wide commands. Lets say my application connects to a specific URL. I have a Conn...

JsUnit Distributed Testing with Multiple Browsers

I am running a distributed JsUnit test, and everything is fine unless I specify more than one browser under browserFileNames in the remote machine's build.xml. A standalone test on that same machine works beautifully with multiple browsers. The distributed test against that machine runs the first browser in listed in browserFileNames, co...

Why does gcov report 0% coverage on a header file for a well used class?

I'm attempting to measure test coverage for the first time using gcov. Now that I'm past the initial learning curve, things seem to be going well, except for one little snag. I expect that it boils down to a lack of understanding on my part, so I'm hoping someone familiar with gcov can explain what's going on. The issue is that I hav...

Unit testing data access layer using Unity Framework

I am getting close to finish my database, so far, 16 tables so far, and I need to unit test my DAO layer for this ASP.NET project. I am using the Unity Framework to decouple the layers, so I expect that I should be able to assign the DAO layer to my unit tests, which will be testing against the interfaces since the concrete classes are ...

Slow compilation of boost-based unit test suite

Hi all, I use boost.test library to write unit tests for my application. The problem is, when one particular *.cpp file containing test suite grows up to certain size, compilation of that file becomes extremely slow. I use BOOST_AUTO_TEST_CASE macro to define test cases. Boost version is 1.34.1 Build env is autotools + gcc 4.3 under...

Testing own OS X framework

I'm writing my first OS X Objective-C framework, but I do not know how to test it. How can I execute methods and classes in framework for testing purposes? ...

Inter-service Communication Architecture Using WCF, Dependency Injection, and Unit Testing

I'm new to WCF and in a large part, also distributed programming. I am working on a project that requires 4 discrete services. I am trying to correctly define the responsibilities for each component of each service. Suppose I have service B which needs to communicate with service A. For each service, I have defined the service implem...

Unit-Testing: Database set-up for tests

Hello! I'm writing unit-tests for an app that uses a database, and I'd like to be able to run the app against some sample/test data - but I'm not sure of the best way to setup the initial test data for the tests. What I'm looking for is a means to run the code-under-test against the same database (or schematically identical) that I cur...