unit-testing

My class constants are nil in the 'test' environment

In a class called 'Quality' I have the following constants defined: class Quality < ActiveRecord::Base [validations excluded in this example] NEW = Quality.find_by_name("New") LGT = Quality.find_by_name("Light use") MED = Quality.find_by_name("Medium use") HVY = Quality.find_by_name("Heavy use") SCR = Quality.find_by_name(...

JSpec vs Jasmine vs QUnit for javascript and jQuery testing in Rails

I am looking for a unit testing framework to use with javascript that integrates well with Rails 3.0 Anyone with experience with above frameworks can share their experience? ** UPDATE: JSpec is now discontinued as per their Github repository: http://github.com/visionmedia/jspec so this leaves Jasmine and QUnit ...

lime vs phpunit

I don't see this answered any where on the web, amazingly. Unit tests in lime seem so much more simple to write than PHPUnit with all its extra boilerplate code. Are there any definitive reasons (besides "PHPUnit is the defacto standard") for choosing one over the other? ...

WPF - XamlParseException when unit testing method in Window class

I'm trying to use MSTest to write unit tests for methods in my MainWindow class in my WPF application. However, I get the following exception: System.Windows.Markup.XamlParseException: 'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '127' and line position '32'. ---> System.Exception: Cann...

TFS Check-in Policty for Unit Tests

Is it possible to enforce that every check-in to TFS has an associated unit test with it? Even if the associated unit test is just a shell? I don't want to allow code to be checked in without the code first having an associated unit test class. I am using TFS 2010 ...

How to unit testing EJBs when using JPA2?

How would you go about unit testing an EJB that uses JPA? For example, if I have an Order entity and and OrderEJB that is supposed to calculate the total of an order (as defined below) how would I go about unit testing the EJB without touching the database? Also, how would you define values for your entities, so you can assert the expect...

Designing a robust unit test - testing the same logic in several different ways?

Hi, In unit test design, it is very easy to fall into the trap of actually just calling your implementation logic. For example, if testing an array of ints which should all be two higher than the other (2, 4, 6, 8, etc), is it really enough to get the return value from the method and assert that this pattern is the case? Am I missing...

Turbogears2 and py.test

I'm switching our testing environment from Nose to py.test for testing a Turbogears2 web application. Currently, when Nose runs it gathers information from a testing configuration file (test.ini) that holds all the testing variables the application needs. And it seems to do so in an automatic way (I'm simply running nosetests and everyt...

TDD for Ant Script Development

I have been handed a complex set of Ant scripts for feature additions and maintenance. No test framework whatsoever has been used for developing those in the past. I want to start developing the new features inside tests. The scripts use a mix of ant, ant contrib and custom made tasks, I am not going to be adding any new tasks, just scri...

Parameterized testing tools with automatic code exploration

I've checked and played a bit with Microsoft Pex. It's a very handy tool/library even though it's not as straight forward to write parametrized unit tests with it. But when used correctly it can provide much better test code coverage than writing manual unit tests. Not to mention time spent writing those tests either. And it integrates n...

If using LINQ For Queries, Do We Need to Unit-Test Sorting?

Hi Guys, I have the following two methods on an interface for my service layer: ICollection<T> FindAll<T>(Expression<Func<T, bool>> predicate) where T : Post; ICollection<T> FindAll<T,TKey>(Expression<Func<T, bool>> predicate, OrderingOptions<T,TKey> orderingOptions) where T : Post; They are extremely similar. The first one (basica...

unit testing a python function which invokes a vim subprocess

I've written a function which opens a vim editor with the given filename when called.. How can I do the unittest of these types of operations.... ...

testing securityConfig mapping in grails + acegi

Hi, I'm kinda lost. I'm writing test cases for a project which still uses the Acegi plugin (not the newer Spring Core Security plugin) and as of now, I've managed to do what this site (http://www.zorched.net/2008/09/01/grails-testing-acegi-security/) has suggested regarding the detection of which user is currently logged in. However, i...

Use SMS Emulator from Android Test Case

I want to automate functional testing of my code which works with SMS. I know, that I can use send sms command and sms will be sent to emulator instance. The question is how can I execute send sms command programmatically from my test case, so I can run test without manual intervention? ...

Cakephp - Testing Components - cannot find component

Hi, I am writing a component test in cakephp here is my code <?php class PermissionTestCase extends CakeTestCase { var $fixtures = array('Org'); function testsetPermission() { $this->PermissionComponentTest = new PermissionComponent(); <---- line 5 I get this error - Fatal error: Class 'PermissionComponent' not foun...

Generating two objects in one form. How to validate both are present?

I have a form for @profile (controller = profile#new). Inside this form are nested fields for generating an @user (I'm using Devise for user authentification). If a profile were to be generated without a user this causes lots of issues in the system so I want to set up a validation ensuring that a profile cannot be created without a u...

PHPUnit: assert two arrays are equal, but order of elements not important

What is a good way to assert that two arrays of objects are equal, when the order of the elements in the array is unimportant, or even subject to change? ...

Parallel testing with Selenium Grid (using C# unit tests)

Following AutomatedTesters response: Is there any way to run parrallel tests with C# code, without using class libraries other than the Selenium Core? I have the following setup: Selenium Grid Hub: 192.168.0.1 Selenium RC 1 : 192.168.0.2 Selenium RC 2 : 192.168.0.3 Both remote controls are running *firefox. If only 1 of the remote c...

Useful design patterns for unit testing/TDD?

Reading this question has helped me solidify some of the problems I've always had with unit-testing, TDD, et al. Since coming across the TDD approach to development I knew that it was the right path to follow. Reading various tutorials helped me understand how to make a start, but they have always been very simplistic - not really somet...

Options for full stack testing in Ruby on Rails

There are quite a number of options for Full-Stack testing of Rails applications. Some use real browsers, some are headless, some don't run javascript at all. Which tools do you use or recommend and why? List of browser simulators or automators: Rails built-in support for integration and functional tests (no JS) Webrat Webrat::selen...