unit-testing

TDD with unclear requirements

Hello! I know that TDD helps a lot and I like this method of development when you first create a test and then implement the functionality. It is very clear and correct way. But due to some flavour of my projects it often happens that when I start to develop some module I know very little about what I want and how it will look at the e...

Unit testing in CakePHP?

I'm wondering, how do you guys unit-test in CakePHP? How do you incorporate tests in projects? What parts of a project do you test? How do you decide which parts gets to be unit-tested? Do you guys still get to finish the job before the deadline? I'd really appreciate your answers. Thanks in advance! ...

Rails Foxy Fixtures throwing unknown column error

I am using dynamic fixtures and whenever I run my tests I am getting an error that thinks my association is a column, when it should be owner_id: ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'owner' in 'field list': INSERT INTO `companies` (`custom_host`, `name`, `created_at`, `updated_at`, `api_key`, `id`, `subdomain`, ...

testing and establish_connection

Hi, could you tell me plz - how to write tests for projects, which uses in model establish_connection to connect another database? ...

PHP Unit testing

Is there any EASY php testing Framework and may be simpler than simpletest and not command line based like PHPUnit ? ...

ASP.NET MVC - test the controller returning different views depending on action method logic

Hi, my controller can return different views depending on action method logic. Action method 'Create' asks service to do some validation and persistence. If validation fails, action method returns same 'Create' view. If validation and save runs OK, action method returns 'Index' view (RedirectToAction). I know that getting view name is po...

C#: How to test that an expression is short-circuited

I have an extension method with the following signature: public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second) { ... } I have written a test-case for it that makes sure the two expressions are in fact combined. At least so that the new expression I get works. Now I ...

asp.net mvc and linq to entities: how to test model custom binding?

I'm trying to build a test for my custom model binder, but not having any success. The call to base.BindModel always returns a null. Is there a way to test custom binding when using LINQ to Entities? foo in this case is a table in the db with two fields - a numeric and a text value. fooBinder.cs: public override Object BindModel(Con...

Hamcrest's lessThan doesn't compile

Trying to compile this code import static org.hamcrest.Matchers.is; import static org.hamcrest.number.OrderingComparison.lessThan; ... Assert.assertThat(0, is(lessThan(1))); issues this compilation error: assertThat(Object, org.hamcrest.Matcher<java.lang.Object>) cannot be applied to (int, org.hamcrest.Matcher<capture<? su...

Data-driven tests with jUnit

What do you use for writing data-driven tests in jUnit? (My definition of) a data-driven test is a test that reads data from some external source (file, database, ...), executes one test per line/file/whatever, and displays the results in a test runner as if you had separate tests - the result of each run is displayed separately, not in...

Fluent NHibernate - unit-testing a one-to-many *inverse* mapping

I can't figure out how (or if it's at all possible) to use the Fluent NHibernate PersistenceSpecification<T>.CheckList(...) method to check an inverse one-to-many mapping. Here's what I'm trying to do: Using fluent nhibernate on a vanilla blog/post example, I have defined a one-to-many blog<->posts mapping. One restriction I want is th...

Sample domains for testing DNS lookups

Are there any well known addresses that can be resolved to well known IP addresses, preferably for both IPv4 and IPv6? I'm playing with Berkeley Sockets and have written a class to encapsulate away the sockaddr_in stuff, and want to unit test it but don't know of any addresses that I can put in as test data that are guaranteed to resolv...

Unit test sequence when running all tests in solution

In a complex VS2008 solution I have three unit test projects. As they operate on the same test database it is important that the test projects are executed one after the other. It is not important which project first, just that one is finished before the other starts. If I want to execute them all, there are several ways to do that, wh...

How do I factor code to ease testability?

I am learning about Unit Testing and want to know how to write testable code. But, I'm not sure how to write testable code without making it complex. I'll take famous Car and Engine problem to describe the problem. class Car { private: Engine m_engine; public: Car(); // Rest of the car } I came up with following solutions to...

Viewing LCOV file in Windows

Hi all: Background: I have used JsTestDriverCoverage and generated a test coverage report for my Javascript unit tests. However it is in LCOV format. As a Windows user running on Windows 2003, I can't just read the file since its perl/lunix friendly. Question: are there any ways to either convert the file to a more readable format (u...

partial argument match in rhino mocks

Hi, In my unit test instead of IgnoreArguments i want to use some partial matching of arguments in rhino mocks testing. How to do that? Thanks, John ...

String comparison in Ruby on Rails unit-test

Hi, my Ruby On Rails unit-test fails in a simple string comparison and I can't figure out why. In the model TestItem, I have doc = REXML::Document.new(data) @bugtitle = doc.root.get_text("/bugzilla/bug/short_desc") where data is a xml-string returned by a Net::HTTP::post request. The data looks good, and if I output @bugtitle it cont...

How to test with easymock Capture

I have the following code Record rd = registerNewRecord(); <do some processing> rd.setFinished(true); updateRecord(rd); The registerNewRecord method calls the RecordDao insert method, and updateRecord calls the update method on the same DAO. I have the following easymock code: Capture<Record> insertRc = new Capture<Record>(); Record...

Moq'ing the raising of events multiple times

In a particular unit test I'm trying to raise an event multiple times and then to veryify a property value after the final event has been raised. I have something like public void TurnRight() { var mockFoo = new Mock<IFoo>(); SomeService someService= new SomeService (); someService.Foo= mockFoo.Object; mockFoo.Raise(foo=> ...

How to include unit tests in a ruby module ?

I'm trying to include the unit tests for a module in the same source file as the module itself, following the Perl modulino model. #! /usr/bin/env ruby require 'test/unit' module Modulino def modulino_function return 0 end end class ModulinoTest < Test::Unit::TestCase include Modulino def test_modulino_functio...