unit-testing

CodeIgniter and SimpleTest -- How to make my first test?

I'm used to web development using LAMP, PHP5, MySQL plus NetBeans with Xdebug. Now I want to improve my development, by learning how to use (A) proper testing and (B) a framework. So I have set up CodeIgniter, SimpleTest and the easy Xdebug add-in for Firefox. This is great fun because maroonbytes provided me with clear instructions a...

How to map a test onto a list of numbers

I have a function with a bug: user> (-> 42 int-to-bytes bytes-to-int) 42 user> (-> 128 int-to-bytes bytes-to-int) -128 user> looks like I need to handle overflow when converting back... Better write a test to make sure this never happens again. This project is using clojure.contrib.test-is so i write: (deftest int-to-bytes-to-int ...

Unit testing a controller method?

I have a controller method like such: def search = { def query = params.query ... render results as JSON } How do I unit test this? Specifically, how do I call search to set params.query, and how do I test the results of the method render? Is there a way to mock the render method, perhaps? ...

Write unit tests that test for failure?

Let’s say I have a function that accepts a user name and password, it then retrieves the record from a database and performs the following checks on that data Today’s date is outside a date range User is disabled A parameter comparison is made If any of these conditions are true an exception is thrown. Obviously I want to write my u...

django: unit testing html tags from response and sessions

Is there a way to test the html from the response of: response = self.client.get('/user/login/') I want a detailed check like input ids, and other attributes. Also, how about sessions that has been set? is it possible to check their values in the test? ...

Unit Testing User Interface. What is an effective way ?

I have an accounting & payroll client/server application where there are several input form with complex data validation rules. I am finding an effective way to perform unit testing of user interface. For complex validation rules I mean: "Disable button X if I Insert a value in textfield Y" "Enable a combobox if I insert a value in a...

MEF and unit testing with NUnit

A few weeks ago I jumped on the MEF (ComponentModel) bandwagon, and am now using it for a lot of my plugins and also shared libraries. Overall, it's been great aside from the frequent mistakes on my part, which result in frustrating debugging sessions. Anyhow, my app has been running great, but my MEF-related code changes have caused m...

Why can't I test Data Annotations in Silverlight 4 DLL within a normal unit test project?

Here's the setup: A Silverlight DLL containing some very basic class definitions. These classes have DataAnnotations via System.ComponentModel.DataAnnotations A "normal" C# unit test library. It references the Silverlight DLL via its binary - not via its project. (And yes, I always rebuild the silverlight DLL manually before running...

How do I use a profiler?

Very often I hear: use a profiler and unit test. How do I do that? I would be glad if someone would provide either links to websites with tutorials or recommend a good book. I'm using Visual Studio 2010 Ultimate. ...

Multiple arrangements/asserts per unit test?

A group of us (.NET developers) are talking unit testing. Not any one framework (we've hit on MSpec, NUint, MSTest, RhinoMocks, TypeMock, etc) -- we're just talking generally. We see lots of syntax that forces a distinct unit test per scenario, but we don't see an avenue to re-using one unit test with various inputs or scenarios. Also...

Unit testing class in a web service in .net

After some digging here, I took the advice in this thread: http://stackoverflow.com/questions/371961/how-to-unit-test-c-web-service-with-visual-studio-2008 I've created a separate class and my web service class is just a wrapper for that one. The problem is that when I try to create a unit test project in VS2008, it insists on creating ...

Help! Sikuli unit test can not run

Hello, I couldn't run any unit tests either in the window xp? The IDE is functional. I write the simple example unit test script in the editor, as follow: def testHelloWorld(self): print("Hello World!") but no test shows up in the unit test window. When clicking the Run button of the Unit test pane, nothing happens, and the IDE w...

Write a funtion based on given TestUnit

I need to write a function to satisfy this input -> output list: 0 -> 0 1 -> 1 3 -> 2 4 -> 3 5 -> 5 7 -> 13 9 -> 34 f(x) = ?? ...

Unit testing an IExtension<OperationContext> for use with WCF Service

I'm trying to develop a extension (IExtension<OperationContext>) for System.ServiceModel.ObjectContext using TDD. The extension is to be used as storage for a lifetime manager to be used with Windsor Castle. The problem lies in abstracting (mocking) the OperationContext. As it is a static object that gets automatically created during ru...

nhibernate error recovery

I downloaded Rhino Security today and started going through some of the tests. Several that run perfectly in isolation start getting errors after one that purposely raises an exception runs though. Here is that test: [Test] public void EntitiesGroup_IfDuplicateName_Error() { _authorizationRepository.CreateEntitiesGroup("...

Date relative to current in the DBUnit dataset

I'm wondering if there is any way to specify for example tomorrow as date in the DBUnit XML dataset. Sometimes code logic is different for dates in future and dates in the past and I want to test both cases. For sure I can specify something like the 5th of November 2239 and be sure that test will work till this date but are there more el...

How can I make the "internal" classes and members of a .NET assembly visible to IronRuby code?

My scenario consists of the following points. I have a packaged software product I am developing in C# Since it is a packaged product, the public interfaces of the assemblies need to be tightly controlled... All assemblies are strong-named Any classes that don't absolutely have to be "public" are "internal" I want to write unit tests...

Unit testing a SQL code generator

The team I'm on is currently writing code in TSQL to generate TSQL code that will be saved as scripts and later run. We're having a little difficulty in separating our unit tests between testing the code generator parts and testing the actual code that they generate. I've read through another similar question, but I was hoping to get so...

Best way to test instance methods without running __init__

I've got a simple class that gets most of its arguments via init, which also runs a variety of private methods that do most of the work. Output is available either through access to object variables or public methods. Here's the problem - I'd like my unittest framework to directly call the private methods called by init with different ...

What is the most idiomatic way to emulating Perl's Test::More::done_testing?

I have to build unit tests for in environment with a very old version of Test::More (perl5.8 with $Test::More::VERSION being '0.80') which predates the addition of done_testing(). Upgrading to newer Test::More is out of the question for practical reasons. And I am trying to avoid using no_tests - it's generally a bad idea not catching w...