unit-testing

How can one use the logging module in python with the unittest module?

I would like to use the python logging module to log all of the output from unittest so that I can incorporate it into a testing framework I am trying to write. The goal of this is to run the tests with 2 sets of output, one with simple output that tells the test case steps and a more debug level output so that when things go wrong we h...

OCUnit for iPhone App - Set all .m files as part of UnitTest Target.

Hy everybody, I have two targets: MyApp and UnitTests MyApp contains two classes: ClassA and ClassB. ClassA has a method "getSomeNumber" that uses a ClassB method. UnitTest is a "Unit Test Bundle" and in "Groups & Files" section i have a folder named "UnitTests" where i create a "MyAppTest" Class. MyAppTest Class has the following me...

Getting started with automated integration/unit testing in an existing code base

Background: We have been handed over a very large codebase (1.4 million lines) that is primarily in C#. The application consists primarily of asp.net 2.0 style asmx web services accessing data in a SQL server 2008 database and also in various XML files. There are no existing automated tests in place. We have an automated nightly build in...

Database interaction code

Hi there I'm writing a small application that works with a database and I can't figure how to test this interaction. My application relies on 5 stored procedures that I have decided to encapsulate them in a class. This class offers 5 public methods that execute the procedures and, when necessary, convert the results into collections of ...

How to unit test this ?

I've been playing around with .NET SpeechSynthesizer lately. and I've got a method that takes in a string and creates a .wav file out of that string. but how do I unit test this method ? seems to me like this situation is one in which unit testing cannot help you. am I right ? ...

TypeInitializationException when running mstest from command line

We have a subset of unit tests which until recently have always been run through Visual Studio. I am now working on a continuous integration setup which will run the tests. All of the tests pass when run through Visual Studio but when I attempt to run them from the command line using mstest they fail with a "TypeInitializationException...

Selecting an item in a combobox using HTTPUnit

Hi, I'm using HTTPUnit to test a web application where one of my pages contains a dropdown/combobox. I would like to know how to select one of the options in the dropdown, because for the life of me I can't figure it out. TIA D~ ...

PHP Unit Testing with Zend Auth and Zend ACL

I have an application that is behind a login and utilizes zend_acl and zend_auth. During pre-dispatch I have an ACL plugin that creates all the rules out for the ACL. I also have an Auth plugin that checks if you're logged in or not and if so if you have access to the requested resource according to the ACL. As the application is entir...

Grails 1.3.3: controller.redirectArgs.action not populated

Does anyone knows what happened to controller.redirectArgs.action in the latest version of Grails (1.3.3)? It used to work properly but now I get NPE when I use it. class FooController { def someRedirect = { redirect(action:"bar") } } class FooControllerTests extends grails.test.ControllerUnitTestCase { void testSom...

Python nose framework: How to stop execution upon first failure

It seems that if a testcase fails, nose will attempt to execute the next testcases. How can I make nose to abort all execution upon the first error in any testcase? I tried sys.exit() but it gave me some ugly and lengthy messages about it ...

How do I test local inner class methods in java?

In many application I often have algorithms which make use of dedicated sub-algorithms (or simply well defined pieces of code). Till now, when I wrote the main algorithm, i created a private method for each sub-algorithm like in the example below (OldStyle): public class OldStyle { public int mainAlg() { int x = subAlg01(...

Unit testing a Data Access Layer

I've been reading up on unit testing the data access layer of a project. Most options boil down to: Use a dedicated test database but cleanup in the finalizing phase of all unit tests (or do it manually) Use the database but don't commit or simply roll back Mock the database In a former project we used to use the rollback way but I l...

Visual Studio Test Project

I've created a new MVC2 project as well as a Tests project within my solution. I have not yet done anything to the default tests nor am I experienced with them. I've seen a webinar on web tests and measuring performance using Test Professional. Are these completely different? Can the Tests project inside my solution be used by Test Prof...

paperclip and functional test problems (rails)

I'm having problems with my functional tests involving paperclip and attachments. I'm using the fixture_file_upload method to fake the attachment uploads. My tests intermittently give me the error below (or one similar to it), generated by a factory_girl call to create the object containing the attachment, which is in my setup block. @...

Are there any test SMTP servers that can simulate error responses?

I have a set of Java, email related unit tests that are currently using Wiser as a test SMTP server. It works great for basic email testing (send email, check to ensure it was received, etc.), but I have logic that I would like to exercise around retrying failed email sends based on error response returned from the SMTP server. Does an...

Running symfony unit test returns "There is no open connection"

Symfony seems to have a problem opening a database connection while running unit test. I have my test env specified in config/databases.yml: all: doctrine: class: sfDoctrineDatabase param: dsn: 'mysql:host=localhost;dbname=ms' username: ms password: xxx test: doctrine: class: sfDoctrineDatabase par...

Writing Unit Tests in ASP.Net MVC with Code-First and EF4 and SQL CE4

Hi All I've been reading Scott Gu's post on code first design with ASP.Net MVC 2.0 and EF4 here: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx In the post he uses the SQL CE4 database for development and 'seeds' test data. My question is related to testing. It is widely regar...

Testing Paperclip file uploading with RSpec

I don't really care about testing file uploads, but since I have validates_attachment_presence, etc.. in my model, rspec is complaining. So now I'm creating my model with these attributes in the spec to try and shut it up: @attr = { :name => "value for name", :title => "value for title", :content => "value for content", :pic_fi...

Do you use constants from the implementation in your test cases?

Let's say you have some code like this (in a made-up langague, since it does not matter for this question): constant float PI = 3.14; float getPi() { return PI; } Would you test it like this: testPiIs3point14() { // Test using literal in test case AssertEquals( getPi(), 3.14 ); } Or like this: testPiIs3Point14() { //...

Unit testing concurrent software - what do you do?

As software gets more and more concurrent, how do you handle testing the core behaviour of the type with your unit tests (not the parallel behaviour, just the core behaviour)? In the good old days, you had a type, you called it, and you checked either what it returned and/or what other things it called. Nowadays, you call a method and ...