PageRenderTime 38ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/ext/README.md

http://github.com/Codeception/Codeception
Markdown | 240 lines | 159 code | 81 blank | 0 comment | 0 complexity | ae7f488c911bdc7ba54d26133a5efb6c MD5 | raw file
  1. # Official Extensions
  2. ## DotReporter
  3. [See Source](https://github.com/Codeception/Codeception/blob/4.0/ext/DotReporter.php)
  4. DotReporter provides less verbose output for test execution.
  5. Like PHPUnit printer it prints dots "." for successful testes and "F" for failures.
  6. ![](https://cloud.githubusercontent.com/assets/220264/26132800/4d23f336-3aab-11e7-81ba-2896a4c623d2.png)
  7. ```bash
  8. ..........
  9. ..........
  10. ..........
  11. ..........
  12. ..........
  13. ..........
  14. ..........
  15. ..........
  16. Time: 2.07 seconds, Memory: 20.00MB
  17. OK (80 tests, 124 assertions)
  18. ```
  19. Enable this reporter with `--ext option`
  20. ```
  21. codecept run --ext DotReporter
  22. ```
  23. Failures and Errors are printed by a standard Codeception reporter.
  24. Use this extension as an example for building custom reporters.
  25. ## Logger
  26. [See Source](https://github.com/Codeception/Codeception/blob/4.0/ext/Logger.php)
  27. Log suites/tests/steps using Monolog library.
  28. Monolog should be installed additionally by Composer.
  29. ```
  30. composer require monolog/monolog
  31. ```
  32. Steps are logged into `tests/_output/codeception.log`
  33. To enable this module add to your `codeception.yml`:
  34. ``` yaml
  35. extensions:
  36. enabled: [Codeception\Extension\Logger]
  37. ```
  38. #### Config
  39. * `max_files` (default: 3) - how many log files to keep
  40. ## Recorder
  41. [See Source](https://github.com/Codeception/Codeception/blob/4.0/ext/Recorder.php)
  42. Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page (here's an [example](http://codeception.com/images/recorder.gif))
  43. Activated only for suites with WebDriver module enabled.
  44. The screenshots are saved to `tests/_output/record_*` directories, open `index.html` to see them as a slideshow.
  45. #### Installation
  46. Add this to the list of enabled extensions in `codeception.yml` or `acceptance.suite.yml`:
  47. ``` yaml
  48. extensions:
  49. enabled:
  50. - Codeception\Extension\Recorder
  51. ```
  52. #### Configuration
  53. * `delete_successful` (default: true) - delete screenshots for successfully passed tests (i.e. log only failed and errored tests).
  54. * `module` (default: WebDriver) - which module for screenshots to use. Set `AngularJS` if you want to use it with AngularJS module. Generally, the module should implement `Codeception\Lib\Interfaces\ScreenshotSaver` interface.
  55. * `ignore_steps` (default: []) - array of step names that should not be recorded (given the step passed), * wildcards supported. Meta steps can also be ignored.
  56. * `success_color` (default: success) - bootstrap values to be used for color representation for passed tests
  57. * `failure_color` (default: danger) - bootstrap values to be used for color representation for failed tests
  58. * `error_color` (default: dark) - bootstrap values to be used for color representation for scenarios where there's an issue occurred while generating a recording
  59. * `delete_orphaned` (default: false) - delete recording folders created via previous runs
  60. * `include_microseconds` (default: false) - enable microsecond precision for recorded step time details
  61. #### Examples:
  62. ``` yaml
  63. extensions:
  64. enabled:
  65. - Codeception\Extension\Recorder:
  66. module: AngularJS # enable for Angular
  67. delete_successful: false # keep screenshots of successful tests
  68. ignore_steps: [have, grab*]
  69. ```
  70. #### Skipping recording of steps with annotations
  71. It is also possible to skip recording of steps for specified tests by using the @skipRecording annotation.
  72. ```php
  73. /**
  74. * @skipRecording login
  75. * @skipRecording amOnUrl
  76. *\/
  77. public function testLogin(AcceptanceTester $I)
  78. {
  79. $I->login();
  80. $I->amOnUrl('http://codeception.com');
  81. }
  82. ```
  83. ## RunBefore
  84. [See Source](https://github.com/Codeception/Codeception/blob/4.0/ext/RunBefore.php)
  85. Extension for execution of some processes before running tests.
  86. Processes can be independent and dependent.
  87. Independent processes run independently of each other.
  88. Dependent processes run sequentially one by one.
  89. Can be configured in suite config:
  90. ```yaml
  91. # acceptance.suite.yml
  92. extensions:
  93. enabled:
  94. - Codeception\Extension\RunBefore:
  95. - independent_process_1
  96. -
  97. - dependent_process_1_1
  98. - dependent_process_1_2
  99. - independent_process_2
  100. -
  101. - dependent_process_2_1
  102. - dependent_process_2_2
  103. ```
  104. HINT: you can use different configurations per environment.
  105. ## RunFailed
  106. [See Source](https://github.com/Codeception/Codeception/blob/4.0/ext/RunFailed.php)
  107. Saves failed tests into tests/log/failed in order to rerun failed tests.
  108. To rerun failed tests just run the `failed` group:
  109. ```
  110. php codecept run -g failed
  111. ```
  112. To change failed group name add:
  113. ```
  114. --override "extensions: config: Codeception\Extension\RunFailed: fail-group: another_group1"
  115. ```
  116. Remember: if you run tests and they generated custom-named fail group, to run this group, you should add override too
  117. Starting from Codeception 2.1 **this extension is enabled by default**.
  118. ``` yaml
  119. extensions:
  120. enabled: [Codeception\Extension\RunFailed]
  121. ```
  122. On each execution failed tests are logged and saved into `tests/_output/failed` file.
  123. ## RunProcess
  124. [See Source](https://github.com/Codeception/Codeception/blob/4.0/ext/RunProcess.php)
  125. Extension to start and stop processes per suite.
  126. Can be used to start/stop selenium server, chromedriver, phantomjs, mailcatcher, etc.
  127. Can be configured in suite config:
  128. ```yaml
  129. # acceptance.suite.yml
  130. extensions:
  131. enabled:
  132. - Codeception\Extension\RunProcess:
  133. - chromedriver
  134. ```
  135. Multiple parameters can be passed as array:
  136. ```yaml
  137. # acceptance.suite.yml
  138. extensions:
  139. enabled:
  140. - Codeception\Extension\RunProcess:
  141. - php -S 127.0.0.1:8000 -t tests/data/app
  142. - java -jar ~/selenium-server.jar
  143. ```
  144. In the end of a suite all launched processes will be stopped.
  145. To wait for the process to be launched use `sleep` option.
  146. In this case you need configuration to be specified as object:
  147. ```yaml
  148. extensions:
  149. enabled:
  150. - Codeception\Extension\RunProcess:
  151. 0: java -jar ~/selenium-server.jar
  152. 1: mailcatcher
  153. sleep: 5 # wait 5 seconds for processes to boot
  154. ```
  155. HINT: you can use different configurations per environment.
  156. ## SimpleReporter
  157. [See Source](https://github.com/Codeception/Codeception/blob/4.0/ext/SimpleReporter.php)
  158. This extension demonstrates how you can implement console output of your own.
  159. Recommended to be used for development purposes only.