phpsp testfest 2010
DESCRIPTION
Introduçao a testes PHPTTRANSCRIPT
![Page 1: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/1.jpg)
SSlides baseados no trabalho de Sebastian Bergmann, traduzido por José Ricardo (PHPMS) e adaptado por Silvano Girardi (PHPSC)Original: http://sebastian-bergmann.de/talks/
![Page 2: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/2.jpg)
Apoio:
Olá eu sou a TestFest Objetivos
Aumentar a abrangência do código do interpretador de PHP (com testes)
Motivar usuários a participar, (re|con)tribuir com o PHP Unir e motivar membros do grupo de usuário Qualificar o participante com uma nova ferramenta
Atividade Global Em 2009: Países de todo mundorealizaram TestFests PHPSP: Grupo com maior número de testes em todo
mundo
Próximas oportunidades PHPSP: Setembro (Encerramento)
![Page 3: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/3.jpg)
Apoio:
Olá eu sou a TestFest Benefícios
Aprendizado de testes Uma linguagem mais estável Mais releases Sorteios entre todos participantes do mundo
2009: 5 participantes ganharam (1 caneca / 4 elephpantes) Se você gostar e ajudar bastante:
Email @php.net Karma no repositório oficial (área de testes)
![Page 4: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/4.jpg)
Apoio:
Pizza!
Patrocinado por:
Como será nosso dia?
TESTES
SUPORTE E CONFIGURAÇÃO
TESTES
Almoço
PALESTRA
SORTEIO
#PHPinga
09h30 12h30 16h30
![Page 5: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/5.jpg)
Apoio:
PHPT Cada arquivo .phpt possui um único teste
Cada teste é executado por um processo separado Isolamento total do teste Configuração do PHP independente para cada teste A suite de testes sobrevive a erros fatais, segfaults, etc..
PHPT: http://phpt.info
![Page 6: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/6.jpg)
Apoio:
Dando nome ao seu filho Testes que ilustram falhas reportadas (bugs)
bug<bugid>.phpt
Testes de comportamento básico de uma função <functionname>_basic.phpt
Testes de comportamento errôneo de uma função <functionname>_error.phpt
Testes de variações no comportamento de uma função <functionname>_variation.phpt
Testes variados para extensões <extname><no>.phpt
![Page 7: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/7.jpg)
Apoio:
O Teste mais simples do mundo
--TEST--
Hello World
--FILE--
Hello World
--EXPECT--
Hello World
![Page 8: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/8.jpg)
Apoio:
Agora com PHP--TEST--
Hello World
--FILE--
<?php print 'Hello World'; ?>
--EXPECT--
Hello World
![Page 9: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/9.jpg)
Apoio:
Expectativas--TEST--
Hello World
--FILE--
<?php print 'Hello World
--EXPECTF--
Parse error: syntax error, unexpected $end in %s.php on line %d
%s - qualquer string
%d - numero
%c - um character
%w - espaço
%i - inteiro
%f - real
%x - hexadecimal
%e – separador de diretórios
![Page 10: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/10.jpg)
Apoio:
Expectativas--TEST--
Hello World
--FILE--
<?php print 'Hello World
--EXPECTREGEX--
Parse error: (parse|syntax) error, unexpected $end in .* on line .*
![Page 11: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/11.jpg)
Apoio:
Limpando a sujeira--TEST--
Removendo arquivos temporários
--FILE--
<?php
$temp_filename = dirname(__FILE__) . '/foo.tmp';
$fp = fopen($temp_filename, 'w');
fwrite($fp, 'bar');
fclose($fp);
?>
--CLEAN--
<?php
$temp_filename = dirname(__FILE__) . '/foo.tmp';
unlink($temp_filename);
?>
--EXPECT--
![Page 12: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/12.jpg)
Apoio:
Mexendo nas Configurações
--TEST--
Definindo um fuso para portabilidade
--INI--
date.timezone=UTC
--FILE--
--EXPECT--
![Page 13: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/13.jpg)
Apoio:
Portavel e Seletivo--TEST--
Verificando se estamos em uma plataforma de 32 bits...
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die('32bit platforms only');
?>
--FILE--
--EXPECT--
![Page 14: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/14.jpg)
Apoio:
Portavel e Seletivo--TEST--
Verificando se estamos no Linux...
--SKIPIF--
<?php
if (!stristr(PHP_OS, 'Linux')) die('Linux only');
?>
--FILE--
--EXPECT--
![Page 15: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/15.jpg)
Apoio:
Fui eu!--TEST--
Um teste com uma seção de créditos
--CREDITS--
Jack <[email protected]>
#testfest PHPSP on 2009-06-20
--FILE--
--EXPECT--
![Page 16: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/16.jpg)
Apoio:
Outras sessões--TEST--
[--DESCRIPTION--]
[--CREDITS--]
[--SKIPIF--]
[--REQUEST--]
[--POST-- | --POST_RAW-- | --GZIP_POST-- | --DEFLATE_POST-- | --GET--]
[--COOKIE--]
[--STDIN--]
[--INI--]
[--ARGS--]
[--ENV--]
--FILE-- | --FILEEOF-- | --FILE_EXTERNAL-- | --REDIRECTTEST--
[--HEADERS--]
[--CGI--]
[--XFAIL--]
[--EXPECTHEADERS--]
--EXPECT-- | --EXPECTF-- | --EXPECTREGEX--
[--CLEAN--]
![Page 17: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/17.jpg)
Apoio:
Roda ai Zé! $ make tests TESTS=path/to/ext/yourextension/tests
=====================================================================PHP : /Users/rdohms/Downloads/src/php-5.3.0RC4/sapi/cli/php PHP_SAPI : cliPHP_VERSION : 5.3.0RC4ZEND_VERSION: 2.3.0PHP_OS : Darwin - Darwin MacDohms.local 9.7.0 Darwin Kernel Version 9.7.0: …INI actual : /Users/rdohms/Downloads/src/php-5.3.0RC4/tmp-php.iniMore .INIs : CWD : /Users/rdohms/Downloads/src/php-5.3.0RC4Extra dirs : VALGRIND : Not used=====================================================================Running selected tests.PASS Hello World [/Users/rdohms/dev/phpsp/testfest/SaoPauloUG/tests/basic/mytest.phpt] =====================================================================Number of tests : 1 1Tests skipped : 0 ( 0.0%) --------Tests warned : 0 ( 0.0%) ( 0.0%)Tests failed : 0 ( 0.0%) ( 0.0%)Expected fail : 0 ( 0.0%) ( 0.0%)Tests passed : 1 (100.0%) (100.0%)---------------------------------------------------------------------Time taken : 0 seconds=====================================================================
![Page 18: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/18.jpg)
Apoio:
Roda na Janela! TEST_EXECUTABLE_PHP=auto sapi/cli/php run-
tests.php path/to/test
Bash export
TEST_PHP_EXECUTABLE=/mnt/workspace/PHP/php53/sapi/cli/php
$TEST_PHP_EXECUTABLE /mnt/workspace/PHP/php53/run-tests.php $*
![Page 19: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/19.jpg)
Apoio:
Ambientes Versão para testes:
PHP 5.3.2 ou 5.3.3-dev (SVN)
Ambientes disponíveis Virtual Machine de Ubuntu (Virtual Box) Windows (run-tests.php) Seu ambiente local já compilado
![Page 20: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/20.jpg)
Apoio:
O Que testar? Como achar?
Verificar GCOV - http://gcov.php.net/ Procurar linhas não testadas Extensões com pouca cobertura
Página de Funções testadas - http://qa.php.net/tested-methods.php Achar casos de uso não testados
![Page 21: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/21.jpg)
Apoio:
Regras Tudo em inglês!
Faltou alguma informação?
http://wiki.php.net/qa/testfest-2010
![Page 22: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/22.jpg)
Apoio:
Processo de escrita Selecione o que irá testar
Avise o resto da sala
Escreva o teste
Rode o teste com PHP 5.3
Rode o teste no Trunk e 5.2 [opcional]
Commite o teste em nosso SVN
Avise um monitor
![Page 23: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/23.jpg)
Apoio:
Não Acabou! Evento se estende até setembro
Repositório continuará aberto
Não pare de contribuir!
Setembro Palestra + testes Encerramento geral
![Page 24: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/24.jpg)
Apoio
![Page 25: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/25.jpg)
S
Ao código!!
![Page 26: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/26.jpg)
License This presentation material is published under the Attribution-Share Alike
3.0 Unported license.
You are free: to Share – to copy, distribute and transmit the work. to Remix – to adapt the work.
Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or
licensor (but not in any way that suggests that they endorse you or your use of the work).
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.
For any reuse or distribution, you must make clear to others the license terms of this work.
Any of the above conditions can be waived if you get permission from the copyright holder.
Nothing in this license impairs or restricts the author's moral rights.
![Page 27: PHPSP TestFest 2010](https://reader035.vdocuments.mx/reader035/viewer/2022081403/554f56a4b4c905b9508b5119/html5/thumbnails/27.jpg)
Apoio:
Licença Este material para apresentação é publicado sob a licença “Attribution-
Share Alike 3.0 Unported”.
Você é livre para: Compartilhar – copiar, distribuir e transmitir o trabalho. Alterar – adaptar o trabalho.
Sob as seguintes condições: Atribuição. Você deve atribuir o trabalho na maneira especificada pelo autor ou
licenciador (mas não de maneira a sugerir que eles te apóiam você ou a maneira como você utiliza o trabalho).
Distribua da mesma forma. Se você alterar, transformar ou construir algo baseando-se neste trabalho, você deve distribuir o trabalho resultante apenas sob a mesma licença, uma licença similar ou compatível.
Para qualquer reuso ou distribuição, você deve deixar claro aos outros os termos de licenciamento deste trabalho.
Qualquer uma das condições acima pode ser ignorada se você obtiver a permissões do proprietário dos direitos autorais.
Nada nesta licença danifica ou restringe os direitos morais do autor.