unit-testing

Ruby on Rails Single Table Inheritance (STI) and unit test problem (with PostgreSQL)

I'm using an STI model with a single "Accounts" table to hold information for Users and Technicians (i.e. User < Account, Technician < Account). Everything works from a functional perspective, but things explode when running unit tests: ... 8) Error: test_the_truth(UserTest): ActiveRecord::StatementInvalid: PGError: ERROR: relation "t...

Python - test that succeeds when exception is not raised

I know about unittest Python module. I know about assertRaises() method of TestCase class. I would like to write a test that succeeds when an exception is not raised. Any hints please? ...

How do I unit test private functions from a separate project in VB .NET?

As I develop code, I often want to unit test some of the building blocks of a class even if they are normally private. If my unit tests are inside the project, I can use "Friend" to accomplish this and still keep the functions private for normal use. But I would rather move my NUnit tests into their own separate project(s). How do I achi...

Standard Output from MSTest, NUnit, MbUnit, xUnit.NET test runners

How do you in any of the common .NET testing frameworks MSTest, NUnit, MbUnit, or xUnit.NET get the command line test runner to output a simple yes/no or true/false or 1/0 on whether all the tests passed or failed? I'm open to workarounds like: 1) no output if all the tests passed, output if anything fails. 2) count of tests that fail...

ASP.NET MVC - Mock a Form Request

I’m just learning ASP.NET MVC and I’m trying to create a mock form request for a unit test. I’m using RhinoMocks. I have looked at the following websites but cannot get these to work. http://blog.maartenballiauw.be/post/2008/03/19/ASPNET-MVC-Testing-issues-Q-and-A.aspx Update: Controller Code: /// <summary> /// Creates a ne...

Mocking using 'traditional' Record/Replay vs Moq model

I'm new to mocks and am deciding on a mock framework. The Moq home quotes Currently, it's the only mocking library that goes against the generalized and somewhat unintuitive (especially for novices) Record/Reply approach from all other frameworks. Can anyone explain simply what the Record/Replay approach is and how Moq diff...

VS2008 Unit tests failed when you select Test- Debug- All Tests in Solution

in Debug mode the tests which throw a custom exception give an error message like Exception of type 'CustomProductException' was thrown instead of 'CustomProductException' Fail.But when I choose Test - Run - All Tests in Solution rather than Debug, all Tests pass.Why is this happening? Any pointers... ...

How to Unit Test an Implementation of IDictionary

When implementing something that implements IDictionary, what should I unit test? It seems to be overkill to test the entire interface, but then what do I know? I have only been unit testing for a few days... ...

What is unit testing and how do you do it?

Exact duplicate of many posts: What is unit testing? What Makes a Good Unit Test? New to Unit Testing Unit Testing - definitions Learning Unit Testing How to properly mock and unit test Unit Testing: Beginner Questions And many more ... Also, Google for site:stackoverflow.com "how do you" unit-test I have read some questions on...

Zend Framework: Getting started with Zend_Test

Has anyone had any success setting up Zend_Test? What was your method/approach and how do you run your tests/test suites? I already have PHPUnit installed and working. Now I'm trying to write some simple controller tests. The Zend Framework documentation assumes that autoloading is setup, which I haven't done. What method do you use to ...

Keep your Source Close and your Unit Tests Closer

When I first started using unit tests I encountered two problems. First was being able to test private methods and fields and second falling behind on keeping unit tests up to date when rapid development was taking place. Consequently I adopted the approach below for my unit tests. #if UNITTEST using NUnit.Framework; #endif public clas...

Running Dijit robot tests in DOH runner

I am using dijit robotx and using doh.robot.initRobot(myAppUrl) within my test page to run tests against my actual app. I load this page up in DOH runner. It is working except after a really short amount of time, it gives me a timeout error. I ensured my timeouts for the tests were long, but it still happens. Is there some special timeou...

Strange dll error message.

For about 2 weeks now, I have been unable to run any UnitTests (built in VS unit tests) for a project. Previously everything worked fine. The error message is: Could not load file or assembly 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\MyProjectName.XmlSerializers.dll" or one of its dependencies. The p...

Unit Testing Code that calls VirtualPathUtility.ToAbsolute

I'm trying to unit test some code that calls into VirtualPathUtility.ToAbsolute Is this possible with the unit testing tools provided with VS 2008. ...

Are there any good Unit Test frameworks for Ada?

I come from a C++ background, but I'm currently working in Ada. In the C++ world, I unit test every class as I write it... this doesn't seem to be the vogue for our codebase here at work. I'd like to start implementing unit tests for the Ada packages I create, are there any good frameworks out there that do this? ...

Unit tests & lengthy setup strings: Style / Best Practice

I'm interested in the opinion, practices and reccommended best practices of using lengthy setup strings in unit tests. Do you prefer to declare the tests in-line, close to your test, or externalize in a file somewhere? Note, I'm talking about test assets which are specific to a single unit test, so not neccessarily suitable for living ...

Refactoring and Test Driven Development

I'm Currently reading two excellent books "Working Effectively with Legacy Code" and "Clean Code". They are making me think about the way I write and work with code in completely new ways but one theme that is common among them is test driven development and the idea of smothering everything with tests and having tests in place before ...

ASP.NET MVC – Mock Membership for Controller Test

I’m not sure how to mock an ASP.NET Membership for my controller test. Controller Code: MembershipUser username = Membership.GetUser(); string UserID = username.UserName.ToString(); Does anyone know how to mock this for a controller test? I'm using RhinoMocks. ...

Where could I find some code examples about Integration Testing

I have methods that interact with DB and external files. I need to write integration tests, however I am not sure how to. Do you know where I can find some source codes about integration testing with Database or External File? If you write a test method that tests a production method in which there are calls to other methods, is this a...

Testing When Correctness is Poorly Defined?

I generally try to use unit tests for any code that has easily defined correct behavior given some reasonably small, well-defined set of inputs. This works quite well for catching bugs, and I do it all the time in my personal library of generic functions. However, a lot of the code I write is data mining code that basically looks for...