TAG | Test Driven Development
20
Do unit tests matter to product managers?
No comments · Posted by Christian in Product development
Imagine you’re a business owner. You know what you want to get developed, you have the budget for it and you know when you need to see a result. You have someone to manage your development team (call him the product owner if you like) and the team seems skilled.
Now what do you need unit tests for?
Actually I started this blog a long time ago only to teach myself test driven development – hence the name. I know all the good reasons why I should’ve written unit tests first.
However I soon discovered that unit testing simply didn’t work out for me.
14
Behaviour Driven Development for PHP with Behat
1 Comment · Posted by Christian in The right tool
I am currently working on ImageTransform an image manipulation library based loosely on Stuart Lowes sfImageTransformPlugin for symfony.
As I started from scratch I made sure to write unit tests of course and it helped me a great deal so far. But as testing goes unit tests are not the silver bullet. They ensure that each unit works as expected but they can not verify if your use cases are implemented correctly. For that you need functional tests.
Writing a library however means that there is no web interface so tests with Selenium or other web centric tools don’t apply.
Behat · Behaviour Driven Development · Functional Tests · Test Driven Development
What I called my “little experience” during the last two days is actually the attempt to rewrite the image manipulation library ImageTransform by Stuart Lowes, which itself is the attempt to turn the symfony plugin sfImageTransformPlugin into a standalone library (unfinished). It’s not at all official and it might be binned again at some point. Until I know that it stays my personal toy.
One of the goals I set myself is to make the code as decoupled as possible and to prove that I try to maintain a high unit test coverage.
Today I just wrote my first transformation using this new architecture and it was just perfect to do it test driven: the resize transformation. (more…)
ImageTransfrom · PHP · phpUnit · Refactoring · Separation of Concerns · TDD · Test Driven Development · Unit Tests
10
Productivity gain when PHPUnit testing decoupled code
1 Comment · Posted by Christian in Good to know

Over the weekend I started writing some code just to try out a few ideas. Over the last four years I have been writing a lot of code but best of it was related to symfony. So this was a nice situation to start something from scratch.
Of course I experienced a lot during the past and also did I learn a lot from participating – actively and passively – in the symfony community. The most important fact I learned is that the key principle of programming that decides about if your code gets manageable is: Separation of Concerns.
And with my small experiment I also learned that following it reduces the time you spend writing unit tests! (more…)
dependency injection · phpUnit · Separation of Concerns · symfony · Test Driven Development · Unit Tests
24
[Question] How can you develop test driven when you don’t know where you’re going in the first place?
11 Comments · Posted by Christian in Question
I’ve got this one question puzzling me for quite some time now and I got to get it off my chest.
An just to make sure there are no misunderstandings: I am not about to question TDD!
I am merely asking for help to find my way to do it properly..
best practice · Functional Tests · Integrations Tests · Refactoring · TD · Test Driven Development · Tests · Unit Tests
31
Testgetriebene Entwicklung (TDD) einer Funktion meines symfony Plugins
2 Comments · Posted by Christian in The real job
Wie ihr gemerkt habe, brauchte ich heute morgen etwas länger für meinen Blogpost. Der Grund ist, dass ich endlich eine Lösung präsentieren wollte für die Anforderung, für die ich noch keine Idee hatte.
Rüdiger und Daniel haben mich korrekterweise darauf hingewiesen, dass keine Lösung schlechter ist, als eine unelegante.
Das wollte ich nicht auf mir sitzen lassen und habe nach einem Weg gesucht.
Da ich die Anforderungen ziemlich genau benennen konnte, war ich auch in der Lage, sie als Unit Test zu formulieren und somit konnte ich Testgetrieben entwickeln (Test Driven Development, TDD).
Witzigerweise bin ich mit dem Ergebnis sogar so zufrieden, dass ich es als (vorerst) elgante Lösung bezeichnen würde.
phpUnit · Refactoring · sfImageTransformExtraPlugin · symfony · Test Driven Development · Unit Tests
Nachdem ich seit gestern nun einigermassen mit Tests ausgestattet bin, will ich mich heute ans Refactoring machen.
Eine Methode ist mir da besonders im Sinn, die ich als zu gross und zu prozedural empfinde. Sie macht einfach zu viel, was besser in mehreren kleinen Methoden erledigt werden sollte.
Ausserdem habe ich noch zwei Methoden in derselben Klasse, die da nun wirklich nicht hingehören.
phpUnit · Refactoring · symfony · Test Driven Development · Tests · Unit Tests
8
Neues Feature, neue Tests, neue Erfahrungen
No comments · Posted by Christian in The real job
Ich bin am Wochenende wenigstens ein paar Stunden aktiv gewesen und habe meinem kleinen Projekt ein neues Feature hinzugefügt.
Mit dem sfImageTransformExtraPlugin erweitere ich das bereits existierende symfony Plugin sfImageTransformPlugin um einen Konfigurations Layer sowie die Möglichkeit, einen Webservice für Thumbnail Generierung zu betreiben. Ich werde das Ganze in Kürze auch auf der symfony Website als Open Source Plugin zur Verfügung stellen, bis dahin möchte ich aber eine bessere Testabdeckung erreichen.
Und genau da bin ich jetzt gerade bei und sammel mal wieder eine Menge kleine Erkenntnisse.
Continuous Integration · phpUnit · sfImageTransformExtraPlugin · symfony · Test Driven Development · Tests · Unit Tests
Letzte Woche hatte ich ja kurz vom ObjektForum Nord berichtet und von dem Tool Fitnesse, welches es erlaubt Akzeptanz Tests (Functional Tests) in Wikiform zu schreiben.

Die Vorteile sind klar:
- Der Kunde oder Produkt Owner wird ohne technische Knowhow in die Lage versetzt, Akzeptanz Tests zu seinen User Stories zu schreiben.
- Solche Akzeptanz Tests sind sprachlich leicht verständlich und dennoch technisch exakt genug, um für ein gemeinsames Verständnis zwischen Anforderungs- und Umsetzungsseite zu sorgen.
- Da diese Form der Akzeptanz Tests nicht auf eine bereits vorhandene Implementation angewiesen ist, kann das gemeinsame Verständnis zum frühest möglichen Zeitpunkt erfolgen.
- Dieses Timing wiederum begünstigt Test getriebene Entwicklung (TDD).
Klingt alles hervorragend. Wir müssen nur zwei Dinge tun..
Functional Tests · symfony · Test Driven Development · Tests


