You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***[Doctrine2]** Added support for Expression and Criteria objects in queries by **[alexkunin](https://github.com/alexkunin)**
17
+
***[Doctrine2]** Added fixture support by **[alexkunin](https://github.com/alexkunin)**
18
+
***[Doctrine2]** added refreshEntities and clearEntityManager methods by **[alexkunin](https://github.com/alexkunin)**
19
+
***[Doctrine2]** implement recursive entity creation by **[alexkunin](https://github.com/alexkunin)**
20
+
***[Doctrine2]** properly handle non-typical primary keys in haveInRepository by **[alexkunin](https://github.com/alexkunin)**
21
+
***[Doctrine2]** merge functionality of persistEntity into haveInRepository by **[alexkunin](https://github.com/alexkunin)**
22
+
***[Doctrine2]** deprecated persistEntity method by **[alexkunin](https://github.com/alexkunin)**
23
+
***[Doctrine2]** Make haveInRepository support constructor parameters by **[burned42](https://github.com/burned42)**
24
+
***[Symfony]** Fixed symfony 4.3 deprecation message removal by **[juntereiner](https://github.com/juntereiner)**
25
+
***[Yii2]** Allow to preserve session with recreateApplication enabled by **[Slamdunk](https://github.com/Slamdunk)**
26
+
***[Docs]** Documentation updates by **[Nebulosar](https://github.com/Nebulosar)** and **[mikehaertl](https://github.com/mikehaertl)**
27
+
***[Docker]** Changed base image to 7.3-cli by **[OneEyedSpaceFish](https://github.com/OneEyedSpaceFish)**
28
+
* Robo build:phar command can be used for building custom phar files again
29
+
* Improved file path detection for groups [#5609](https://github.com/Codeception/Codeception/issues/5609) by **[adaniloff](https://github.com/adaniloff)**
30
+
* Shortened error output of unexpected exit to one line by **[Slamdunk](https://github.com/Slamdunk)**
31
+
* Fixed composer.json of codeception/base package
10
32
#### 3.0.3
11
33
-**[Laravel5]** Add `make` and `makeMultiple` methods for generating model instance by **[ibpavlov](https://github.com/ibpavlov)**
12
34
-**[Lumen]** Add `make` and `makeMultiple` methods for generating model instance by **[ibpavlov](https://github.com/ibpavlov)**
One of the main advantages of Codeception is that you don't have to decide on just *one* type of testing. You can have all three!
34
+
One of the main advantages of Codeception is that you don't have to decide on just *one* type of testing. You should have all three!
35
35
And chances are, that you will (sooner or later) need all three. That's why Codeception consists of three so-called "suites":
36
36
A "unit suite" for all unit tests, a "functional suite" for all functional tests, and an "acceptance suite" for all acceptance tests.
37
37
38
38
Let's review those three testing types in reverse order.
39
39
40
40
### Acceptance Tests
41
41
42
-
How does your client, manager, tester, or any other non-technical person know your website is working?
43
-
By opening the browser, accessing the site, clicking on links, filling in the forms,
44
-
and actually seeing the content on a web page. They have no idea of the programming language, framework, database, web-server,
42
+
How does your client, manager, tester, or any other non-technical person know your website is working? By opening the browser, accessing the site, clicking on links, filling in the forms, and actually seeing the content on a web page. They have no idea of the programming language, framework, database, web-server,
45
43
or why the application did (or did not) behave as expected.
46
44
47
45
This is what acceptance tests are doing. They cover scenarios from a user's perspective.
48
46
With acceptance tests, you can be confident that users, following all the defined scenarios, won't get errors.
49
47
50
-
**Any website** can be covered with acceptance tests, even if you use a very exotic CMS or framework.
48
+
> **Any website** can be covered with acceptance tests, even if you use a very exotic CMS or framework.
51
49
52
50
#### Sample acceptance test
53
51
@@ -56,23 +54,22 @@ With acceptance tests, you can be confident that users, following all the define
What if we could check our application without running it on a server?
67
-
That way we could see detailed exceptions on errors, have our tests run faster,
68
-
and check the database against predictable and expected results. That's what functional tests are for.
67
+
What if you could check our application without running it on a server?
68
+
That way you could see detailed exceptions on errors, have our tests run faster, and check the database against predictable and expected results. That's what functional tests are for.
69
69
70
-
For functional tests, you emulate a web request (`$_GET` and `$_POST` variables)
71
-
which returns the HTML response. Inside a test, you can make assertions about the response,
72
-
and you can check if the data was successfully stored in the database.
70
+
For functional tests, you emulate a web request (`$_GET` and `$_POST` variables) which returns the HTML response. Inside a test, you can make assertions about the response, and you can check if the data was successfully stored in the database.
73
71
74
-
For functional tests, your application needs to be structured in order to run in a test environment.
75
-
Codeception provides connectors to several popular PHP frameworks. You can also write your own.
72
+
For functional tests, your application needs to be structured in order to run in a test environment. Codeception provides connectors to all popular PHP frameworks.
Despite the wide popularity of *TDD* (Test Driven Development), some PHP developers never write automated tests for their applications mostly because they think it's hard, slow or boring.
125
126
The Codeception framework was developed to actually make testing fun.
126
127
It allows writing unit, functional, integration, and acceptance tests in a single, coherent style.
127
128
128
-
It can be called a *BDD* (Behavior Driven Development) framework. All Codeception tests are written in a descriptive manner.
129
+
All Codeception tests are written in a descriptive manner.
129
130
Just by looking at the test body, you can clearly understand what is being tested and how it is performed.
130
-
Even complex tests with many assertions are written in a simple PHP Domain-Specific Language (*DSL*).
Copy file name to clipboardExpand all lines: docs/02-GettingStarted.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ Codeception follows simple naming rules to make it easy to remember (as well as
34
34
$I->dontSeeInPageSource('<sectionclass="foo">');
35
35
36
36
{% endhighlight %}
37
-
* **Grabbers** just *read* something from the page, but don't process it. The return value of those are meant to be saved as variables and used later. Example:
37
+
* **Grabbers** take information. The return value of those are meant to be saved as variables and used later. Example:
38
38
{% highlight php %}
39
39
40
40
<?php
@@ -45,13 +45,11 @@ Codeception follows simple naming rules to make it easy to remember (as well as
45
45
46
46
## Actors
47
47
48
-
One of the main concepts of Codeception is representation of tests as actions of a person.
49
-
We have a UnitTester, who executes functions and tests the code. We also have a FunctionalTester, a qualified tester,
48
+
One of the main concepts of Codeception is representation of tests as actions of a person.We have a UnitTester, who executes functions and tests the code. We also have a FunctionalTester, a qualified tester,
50
49
who tests the application as a whole, with knowledge of its internals. Lastly we have an AcceptanceTester, a user who works with our application
51
50
through an interface that we provide.
52
51
53
-
**Methods of actor classes are generally taken from [Codeception Modules](http://codeception.com/docs/06-ModulesAndHelpers)**.
54
-
Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment.
52
+
Methods of actor classes are generally taken from [Codeception Modules](http://codeception.com/docs/06-ModulesAndHelpers). Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment.
55
53
Codeception tries to solve 90% of possible testing issues in its modules, so you don't have to reinvent the wheel.
56
54
We think that you can spend more time on writing tests and less on writing support code to make those tests run.
57
55
By default, AcceptanceTester relies on PhpBrowser module, which is set in the `tests/acceptance.suite.yml` configuration file:
* Enable [RunProcess](http://codeception.com/extensions#RunProcess) extension to start/stop PhantomJS automatically *(optional)*.
451
-
452
439
#### ChromeDriver
453
440
454
441
ChromeDriver was created by Google to control Chrome and Chromium browsers programmatically.
@@ -610,7 +597,7 @@ Retries are disabled by default. To enable them you should add retry step decora
610
597
step_decorators:
611
598
- \Codeception\Step\Retry
612
599
613
-
{% endhighlight %}
600
+
{% endhighlight %}
614
601
615
602
Then add `\Codeception\Lib\Actor\Shared\Retry` trait into `AcceptanceTester` class:
616
603
@@ -702,7 +689,7 @@ A/B testing is disabled by default. To enable it you should add corresponding st
702
689
step_decorators:
703
690
- \Codeception\Step\TryTo
704
691
705
-
{% endhighlight %}
692
+
{% endhighlight %}
706
693
707
694
Then rebuild actors with `codecept build` command.
708
695
@@ -803,6 +790,98 @@ Additional debugging features by Codeception:
803
790
* [Interactive Pause](http://codeception.com/docs/02-GettingStarted#Interactive-Pause) is a REPL that allows to type and check commands for instant feedback.
804
791
* [Recorder Extension](http://codeception.com/addons#CodeceptionExtensionRecorder) allows to record tests step-by-steps and show them in slideshow
805
792
793
+
### Common Cases
794
+
795
+
<<<<<<< HEAD
796
+
Let's see how common problems of acceptance testing can be solved with Codeception.
797
+
798
+
#### Authorization
799
+
=======
800
+
Let's see how common problems of acceptance testing can be solved with Codeception. We will need to update actor class (whcih is AcceptanceTester) in our case to add a new action.
801
+
802
+
#### Login
803
+
>>>>>>> 82997221b762bc09876379f9f30906c9d364a4f5
804
+
805
+
It is recommended to put widely used actions inside an Actor class. A good example is the `login` action
806
+
which would probably be actively involved in acceptance or functional testing:
807
+
808
+
{% highlight php %}
809
+
810
+
<?php
811
+
class AcceptanceTester extends \Codeception\Actor
812
+
{
813
+
// do not ever remove this line!
814
+
use _generated\AcceptanceTesterActions;
815
+
816
+
public function login($name, $password)
817
+
{
818
+
$I = $this;
819
+
$I->amOnPage('/login');
820
+
$I->submitForm('#loginForm', [
821
+
'login' => $name,
822
+
'password' => $password
823
+
]);
824
+
$I->see($name, '.navbar');
825
+
}
826
+
}
827
+
828
+
{% endhighlight %}
829
+
830
+
Now you can use the `login` method inside your tests:
831
+
832
+
{% highlight php %}
833
+
834
+
<?php
835
+
// $I is AcceptanceTester
836
+
$I->login('miles', '123456');
837
+
838
+
{% endhighlight %}
839
+
840
+
However, implementing all actions for reuse in a single actor class may lead to
841
+
breaking the [Single Responsibility Principle](http://en.wikipedia.org/wiki/Single_responsibility_principle).
842
+
843
+
<<<<<<< HEAD
844
+
#### Session Snapshot
845
+
=======
846
+
#### Single Login
847
+
>>>>>>> 82997221b762bc09876379f9f30906c9d364a4f5
848
+
849
+
If you need to authorize a user for each test, you can do so by submitting the login form at the beginning of every test.
850
+
Running those steps takes time, and in the case of Selenium tests (which are slow by themselves)
851
+
that time loss can become significant.
852
+
853
+
Codeception allows you to share cookies between tests, so a test user can stay logged in for other tests.
854
+
855
+
Let's improve the code of our `login` method, executing the form submission only once
856
+
and restoring the session from cookies for each subsequent login function call:
857
+
858
+
{% highlight php %}
859
+
860
+
<?php
861
+
public function login($name, $password)
862
+
{
863
+
$I = $this;
864
+
// if snapshot exists - skipping login
865
+
if ($I->loadSessionSnapshot('login')) {
866
+
return;
867
+
}
868
+
// logging in
869
+
$I->amOnPage('/login');
870
+
$I->submitForm('#loginForm', [
871
+
'login' => $name,
872
+
'password' => $password
873
+
]);
874
+
$I->see($name, '.navbar');
875
+
// saving snapshot
876
+
$I->saveSessionSnapshot('login');
877
+
}
878
+
879
+
{% endhighlight %}
880
+
881
+
Note that session restoration only works for `WebDriver` modules
0 commit comments