Posts Tagged ‘mocha’

Bug fighting with Test Driven Development Follow-Up

Sunday, February 8th, 2009 by Thilo Utke

On Thursday I gave a talk about Bug fighting with TDD and how it will help you to write better software at the Ruby User Group in Berlin. Sorry, I won’t put the slides online, although people asked about it. I think they are a pretty useless collection of keywords and pictures without the talking. Instead I like to provide a collection of links to dive into the whole testing matters.

First a collection of tools you can choose from for various testing scenarios. They all have their pros and cons, it just comes down to which will do the job best for you.

Tools for Unit Testing

Tools for Mocking

Tools for Acceptance Testing

Tools to generate test objects

Misc tools

To save you the initial searching where to start, I collected some links where you find basic information about testing in general or with certain tools.

Getting started

For everyone who wants to get more into the subject, I drilled down my feed reader to collect some interesting blog posts on testing matters.

Opinions and In-sign

So much for my two cents to make the software world better.

Does your company need help with software testing? We can help: check out our new product Scene Investigation.

mocha Präsentation

Thursday, September 6th, 2007 by Thilo Utke

Hier wie versprochen die Slides meiner Presentation zum Thema mocha bei der Ruby User Group Berlin.

Links:

Mocha
Floehopper (Blog des Mocha Entwicklers)
Presentation about Ruby Mocks
TestingRails Blog (gelöscht :( )
Use stubs and mocks to convey intent
Ruby: Mocks and Stubs using Mocha

Using Mocha – A review

Wednesday, August 1st, 2007 by Thilo Utke

For aprox. 3 months we have been using mocha now. And we promised to get back to this subject when we passed our 2000th revision.

In this post I’d like to share some expirence we made while using mocha. But first a short introduction to mocha taken from the rubyforge page.

Mocha is a library for mocking and stubbing using a syntax like that of JMock, and SchMock. One of its main advantages is that it allows you to mock and stub methods on real (non-mock) classes and instances.

We started to use mocha on an existing test suite and changed our test code in place when we wrote a new test or had to update old ones. The transition was mostly painless, there were three things where we stumbled.
(more…)

Wir machen unseren Tests Beine

Friday, March 30th, 2007 by Thilo Utke

Da unsere vielen Tests mittlerweile ein wenig lange brauchen, haben wir uns am heutigen Forschungstag mal wieder mit dem Problem Testing auseinandergesetzt. Das Ergebniss diesmal schon vorne weg: unsere erfolgreichste Entdeckung ist Mocha.
Mit diesem Framework lassen sich Stubs und Mocks mit realen Objekten verwenden. Es folgt ein kleiner Auszug aus unserem bisherigen Testcode.

def create_activated_user(attributes = {})
email = generate_email_address
User.create!({:gender => ‘m’, :first_name => ‘joe’, :last_name => ‘doe’, :email => email,
:password => ‘test’, :password_confirmation => ‘test’, :city => “berlin”, :status => ‘active’
}.merge(attributes))
end

def create_auto(user = nil, attributes = {})
user = create_user unless user
Auto.create!(auto_hash(user).merge(attributes))
end

def test_activity_returns35_for_user_with_picture_and_auto_with_picture
user = create_activated_user :photo => ‘1.gif’
create_auto user, :photo => ‘2.gif’
assert_equal(35, user.activity)
end

Dauer: 795ms

Nach kurzem Studium des Mocha Cheat Sheets haben wir dann den Test wie folgt geändert.

def test_activity_return35_for_user_with_picture_and_auto_with_picture
with_photos = stub :with_photos => [Auto.new(:photo =>'test.gif')]
user = User.new :photo => ‘1.gif’
user.stubs(:autos).returns(with_photos)
assert_equal(35, user.activity)
end

Dauer: 49ms

Na wenn das keine signifikate Verbesserung ist. Auf Mocha gestoßen sind wir über den Testing Rails Blog, auf dem leider nichts Neues mehr zu passieren scheint. Eine kleine Übersicht von Stub-Frameworks mit problemspezifischen Einschätzungen fanden wir auf dem Blog von Jay Fields.

Wir werden Mocha in der nächsten Zeit in unseren Test integrieren, und bei der 2000ten Revision sagen wir euch wie lange unsere Test Suite läuft.