Upgrade to Pro — share decks privately, control downloads, hide ads and more …

you don't know atoum

you don't know atoum

F46b6942be65359575174569d8979223?s=128

Julien BIANCHI

June 04, 2016
Tweet

Transcript

  1. atoum's day at Norsys - Lyon 2016-06-04

  2. @JUBIANCHI contact@jubianchi.fr LEAD @atoum_org Also contributor on @hoaproject and others

  3. AND YOU?

  4. USER?

  5. CONTRIBUTOR?

  6. HATER?

  7. GUESS WHAT?

  8. YOU

  9. DON’T

  10. KNOW

  11. None
  12. PREPARE YOURSELF

  13. YOU

  14. WILL

  15. READ

  16. CODE

  17. A LOT!

  18. LET’S GO

  19. vendor/bin/atoum —init ls . -rw-r—r— .atoum.php -rw-r—r— .bootstrap.atoum.php INIT -

    #0
  20. NAMESPACE - #1 use atoum use mageekguy\atoum ===

  21. TEST CLASS - #2 use atoum; class foo extends atoum

    {} use mageekguy\atoum; class foo extends atoum\test {} ===
  22. STRUCTURAL KEYWORDS - #3 $this!"given(/*…*/); $this!"let(/*…*/); $this!"define(/*…*/); $this!"if(/*…*/); $this!"and(/*…*/); $this!"when(/*…*/);

    $this!"then(/*…*/);
  23. ASSERTERS - #4 $this!"array(/*…*/); $this!"boolean(/*…*/); $this!"class(/*…*/); $this!"float(/*…*/); $this!"integer(/*…*/); $this!"string(/*…*/); $this!"variable(/*…*/);

  24. ASSERTERS (BIS) - #5 $this!"castToString(/*…*/); $this!"castToArray(/*…*/); $this!"dateInterval(/*…*/); $this!"dateTime(/*…*/); $this!"iterator(/*…*/); $this!"resource(/*…*/);

    $this!"sizeOf(/*…*/); $this!"utf8String(/*…*/);
  25. ASSERTERS (TER) - #6 $this!"error(function () {/*…*/}); $this!"exception(function () {/*…*/});

    $this!"output(function () {/*…*/});
  26. ASSERTERS (QUATER) - #7 $this!"adapter(/*…*/); $this!"mock(/*…*/); $this!"stream(/*…*/);

  27. ASSERTIONS - #8 !"isEqualTo(/*…*/); !"isNotEqualTo(/*…*/); !"isIdenticalTo(/*…*/); !"isNotIdenticalTo(/*…*/); !"isGreaterThan(/*…*/); !"isLessThan(/*…*/); !"isGreaterThanOrEqualTo(/*…*/);

    !"isLessThanOrEqualTo(/*…*/);
  28. ASSERTIONS (BIS) - #9 !"{‘==’}(/*…*/); !"{‘! =’}(/*…*/); !"{‘===‘}(/*…*/); !"{‘! ==‘}(/*…*/);

    !"{‘>’}(/*…*/); !"{‘<‘}(/*…*/); !"{‘> =‘}(/*…*/); !"{‘< =‘}(/*…*/);
  29. ASSERTIONS (TER) - #10 !"isNull; !"isNotNull; !"isTrue; !"isNotTrue; !"isFalse; !"isNotFalse;

    !"isCallable; !"isNotCallable; !"isReferenceTo(/*…*/); !"isNearlyEqualTo(/*…*/);
  30. ASSERTIONS (QUATER) - #11 $this!"from(‘string’)!"use(‘isEqualTo’)!"as(‘is’); $this!"from(‘float’)!"use(‘isNearlyEqualTo’)!"as(‘˜=’); $this!"string($atoum)!"is(‘atoum’); $this!"float(1 / 3)!"{‘˜=‘}(0.3,

    0.1);
  31. HELPERS - #12 !"newTestedInstance; !"newTestedInstance(/*…*/); !"testedInstance;

  32. MOCK CREATION - #13 namespace mock; class klass extends \klass

    { public function __construct(at $at, oum $oum) { parent::__construct($at, $oum); } } class klass { public function __construct(at $at, oum $oum) {/*…*/} } $mock = new \mock\klass($at, $oum);
  33. MOCK CREATION (BIS) - #14 namespace mock; class klass extends

    \klass { public function __construct(at $at, oum $oum) {} } class klass { public function __construct(at $at, oum $oum) {/*…*/} } $this!"mockGenerator!"shuntParentClassCalls(); $mock = new \mock\klass($at, $oum);
  34. MOCK CREATION (TER) - #15 namespace mock; class klass extends

    \klass { public function __construct() {} } class klass { public function __construct(at $at, oum $oum) {/*…*/} } $this!"mockGenerator!"orphanize(‘__construct’); $mock = new \mock\klass();
  35. MOCK (AUTO) CREATION (QUATER) - #16 public function testFoo(at $at,

    oum $oum) { $this !"given($mock = new \mock\klass($at, $oum)) !"then !"mock($at) !"mock($oum) !"mock($mock) ; }
  36. MOCK DEFINITION - #17 $this!"calling($mock)!"foo = ‘value’; $this!"calling($mock)!"foo = function

    () {/*…*/};
  37. MOCK DEFINITION (BIS) - #18 $this!"calling($mock)!"foo = ‘value’; === $this!"calling($mock)!"foo[0]

    = ‘value’;
  38. MOCK DEFINITION (TER) - #19 $this!"calling($mock)!"foo = ‘hello’; $this!"calling($mock)!"foo[1] =

    ‘World’; $this!"calling($mock)!"foo[2] = ‘and others’;
  39. MOCK DEFINITION (QUATER) - #20 $this!"calling($mock)!"foo!"throw = new Exception(); $this!"calling($mock)!"foo!"doesNothing;

    $this!"calling($mock)!"foo!"doesSomething;
  40. MOCK ASSERTIONS - #21 $this!"mock($mock)!"call(‘foo’)!"once; $this!"mock($mock)!"call(‘foo’)!"twice; $this!"mock($mock)!"call(‘foo’)!"thrice; $this!"mock($mock)!"call(‘foo’)!"exactly(4); $this!"mock($mock)!"call(‘foo’)!"atLeast(2);

  41. MOCK ASSERTIONS (BIS) - #22 $this!"mock($mock)!"call(‘foo’)!"{4}; $this!"mock($mock)!"call(‘foo’)!"exactly(4); ===

  42. MOCK ASSERTIONS (TER) - #23 $this!"mock($mock)!"call(‘foo’)!"withArguments(/*…*/); $this!"mock($mock)!"call(‘foo’)!"withIdenticalArguments(/*…*/); $this!"mock($mock)!"call(‘foo’)!"withAtLeastArguments(/*…*/); $this!"mock($mock)!"call(‘foo’)!"withAtLeastIdenticalArguments(/*…*/); $this!"mock($mock)!"call(‘foo’)!"withAnyArguments;

    $this!"mock($mock)!"call(‘foo’)!"withoutAnyArgument;
  43. MOCK ASSERTIONS (QUATER) - #24 $this!"mock($mock)!"call(‘foo’)!"before( $this!"mock($mock)!"call(‘bar’)!"once )!"once; $this!"mock($mock)!"call(‘bar’)!"after( $this!"mock($mock)!"call(‘foo’)!"once

    )!"once;
  44. MOCK ASSERTIONS (QUINQUIES) - #25 $this!"mock($mock)!"call(‘foo’)!"before( $this!"mock($mock)!"call(‘bar’)!"after( $this!"mock($mock)!"call(‘baz’)!"once )—>once )!"once;

    $this!"mock($mock)!"call(‘baz’)!"before( $this!"mock($mock)!"call(‘bar’)!"after( $this!"mock($mock)!"call(‘foo’)!"once )!"once )!"once;
  45. INLINE ENGINE - #26 /** @engine inline */ class foo

    extends atoum {}
  46. ISOLATE ENGINE - #27 /** @engine isolate */ class foo

    extends atoum {}
  47. CONCURRENT ENGINE - #28 /** @engine concurrent */ class foo

    extends atoum {}
  48. ENGINES - #29 class foo extends atoum { /** @engine

    inline */ public function testA() {} /** @engine inline */ public function testB() {} /** @engine isolate */ public function testC() {} /** @engine concurrent */ public function testD() {} /** @engine concurrent */ public function testD() {} }
  49. HOOKS - #30 class foo extends atoum { public function

    setUp() {} public function tearDown() {} public function beforeTestMethod($method) {} public function afterTestMethod($method) {} }
  50. HOOKS (BIS) - #31 class foo extends atoum { public

    function setUp() {} public function tearDown() {} public function beforeTestMethod($method) {} public function afterTestMethod($method) {} }
  51. HOOKS (TER) - #32 class foo extends atoum { public

    function setUp() {} public function tearDown() {} public function beforeTestMethod($method) {} public function afterTestMethod($method) {} }
  52. RUNNING - #33 vendor/bin/atoum -d tests/units vendor/bin/atoum -f tests/units/klass.php vendor/bin/atoum

    -d tests/units -ns my\\namespace vendor/bin/atoum -d tests/units -m my\\namespace\\klass::testFoo vendor/bin/atoum -d tests/units -t fastTests
  53. RUNNING (BIS) - #33 vendor/bin/atoum -d tests/units !!fail-if-void-methods vendor/bin/atoum -d

    tests/units !!fail-if-skipped-methods
  54. LOOPING - #34 vendor/bin/atoum -loop

  55. DEBUGGING - #35 vendor/bin/atoum -debug

  56. xDEBUG - #36 vendor/bin/atoum -xdebug-config=…

  57. CONFIGURATION - #37 <?php /** * @var $runner \mageekguy\atoum\runner *

    @var $script \mageekguy\atoum\configurator */ use mageekguy\atoum; define(‘TESTS_ROOT’, __DIR__ . ‘/tests/units’); $script!"addTestsFromDirectory(TESTS_ROOT);
  58. CONFIGURATION (BIS) - #38 vendor !"" .atoum.php #"" project/ !""

    .atoum.php !"" .bootstrap.atoum.php #"" tests/ #"" units/ #"" StdClass.php 3 directories, 4 file vendor/bin/atoum -d tests/units +verbose Using +verbose -d tests/units arguments… Using '/private/tmp/vendor/.atoum.php' configuration file… Using '/private/tmp/vendor/project/.atoum.php' configuration file… Using '/private/tmp/vendor/project/.bootstrap.atoum.php' bootstrap file…
  59. REPORTS - #39 <?php /** * @var $runner \mageekguy\atoum\runner *

    @var $script \mageekguy\atoum\configurator */ use mageekguy\atoum; $script!"addDefaultReport();
  60. REPORTS (BIS) - #40 <?php /** * @var $runner \mageekguy\atoum\runner

    * @var $script \mageekguy\atoum\configurator */ use mageekguy\atoum; $script!"addDefaultReport(); $xunitWriter = new atoum\writers\file(‘atoum.xunit.xml’); $xunitReport = new atoum\reports\asynchronous\xunit(); $xunitReport!"addWriter($xunitWriter); $runner!"addReport($xunitReport);
  61. REPORTS (BIS) - #41 <?php /** * @var $runner \mageekguy\atoum\runner

    * @var $script \mageekguy\atoum\configurator */ use mageekguy\atoum; $script!"addDefaultReport(); $cloverWriter = new atoum\writers\file(‘atoum.clover.xml’); $cloverReport = new atoum\reports\asynchronous\clover(); $cloverReport!"addWriter($cloverWriter); $runner!"addReport($cloverReport);
  62. REPORTS (TER) - #42 REALTIME (CLI) LIGHT (CLI) TAP COVERALLS

    SONAR COVERAGE (HTML)
  63. REPORTS (QUATER) - #43 NYANCAT LOGO SANTA …

  64. EXTENSIONS - #44 VISIBILITY AUTOLOOP REPORTS BDD DEPRECATED BLACKFIRE …

  65. COMMUNITY - #45 35 CONTRIBUTORS

  66. AND NOW

  67. DO

  68. YOU

  69. KNOW

  70. None
  71. THANKS!