unit-testing

Should native validations be tested in rails?

Everybody knows that automated testing is a good thing. Not everybody knows exacly what to test. My question is if native validations like validate_presence_of, validate_uniqueness_of and so on should be tested in the application. In my office we are three, one thinks it should be tested, one thinks it shouldn´t and I am up in the air...

Mock an out paramter with moq or rhino mock or something else

I tried with NMock2 but I get TypeLoadExceptions when trying to pass the mocks into the constructor, also I saw TypeMock can do that but it costs 80$ ...

How to test file manipulation

I hear that accessing to database is wrong in testing. But what about file manipulation? Things like, cp, mv, rm and touch methods in FileUtils. If I write a test and actually run the commands (moving files, renaming files, making directories and so on), I can test them. But I need to "undo" every command I ran before running a test ag...

Unit testing Sql for logical reads

We have unit tests for our data access layer. This has helped to spot sql syntax errors. Now that we have these tests I would like to take it one step further. I would like to run the unit tests and find sql that has a high number of logical reads, Automatically.(to find sql in need of tuning) Adding "set statistics IO" to the sql is no...

scons - how to run something /after/ all targets have been built

I've recently picked up scons to implement a multi-platform build framework for a medium sized C++ project. The build generates a bunch of unit-tests which should be invoked at the end of it all. How does one achieve that sort of thing? For example in my top level sconstruct, I have subdirs=['list', 'of', 'my', 'subprojects'] for subd...

Looking for an example of a custom SynchronizationContext

I need a custom SynchronizationContext that: Owns a single thread that runs "Posts" and "Sends" delegates Does the send in the order they are send in No other methods are needed I need this so I can unit test some threading code that will talk to WinForm in the real application. Before I write my own, I was hoping that someone coul...

Unit Testing Sqlite Membership Provider in MVC app

I've created an MVC application and I've set up Roger Martin's sqlite Providers in place of the default Providers. I'm curious about how I would go about unit testing these. Below is a stripped down method that has many validations, only one of which is still present. Among other things, I want to write tests that ensures one can't ...

C#.NET 2.0 - Getting ConfigurationError, configuration section for Logging cannot be found, when running test framewlork

Hello - We have a solution that comprises several projects. I came on not too long ago, and started adding functionality to one of the projects. We are using the Enterprise Library 3.1 Logging Application Block for logging. We have been talking about Unit Testing (who hasn't) but haven't tried to add it until today. I decided to use...

Unit testing a WCF service with multiple dependencies

I certainly hope someone can help ease my frustration. I am trying to find a good way to unit test my WCF service implementation classes but every resource that I've found providing a solution is limited to services with only a single method/operation. In my case, I have a service class which contains several service methods/operations...

cakephp unit testing models, fixtures problem

Hey all, So i'm working with CakePHP v1.2.5. On my current project, I decided to start writing tests as I code the functionality (yay TDD). I'm having trouble with fixture loading though. To aid in the process, I'll describe my code (Really quite simple right now). My model is defined like so // app/models/newsitem.php <?php class New...

C# : Unit testing without using 3rd party framework?

Should unit testing be run in debug or release mode? I am using Visual Studio Standard Edition 2005 which does not come with any unit testing framework. Since I also do not want to make use of any other 3rd party unit testing framework, I used Debug.Assert to perform the actual test inside all unit test methods. However, Debug.Assert on...

Unit Testing Controller Actions that call IsAjaxRequest()

Some of my controller actions need to respond with different ViewResults depending whether or not they were called by an AJAX request. Currently, I'm using the IsAjaxRequest() method to check for this. When this method is called during a unit test, it throws an ArgumentNullException because the HTTP context is missing. Is there a way t...

Unit testing a Winforms event driven architecture

What approach should I take (if it's even possible) to unit test a standard event driven Winforms app where display and logic are mixed together. ...

So.. I need to train the team on Unit Testing - could use C&C on lesson plan

Hi all, So - management is looking to do a push to move towards doing unit-testing in all the applications moving forward - and eventually get into full TDD/Continuous Integration/Automated build mode (I hope). At this point however we are just concerned about getting everyone developing apps moving forward using unit-testing. I'd like ...

Rails test fixtures vs uniqueness

In Rails, fixtures records seem to be inserted & deleted in isolation for a given model. I'd like to test having many objects/rows in one transaction, eg. to check uniqueness. How to do it? ...

Is this the correct way to use and test a class that makes use of the factory pattern?

I don't have a lot of experience with the factory pattern and I've come across a scenario where I believe it is necessary but I'm not sure the I've implemented the pattern correctly and I'm concerned about the impact it's had on the readability of my unit tests. I've created a code snippet that approximates (from memory) the essence of ...

Code and unit tests in two different laguages?

I've recently have started writing unit tests for PL/SQL code in Ruby. Are there any other language combinations where you write your code and unit tests in two completely different languages? ...

How do you separate unit tests from integration tests in Visual Studio?

I've been using Visual Studio 2008 Test projects to store my tests. Lately I've realized that a lot of my unit tests are in fact integration tests because they rely on external sources (e.g. file system, SQL server, registry). My question is, what is a good approach to separating out integration tests from unit tests? Ideally I want...

Using OCUnit in Xcode for iPhone projects?

After configuring my iPhone app for unit testing, I belatedly noticed this warning in the documentation: iPhone OS Unit Testing Support: Unit tests are not supported for iPhone applications. As some of the other Xcode documentation regarding unit testing is out of date...is this still the case? ...

unit test in rails - model with paperclip

I'm trying to write a test for a model with a picture, using paperclip. I'm using the test framework default, no shoulda or rspec. In this context, how should I test it? Should I really upload a file? How should I add a file to the fixture? ...