Skip to content

Commit 17d7097

Browse files
committed
added reporters
1 parent 55eab17 commit 17d7097

File tree

5 files changed

+129
-66
lines changed

5 files changed

+129
-66
lines changed

guides/02-GettingStarted.md

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -260,63 +260,6 @@ class TaskCrudCest
260260

261261
Learn more about the [Cest format](https://codeception.com/docs/07-AdvancedUsage#Cest-Classes) in the Advanced Testing section.
262262

263-
## Interactive Pause
264-
265-
It's hard to write a complete test at once.
266-
You will need to try different commands with different arguments before you find a correct path.
267-
268-
Execution can be paused at any point and enter an interactive shell where you will be able to try different commands in action.
269-
All you need to do is **call `$I->pause()`** somewhere in your test, then run the test in [debug mode](#Debugging).
270-
271-
Interactive Pause requires [`hoa/console`](https://hoa-project.net/) which is not installed by default. To install it, run:
272-
273-
{% highlight bash %}
274-
275-
php composer.phar require --dev hoa/console
276-
277-
{% endhighlight %}
278-
279-
{% highlight php %}
280-
281-
<?php
282-
// use pause inside a test:
283-
$I->pause();
284-
285-
{% endhighlight %}
286-
287-
The execution of the test is stopped at this point, and a console is shown where you can try all available commands "live".
288-
This can be very useful when you write functional, acceptance, or api test.
289-
290-
![](https://user-images.githubusercontent.com/220264/54929617-875ad180-4f1e-11e9-8fea-fc1b02423050.gif)
291-
292-
Inside Interactive Pause you can use the entire power of the PHP interpreter: variables, functions, etc.
293-
You can access the result of the last executed command in a variable called `$result`.
294-
295-
In acceptance or functional test you can save page screenshot or html snapshot.
296-
297-
{% highlight php %}
298-
299-
<?php
300-
// inside PhpBrowser, WebDriver, frameworks
301-
// saves current HTML and prints a path to created file
302-
$I->makeHtmlSnapshot();
303-
304-
// inside WebDriver
305-
// saves screenshot and prints a path to created file
306-
$I->makeScreenshot();
307-
308-
{% endhighlight %}
309-
310-
To try commands without running a single test you can launch interactive console:
311-
312-
{% highlight bash %}
313-
314-
$ php vendor/bin/codecept console suitename
315-
316-
{% endhighlight %}
317-
318-
Now you can execute all the commands of a corresponding Actor class and see the results immediately.
319-
320263
## BDD
321264

322265
Codeception allows execution of user stories in Gherkin format in a similar manner as is done in Cucumber or Behat.
@@ -401,18 +344,11 @@ php vendor/bin/codecept run --steps --xml --html
401344

402345
This command will run all tests for all suites, displaying the steps, and building HTML and XML reports. Reports will be stored in the `tests/_output/` directory.
403346

404-
To see all the available options, run the following command:
405-
406-
{% highlight bash %}
407-
408-
php vendor/bin/codecept help run
409-
410-
{% endhighlight %}
411-
412347
## Debugging
413348

414349
To receive detailed output, tests can be executed with the `--debug` option.
415-
You may print any information inside a test using the `codecept_debug` function.
350+
351+
Learn more about [debugging](/docs/Debugging).
416352

417353
### Generators
418354

guides/11-Reporting.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
## Reporting
2+
3+
Clear reports gives a picture of the current state of the system. Which tests are passed, which tests are failed, and if failed what was the reason. Reports may vary on the level of detail and by the technical information collected. Codeception provides as built-in reporters and customizable API to create your own reporter.
4+
5+
## CLI
6+
7+
The standard reporter you already is CLI reporter. It is great for writing and debugging tests as well, as checking the results on CI. On failure, CLI reporter prints a list of all failed tests, if test includes some valuable data like last send requests for REST module, it will also be printed under 'artifacts' section of a test.
8+
9+
![](/images/codecept-cli.png)
10+
11+
To launch CLI reporter in minimal mode, simply execute tests:
12+
13+
```
14+
php vendor/bin/codecept run
15+
```
16+
17+
To see step-by-step execution in a runtime use `--steps` flag:
18+
19+
```
20+
php vendor/bin/codecept run --steps
21+
```
22+
23+
To get additional information which may be handful for debugging tests use `--debug` flag.
24+
This flag is your best friend for writing new tests.
25+
26+
```
27+
php vendor/bin/codecept run --debug
28+
```
29+
30+
More CLI options are available:
31+
32+
* Artifacts report can be disabled with `--no-artifacts` option.
33+
* To explicitly enable ANSI colors use `--colors`, and `--no-colors` to disable them.
34+
* Use `--silent` to get the minimal possible output
35+
36+
Codeception will exit with exit code 1 if tests are failed.
37+
This is how CI can mark the job as failed.
38+
39+
## HTML
40+
41+
More information can be presented via HTML report.
42+
43+
![](/images/codeception-html.png)
44+
45+
Run tests with `--html` flag to create html report
46+
47+
```
48+
php vendor/bin/codecept run --html
49+
```
50+
51+
HTML report is valuable to present for non-tech colleagues. If you create HTML reports on CI you need to store a report as artifact to display it after. Codeception generates a static HTML file so no additional web server is needed to show it.
52+
53+
## Testomat.io
54+
55+
While HTML report can be pretty good for a single test run, more advanced reporting can be enabled by using Testomat.io. Testomat.io is a SaaS service which can store and present reports, and could be used by developers, QAs and managers. It is a complete test management system, which allows you track the history of tests, detect flaky tests, and work on planning new tests.
56+
57+
Testomat.io reports are easy to set up and without storing artifacts on CI system.
58+
59+
![](images/testomatio-report.png)
60+
61+
> 😻 Testomat.io is free for small teams, so you can use its reporting features with Codeception.
62+
63+
Testomat.io imports all tests into UI, so your managers, business analysts, and manual QAs can see all your unit, funcitonal, and acceptance tests listed in one place:
64+
65+
![](images/testomatio-import.png)
66+
67+
To start, create a new project at Testomat.io and import all your Codeception tests into it. Install testomatio packages for reporting and importing Codeception tests:
68+
69+
```
70+
composer require testomatio/list-tests --dev
71+
composer require testomatio/reporter --dev
72+
```
73+
74+
Obtain API key from a newly created Testomat.io project and import tests:
75+
76+
```
77+
TESTOMATIO={apiKey} php vendor/bin/list-tests tests
78+
```
79+
80+
After tests imported you can get a complete report while executing them:
81+
82+
```
83+
TESTOMATIO={apiKey} php vendor/bin/codecept run --ext "Testomatio\Reporter\Codeception"
84+
```
85+
86+
Data from test runs will be sent to Testomat.io server and you will see tests statuses are reported in realtime.
87+
88+
Testomat.io not only provides reports for test executions, it also collects historical data for tests, allows attaching tests to Jira issues, and provides useful analytics, and allows planning new tests.
89+
90+
Check an [Example Project](https://github.com/testomatio/examples/tree/master/codeception) to try it.
91+
92+
## Recorder
93+
94+
By default Codeception saves the screenshot for a failed test for acceptance tests and show it in HTML report. However, can't be possible to understand cause of failure just by one screenshot. This is where Recorder extension is handy, it saves a screenshot after each step and shows them in a slideshow.
95+
96+
![](https://codeception.com/images/recorder.gif)
97+
98+
Selenium WebDriver doesn't have a simple way to record a video of a test execution, so slideshow is the simplest solution you can use to debug your tests.
99+
100+
To use Recorder enable it as an extension inside config file:
101+
102+
```yml
103+
extensions:
104+
enabled:
105+
- Codeception\Extension\Recorder
106+
```
107+
More config options are available on [Extension page](https://codeception.com/extensions#Recorder).
108+
109+
## XML
110+
111+
JUnit XML is a reporting standard for testing frameworks. CI platforms like Jenkins can visualize JUnit reports.
112+
113+
```
114+
php vendor/bin/codecept run --xml
115+
```
116+
117+
## Allure
118+
119+
[Allure](https://docs.qameta.io/allure/) is a popular open-source reporting tool. It can be paired with Codeception to get a detailed run report. Use [Allure extension](https://github.com/allure-framework/allure-codeception) to generate report which can be passed to Allure to display it.
120+
121+
## Custom Reporter
122+
123+
Custom reporter can be built as an [Extension](https://codeception.com/docs/08-Customization#Extension). Extension can listen to all test events and log data from them.
124+
Look into the basic reporting extensions like [DotReporter](https://codeception.com/extensions#DotReporter) or [Logger](https://codeception.com/extensions#Logger) to learn how to build your own.
125+
126+
127+

images/codecept-cli.png

116 KB
Loading

images/codeception-html.png

375 KB
Loading

images/testomatio-import.png

272 KB
Loading

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy