unit-testing

RSpec, stubbing nested resource methods

I've got two models: class Solution < ActiveRecord::Base belongs_to :owner, :class_name => "User", :foreign_key => :user_id end class User < ActiveRecord::Base has_many :solutions end and I nest solutions within users like this: ActionController::Routing::Routes.draw do |map| map.resources :users, :has_many => :solutions end ...

Is testswarm.com dead? Any equivalents?

Hi. I hope You are more 'on the ball' than I am. I remember getting news on the Mozilla labs TestSwarm some time ago. It had active users then, but it was not more than 10 per a single browser+OS configuration. I went there today expecting it to be far better and it turns out that there are NO active testing environments. Moreover, wh...

Is there an equivalent to RSpec's before(:all) in MiniTest?

Since it now seems to have replaced TestUnit in 1.9.1, I can't seem to find an equivalent to this. There are times when you really just want a method to run once for the suite of tests. For now I've resorted to some lovely hackery along the lines of: Class ParseStandardWindTest < MiniTest::Unit::TestCase @@reader ||= PolicyDataReade...

Why is "rake tests" running an empty suite when I use shoulda?

So here is my test suite: class ReleaseTest < ActiveSupport::TestCase should_not_allow_values_for :title, '', 'blah', 'blah blah' should_allow_values_for :title, 'blah - bleh', 'blah blah - bleh bleh' def test_something assert true end end Shoulda's macros generate 5 tests, and then I have test_something below (just to se...

iPHone: Unit/Logic Tests initWithNibName

I have setup my Logic Tests following the instructions on http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html. I could test a couple classes successfully. But I got error when testing the following: - (id)init { if (self = [super init...

VS2008: File creation fails randomly in unit testing?

I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in C# .NET with VS 2008. I have about 50 unit tests right now for various parts of the code (mostly for the various serialization operations), and some of them seem to be failing mostly at random when they deal with file I/O. The wa...

How to test a site rigorously?

Hello, I recently created a big portal site. It's time for putting it to test. How do you guys test a site rigorously? What are the ways and tools for that? Can we sort of mimic hundreds of virtual users visiting the site to see its load handling? The test should be for both security and speed Thanks in advance. ...

How can I include utility functions from another file into a Sproutcore unit test file?

Lets say I have a few utility functions in file tests/utils/functions.js. I would like to use these functions from several unit test files. However, I'm not able to use them as the Sproutcore build system does not include any external files into the html page used to run the unit tests. Only application code and the code from the unit t...

Starting a new project - where do I start?

I am going to start a project of my own, which will be ASP.NET MVC + Fluent NHibernate. I want to use test-first approach as much as I can. So, where exactly do I start from? Database schema? Domain model? Mapping domain model classes to the database? ...

How do I inherit abstract unit tests in Ruby?

I have two unit tests that should share a lot of common tests with slightly different setup methods. If I write something like class Abstract < Test::Unit::TestCase def setup @field = create end def test_1 ... end end class Concrete1 < Abstract def create SomeClass1.new end end class Concrete2 < Abstract de...

API sanity autotest help needed

I am trying to auto-generate Unit Tests for my C code using API sanity autotest. But, the problem is that it is somewhat complex to use, and some tutorials / howto / other resources on how to use it would be really helpful. Have you had any luck with API sanity autotest? Do you think there's a better tool that can be used to auto-gener...

Using ASSERT and EXPECT in GoogleTest

While ASSERT_* macros cause termination of test case, EXPECT_* macros continue its evaluation. I would like to know which is the criteria to decide whether to use one or the other. ...

test cases for testing a strtok-alike function [C++]

Consider the following class definition: class StrToTokens { StrToTokens(const char* str, const char* delimiters = "\t\r\n"); //constructor string getNextToken(); void reset(); bool empty(); } Can someone list some good testcases to test the above class. A few I could think of are: empty string, empty delimiters, repeated del...

Unit testing that an event is raised in C#, using reflection

I want to test that setting a certain property (or more generally, executing some code) raises a certain event on my object. In that respect my problem is similar to http://stackoverflow.com/questions/248989/unit-testing-that-an-event-is-raised-in-c, but I need a lot of these tests and I hate boilerplate. So I'm looking for a more genera...

Problem Unit Testing ActiveResource Model with HttpMock

I'm working on unit testing an ActiveResource model in my Rails application. I have my ActiveResource::HttpMock code in my test file as follows: ActiveResource::HttpMock.respond_to do |mock| mock.get "/audience/42/people/1.xml", {"Authorization" => "Basic VTExbTJCTzhkZzNMOmFpdU1nbHZJT2taakdPV3A=", "Accept" => "application/xml"}, @some...

Generic test suite for ASP.NET Membership/Role/Profile/Session Providers

Hi! I've just created custom ASP.NET Membership, Role, Profile and Session State providers, and I was wondering whether there exists a test suite or something similar to test the implementation of the providers. I've checked some of the open source providers I could find (like the NauckIt.PostgreSQL provider), but neither of them contai...

No test coverage files generated for Unit Test bundle in Xcode

The Problem I've got a Cocoa project on the desktop and I'm using Xcode 3.2.1 on Snow Leopard 10.6.2. I want to generate code coverage files for my Unit Test Target in Xcode. What I've Tried As articles like this one suggest, I've adjusted the build settings to: “Generate Test Coverage Files” checked “Instrument Program Flow” checke...

Servlet unit test

Currently I'm using TestNG framework for testing application business logic, i added some Servlet classes recently. How do I unit test these Servlet classes in TestNg framework? ...

Web service unit testing

I'm using JAX-WS web services (client and exposed services), is there any API to test these web services? ...

How to write a test for accounts controller for forms authenticate

Trying to figure out how to adequately test my accounts controller. I am having problem testing the successful logon scenario. Issue 1) Am I missing any other tests.(I am testing the model validation attributes separately) Issue 2) Put_ReturnsOverviewRedirectToRouteResultIfLogonSuccessAndNoReturnUrlGiven() and Put_ReturnsRedirectResu...