unit-testing

What is the best way to refactor database procedures?

I need to understand and clarify some T-SQL stored procedures that contain important business logic. Does anyone know of any tools, tips, tricks, or hints that can be used for unit testing so I can refactor this sql without breaking it? ...

Unit testing Abstract classes in Groovy

I am new to unit testing and mocking. I am trying to unit test an abstract domain class in Grails. How should I mock an implementation so I can unit test the constraints of the domain class? Is there a way to use the mock libraries that come with groovy or grails? Should I just implement a class that simply extends the abstract class? ...

Should I run Unit Tests against my SQLRepository as well?

I'm developing a Domain Model based on the Repository Pattern and all of my Unit Tests as part of TDD are going against a Test Repository. My question is: at what point do I create integration tests against the SQL version of the Repository? My concern is that the code to access data from objects (Test Repository) will work fine. ...

How-to do unit-testing of methods involving file input output?

Hello, I'm using C++Test from Parasoft for unit testing C++ code. I came across the following problem. I have a function similar to the next one (pseudocode): bool LoadFileToMem(const std::string& rStrFileName) { if( openfile(rStrFileName) == successfull ) { if( get_file_size() == successfull ) { i...

Rails unit tests for functions which use attachments

I'm creating a program which will be examining images which are uploaded by the users logged in. I have the RMagick code written up to do the examination (basically finding out if a pixel black is in an image), but I don't know how to write the unit tests for this model. Currently I'm using paperclip to attach the uploaded file to the ...

Customize formatting of passed-in parameter in an expectation

I'm using jmock to mock out an OutputStream and set expectations on the data that gets written to it. So I have an expectation that looks something like this oneOf(stream).write(byteArrayMatching("Some string")); (byteArrayMatching) is a factory for a custom matcher. This all works fine, except when the test fails because the class ...

mockForConstraintsTests abstract groovy class

Unit testing Abstract classes in Groovy I asked a question previous about unit testing and mocking a domain class, but I do not think I was specific enough. I have a domain class: package toplevel.domain abstract class Party { static hasMany = [roles:PartyRole] static constraints = { roles(nullable:true) dateCr...

Given the recent trends in TDD and so on, is a "manager" object always a bad idea?

I write applications for various platforms, but chiefly OS X and Windows. On both, I've been influenced by recent trends in test-driven development (TDD), SOLID, and so on. Most of this I've found to be great advice. I've found that if I have excellent test coverage, I'm more likely to refactor as needed, because I'm more confident that ...

How to set up a local test/build machine?

Hello I am about to start a new personal project. It aims to be a pretty big one so I thought it would be a good idea to keep some sort of CVS. I have also read lot of interesting stuff about unit testing and I would like to include some system that automatically builds the project and runs a series of test after each check in. The cha...

Testing Nested Error Handling with OCMock

I'd really appreciate some advice around testing for errors using OCMock. Method Under Test It grabs a process using an instance of the AppScriptController class. @implementation ProcessGrabber -(void)grabProcess { NSError *error = nil; NSString *processName = [appScriptController processName:ProcessRef ...

Does the Visual Studio Test Runner Support Other Frameworks?

Can I run nUnit tests in Visual Studio (for instance)? ...

Unit testing DAO, am I doing it right?

I'm starting out unit testing and reviewing Java web programming. The thing is I don't know if I'm doing things right. I'm building a mini blog. I'm using EasyMock for the mock objects. Here's my code: The test case The PostDAO The Post Bean I'd really appreciate your comments and suggestions on how I could improve my code and bec...

Handling ASP.NET Forms authentication in WatiN unit tests

.NET application being tested uses <authentication mode="Forms"> so whenever an instance of WatiN.Core.IE is created the login page appears. Can successfully fill in the login form and authenticate, but wondering how to handle this for multiple tests? As soon as the IE instance is released, the next test must log in again. Does WatiN h...

Is assert and unit-testing incompatible?

Hello, I have some concerns related to the fact of testing some functions containing the assert macro from assert.h. If the assert fails the test fails also. This leaves me with some test cases that will never work. For example a function instead of indicating failure (return false or something similar) asserts. Is there a solution f...

How do you Setup your Unit Test Project(s) in .Net?

Can you share the way you setup your unit test projects within your .net solutions? I can imagine several possible methodologies. For example: Having a separate solution for unit tests, perfectly mirroring the structure of the original code solution being tested. Inside the original code solution, have a solution folder in which you'r...

VS2008 UnitTesting - detached RCW with Office Application objects (PowerPoint, etc.)

BACKGROUND I am automating an PowerPoint 2007 via C# I am writing unittests using the built-in unit testing of Visual Studio (Microsoft.VisualStudio.TestTools.UnitTesting) for my code I am well relatively experienced in automating the Office 2007 apps MY PROBLEM When I run my unit tests, the first unit test method runs fine, all af...

Best practices for setting up a Visual Studio project for nUnit tests

How do people set up their projects for Visual Studio and how do you reference the testable application ? Right now I've added a separate project creating a .dll to my solution which contains all the test cases and references nunit.framework , and it also references the main .exe file right from the Debug/ folder where VS generates the ...

Visual Studio Run Tests In Context Problem

When I attempt to "Run Tests in current context" it runs every test in the entire solution. This used to work fine but now seems to have either a bug or a configuration problem. Thanks. ...

Problem with reflection in Unit/Integration tests

Hi I´m dynamically creating an instance of a class with reflection and this works fine, except when trying to do this through unit testing - I´m using the MS testing framework. I get the familiar error of: "Could not load file or assembly 'Assy' or one of its dependencies. The system cannot find the file specified" I have copied the d...

VS2008 unit tests - assert method exits

I'm trying to write a C# unit test with VS 2008's built-in unit testing framework and the method I'm testing calls Environment.Exit(0). When I call this method in my unit test, my unit test is Aborted. The method should indeed be calling Exit, and I want a way to test that it does, and also to test the exit code that it uses. How migh...