Haku

Test-driven development

QR-koodi

Test-driven development

In this thesis, a literature survey of TDD, and an evaluation of two different unit test frameworks for standard C++ was done.

The theoretical part examined test-driven development (TDD) from a developer’s point of view with the objective to learn how the method works in practice and what difficulties there are to adopt it. The approach is to write the test before the code to be tested. The programmer writes the test and is using a unit test framework. It appeared that tests are written and executed frequently. Adaptation of the method proved to be difficult, since it is radically different from the traditional methods, where tests are written after the implementation.

In the practical part of the thesis two unit test frameworks for standard C++ was evaluated, CppUnit and Boost.Test. The learning from the theoretical part formulated the evaluation criteria to contain minimal amount of steps to add new tests and easy test execution. xUnit is an architecture description of unit test frameworks, which is implemented in most modern programming languages. In the evaluation it appeared that the evaluated framework that implements the xUnit architecture is not optimal for C++.

I detta slutarbete gjordes en litteraturstudie av testdriven utveckling (TDU) och en utvärdering av två olika testramverk för standard C++.

Den teoretiska delen undersökte testdriven utveckling (TDU) från en programmerares synvinkel med målet att lära sig hur metoden fungerar i praktiken och vilka svårigheter det finns att anamma den. Metoden går ut på att testen skrivs innan koden som ska testas. Programmeraren skriver testerna och har till sin hjälp ett testramverk. Det framkom att man frekvent skriver nya tester och att de körs ofta. Att anamma metoden är svårt eftersom den skiljer sig radikalt från de traditionella metoderna, där testerna skrivs efter implementationen.

I den praktiska delen av slutarbetet utvärderades två testramverk för standard C++, CppUnit och Boost.Test. Kunskaperna från den teoretiska delen användes till att skapa utvärderingskriterierna. De fokuserar på att det skall vara så enkelt som möjligt att lägga till nya test samt att de skall vara enkla att köra. xUnit är en arkitekturbeskrivning för testramverk som implementerats till de flesta moderna programmeringsspråken. Evalueringen visade att testramverket som implementerade xUnit arkitekturen inte är optimalt för C++.

Tallennettuna: