+ All Categories
Home > Technology > Test Fest 2009

Test Fest 2009

Date post: 18-Dec-2014
Category:
Upload: pierre-joye
View: 1,413 times
Download: 0 times
Share this document with a friend
Description:
Presentation PHP Testfest 2009 Utrecht.
19
TestFest 2009 PHP Netherland, Utrecht Pierre Joye
Transcript
Page 1: Test Fest 2009

TestFest 2009PHP Netherland, Utrecht

Pierre Joye

Page 2: Test Fest 2009

Welcome to the TestFest 2009!

Thanks you for joining us!

First tests fest?

First test (I won’t tell your boss)?

Page 3: Test Fest 2009

What should I bother?

PHP needs YOU

You need PHP too

a broken PHP is uselessA new Phpet is waiting for you!

Page 4: Test Fest 2009

What is this about?

Improve code coverage

Fantastic opportunity to be part of PHP

Network to learn and work together

Page 5: Test Fest 2009

PHPT

Single test in a single .phpt file

Small set of similar tests in a .phpt file

Each test are run by calling a new php instance

Test isolationCustom configuration Support of segfaults and other fatal

errors

Page 6: Test Fest 2009

Testing PHP, everything (or less)

(n)make test

make test \TESTS=/home/joe/php/ext/reflection/tests

make test \TESTS=/home/joe/php/ext/a/tests/b.phpt

Page 7: Test Fest 2009

Naming convention

A bugbug12345.phpt (bug.php.net/12345)

Features<functionname>_basic.phpt

Errors<functionname>_error.phpt

Generalextname<test nr>.phpt

Page 8: Test Fest 2009

Simplest test ever

--TEST—Not testing PHP--FILE—Goede morgen--EXPECT—Goede morgen

Page 9: Test Fest 2009

2nd most simplest test ever (failing)

--TEST—Let try to test echo!--FILE—<?php echo “Hoe doet u?”; ?>--EXPECT—Ik heb nodig koffie

Page 10: Test Fest 2009

Expect using printf syntax

--TEST—rand--FILE—<?php echo “rand: ”. rand(); ?>--EXPECT—rand: %d

Page 11: Test Fest 2009

Expect using regex syntax (avoid it)

--TEST—rand--FILE—<?php echo “rand: ”. rand(); ?>--EXPECTREGEX—M_E: 2.718281[0-9]*

Page 12: Test Fest 2009

Where to find the EXPECTF placeholders list

http://qa.php.net/expectf_details.php

Page 13: Test Fest 2009

Custom ini settings

--TEST—Timezone--INI—date.timezone=Europe/Berlin--FILE—<?php echo date_timezone_get(); ?>--EXPECT—Europe/Berlin

Page 14: Test Fest 2009

Conditional test

--TEST—Timezone--SKIPIF—<?php if (! extension_loaded (‘myext’) die(‘myext not available’); ?>

--FILE—…--EXPECT—..

Page 15: Test Fest 2009

Render unto Caesar the things which are Caesar’s

--TEST—Timezone--CREDITS—John TheWriter#testfest Utrecht 2009--FILE—…--EXPECT—..

Page 16: Test Fest 2009

Complete doc about phpt (with samples!)

http://qa.php.net/phpt_details.php

Page 17: Test Fest 2009

What is a good test?

Keep it smalll and beautifulTest one feature per phptAvoid large output

Page 18: Test Fest 2009

What is a good test?

If a large output is necessaryNumerate or name each line

Easier to analyzeEasier to debug

Page 19: Test Fest 2009

Resources

PHP GCOV - Test and Code Coverage Analysishttp://gcov.php.net/

PHP WIKI - How to look at the test coverage for an extensionhttp://wiki.php.net/qa/testcoverage

PHP QA - Writing Testshttp://qa.php.net/write-test.php

Lessons Learned from PHPT Writinghttp://wiki.php.net/qa/phptlessonslearned

PHP CVS - README.TESTINGhttp://cvs.php.net/viewvc.cgi/php-src/README.TESTING


Recommended