Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test...
Transcript of Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test...
![Page 1: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/1.jpg)
Unit Testing is like cooking!(you‘ll see!)
Mario Rimann TYPO3 Developer Days 2008
![Page 2: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/2.jpg)
![Page 3: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/3.jpg)
How?
Why?
Then?
![Page 4: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/4.jpg)
How?
Why?
Then?
![Page 5: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/5.jpg)
Managing complexity
![Page 6: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/6.jpg)
Managing complexity
![Page 7: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/7.jpg)
Avoiding chain reactions
![Page 8: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/8.jpg)
Regression
![Page 9: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/9.jpg)
Saving time
??
?
?
![Page 10: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/10.jpg)
Improving structure
![Page 11: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/11.jpg)
Improving structure
![Page 12: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/12.jpg)
How?
Why?
Then?
![Page 13: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/13.jpg)
Unit Testing is like cooking!
Classes to test
TestcasesEnvironmentfor Testing
Fixtures
Testing Framework
![Page 14: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/14.jpg)
PHPUnit≠
tx_phpunit... but somehow similar
LiveDemo
![Page 15: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/15.jpg)
A simple class:
class superMathematics {
static function add($a, $b) { return $a + $b; }
}
![Page 16: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/16.jpg)
A small Test Case:class superMathematics_testcase extends PHPUnit_testcase {
public function testAdd() { $this->assertEquals( 12, superMathematics::addition(5, 7) ); }}
![Page 17: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/17.jpg)
A more complex class:class tx_seminars_place extends tx_seminars_objectfromdb {
function getCity() { return $this->getRecordPropertyString('city'); }
function getCountryIsoCode() { return $this->getRecordPropertyString('country'); }}
![Page 18: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/18.jpg)
Fixtures are like spices private $fixture;
public function setUp() { $uid = $this->testingFramework->createRecord( tx_seminars_sites, array( 'title' => 'TEST Place 1', 'city' => 'Tokyo', 'country' => 'JP' ) ); $this->fixture = new tx_seminars_place($uid); }
![Page 19: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/19.jpg)
A Test Case:class tx_seminars_place_testcase extends tx_phpunit_testcase { public function testGetCityReturnsCityName() { $this->assertEquals( 'Tokyo', $this->fixture->getCity() ); }
public function testGetCountryIsoCodeReturnsIsoCode() { $this->assertEquals( 'JP', $this->fixture->getCountryIsoCode() ); }}
![Page 20: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/20.jpg)
Let‘s play!
![Page 21: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/21.jpg)
Test different aspects
Functionality RegressionEdge cases
![Page 22: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/22.jpg)
Kitchen Tools can help!
![Page 23: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/23.jpg)
How?
Why?
Then?
![Page 24: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/24.jpg)
Risks of Unit Testing
Don‘t eat too much!
Don‘t cook bullshit!
![Page 25: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/25.jpg)
Workflow
He‘s a cool developer!
That‘s the SVN Server!
![Page 26: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/26.jpg)
Local testing
Coding
Unit Testing
drinking coffee
Subversion
Comitting only tested code!
![Page 27: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/27.jpg)
Continous Integration
Coding
Unit Testing
drinking coffee
Subversion
Unit Testing
![Page 28: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/28.jpg)
Continous Integration
Coding
drinking coffee
Subversion
Comitting un-tested code!
Unit Testing Unit Testing
![Page 29: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/29.jpg)
less than 2%
of all extensions in TER are unit tested
![Page 30: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/30.jpg)
feels good!
![Page 31: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/31.jpg)
How?
Why?
Then?
![Page 32: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/32.jpg)
page intentionally left blank for your questions
![Page 33: Unit Testing is like cooking! - t3dd08.typo3.org fileUnit Testing is like cooking! Classes to test Testcases Environment for Testing Fixtures Testing Framework](https://reader030.fdocuments.us/reader030/viewer/2022040416/5d4876c188c993fc4f8bd3d8/html5/thumbnails/33.jpg)
Mario [email protected]
Screenteam GmbHFalkenstrasse 26CH-8008 Zürich
www.screenteam.com
Thanks for your attention...
... and happy cooking!