unit-testing

In Ruby, how to I control the order in which Test::Unit tests are run?

For example, when these tests are run, I want to ensure that test_fizz always runs first. require 'test/unit' class FooTest < Test::Unit::TestCase def test_fizz puts "Running fizz" assert true end def test_bar puts "Running bar" assert true end end Update: Why do I want to do this? My ...

Fluent NHibernate PersistenceSpecification

Hi! I got the following error message: System.IndexOutOfRangeException: Invalid index 9 for this SqlParameterCollection with Count=9.. And I absolutely wonder why oO?! The database schema and the hbm.xml files were all correctly created with FluentNHibernate. The error ocurrs in the CanCorrectlyMapBookmethod, the PersistenceSpecifica...

How do I setup a functional test to authenticate openid with authlogic?

I have a functional test that is supposed to call ROTS (Ruby Openid Test Server) to act as an identity. In my UsersControllerTest, I have the following: test "creating a user" do get :create, :user => { :username => "woot", :email => "[email protected]", ...

How does TDD work with Exceptions and parameter validation?

I have come to something of a crossroads. I recently wrote a 10,000 line application with no TDD (a mistake I know). I definitely ran into a very large amount of errors but now I want to retrofit the project. Here is the problem I ran into though. Lets take a example of a function that does division: public int divide (int var1, int var...

Fluent NHibernate PersistenceSpecification Component and Reference Tests

Hi! I have two problems. 1 . FNH does not test my component correcty and I dont know why. System.ApplicationException: Expected 'DomainModel.Model.Publisher' but got 'DomainModel.Model.Publisher' for Property 'Publisher'. [TestMethod] public void CanCorrectlyMapBook() { new PersistenceSpecification<Book>(_session) ...

Path to Test Data Files for Unit Testing

I am currently using the standard Microsoft Unit Test suite in VS 2008. ReSharper 4.5 is also installed. My unit tests rely on an TestInitialize method which pre-loads a data file. The path to this test data file will differ depending on if I run the unit test from within VS 2008 using the standard Ctrl-R + Ctrl-T command versus the R...

functional test for Rails plugin, assert_template broken?

I'm writing a plugin that adds a class method to ActionController::Base, so in my functional test I am creating a simple controller to test against. The example below is totally stripped down to basically do nothing. The test succeeds all the way up to assert_template, which fails. require 'rubygems' require 'test/unit' require 'active_...

Using Mockito's generic "any()" method

I have an interface with a method that expects an array of Foo: public interface IBar { void DoStuff(Foo[] arr); } I am mocking this interface using Mockito, and I'd like to assert that DoStuff() is called, but I don't want to validate what argument are passed - "don't care". How do I write the following code using any(), the gener...

Does it make sense to unit test controllers

I know that Microsoft and MvcContrib have made great attempts at enabled developers to unit test controllers. But lately I've been wondering if we should ditch unit testing controllers, and leave them for integration testing. I have two reasons for this: A good controller should not have any logic in it, or very basic minimal logic. ...

Visual C++ Team Test problems

I am trying to get some unit tests for native C++ running with Visual Studio Test Suite. I have just a single, simple class named "Shape". I followed a tutorial and did the following steps: Created a "ref class" wrapper called "MShape" for the native class I want to test Changed configuration type to .dll Changed CLR support to /CLR Se...

Why doesn't Visual Studio 2008 permanently show Class Name column in Test Results window?

Using the Show/Remove Columns context menu option in the Test Results window I can show the Class Name column. However, when I then close and reopen Visual Studio 2008 the Class Name column is not longer there. How do I permanently display the Class Name column? EDIT: I started this edit thinking I'd found the reliable way to reproduc...

how can I get test coverage statistics for VS2008 C# project

Hi, I am using Visual Studio 2008 for a C# WinForms application and I am using the MSTest unit testing framework. It doesn't seem to have test coverage (I think it's in Team System?). What is the easiest (cheapest?) way to get some test coverage statistics for my project here? Effectively just an indication of for each *.cs file the...

Moq Roles.AddUserToRole test

I am writing unit tests for a project in ASP.NET MVC 1.0 using Moq and MvcContrib TestHelper classes. I have run into a problem. When I come to Roles.AddUserToRole in my AccountController, I get a System.NotSupportedException. The Roles class is static and Moq cannot mock a static class. What can I do? ...

How do I ignore a test based on another test in NUnit?

I'm writing some NUnit tests for database operations. Obviously, if Add() fails, then Get() will fail as well. However, it looks deceiving when both Add() and Get() fail because it looks like there's two problems instead of just one. Is there a way to specify an 'order' for tests to run in, in that if the first test fails, the following...

C#: Unit testing of child classes

Say we have this hyper simple class hierchy: public class SomeMath { public int Add(int x, int y) { return x + y; } } public class MoreMath : SomeMath { public int Subtract(int x, int y) { return x - y; } } Should I write tests for the Add method when I write tests for the MoreMath class? Or sh...

How do I unit test a controller action that uses ther Controller.User variable?

I have a controller action that automatically redirects to a new page if the user is already logged in (User.Identity.IsAuthenticated). What is the best way to write a unit test for this scenario to ensure that the redirect takes places? ...

How to unit test the sorting of a std::vector

I have never used unit testing before, so I'm giving CxxTest a go. I wrote a test to check if a function correctly sorts a std::vector. First I made sure the test failed when the vector wasn't sorted, and then as a sanity check I tested whether std::sort worked (it did, of course). So far, so good. Then I started writing my own sorting ...

Unit testing icefaces

Can you separate components of an IceFaces application so they can be tested in isolation instead of using something like Selenium or HttpUnit on the assembled application? Backing beans can be easily isolated (if written to be testable) but I am interested in testing the template/display parts of the application while using as little o...

Should you still do memory management in a unit test? (OCUnit)

Hi! Should I still bother with releasing objects in a unit test? I noticed in Apple's "iPhoneUnitTests" sample project objects are [[object alloc] init] in the setup method but never released anywhere in the unit test? Thanks! ...

Struts Action Validation

Hey People. I have been recently validating Struts 2 actions. In One of my action class, the save method to be precise must have two id's. That is an assessmenttype id and a course id. this is what is have so far. @Test public void testSave() { Assessment assessment = new Assessment(); assessment.setAssessmentType(assessment.get...