|
3 | 3 | title: Quick Start Codeception
|
4 | 4 | ---
|
5 | 5 |
|
6 |
| -<div class="page-header"> |
7 |
| - <h1>Codeception Quickstart Guide</h1> |
8 |
| -</div> |
9 |
| -<p class="lead">Codeception PHP Testing Framework is designed to work just out of the box. |
10 |
| - This means its installation requires minimal steps and no external dependencies |
11 |
| - preinstalled (except PHP, of course). Only one configuration step should |
12 |
| - be taken and you are ready to test your web application from an eye of |
13 |
| - actual user. </p> |
14 | 6 | <div class="row">
|
15 |
| - <div class="panel panel-info"> |
| 7 | + <div class="col-xs-12 col-md-9"> |
| 8 | + <h1>Codeception Quickstart Guide</h1> |
| 9 | + <p class="lead">Codeception PHP Testing Framework is designed to work just out of the box. |
| 10 | + This means its installation requires minimal steps and no external dependencies |
| 11 | + preinstalled (except PHP, of course). Only one configuration step should |
| 12 | + be taken and you are ready to test your web application from an eye of |
| 13 | + actual user.</p> |
| 14 | + <p> |
| 15 | + <strong class="text-info text-uppercase">Requirements: PHP5.3, CURL enabled</strong> |
| 16 | + </p> |
| 17 | + </div> <!-- /.col --> |
| 18 | +</div> <!-- /.row --> |
| 19 | + |
| 20 | +<div class="row"> |
| 21 | +<div class="col-xs-12 col-md-9"> |
| 22 | + <div class="panel panel-info"> |
16 | 23 | <div class="panel-heading"><h4 class="panel-title">1. Download</h4></div>
|
17 | 24 | <div class="panel-body">
|
18 |
| - |
19 |
| - <div class="container"> |
20 |
| - <div class="col-sm-6 col-lg-6"> |
21 |
| - <p>Download and save the |
22 |
| - <b>phar</b> archive to the root of your web application. </p> |
23 |
| - <a class="btn btn-lg btn-success" href="/thanks" target="_blank">Download Codeception</a> |
24 |
| - |
25 |
| - <p class="text-muted">Alternatively download it from console</p> |
26 |
| - <div> |
27 |
| - <pre><code>wget http://codeception.com/codecept.phar</code></pre> |
28 |
| - </div> |
| 25 | + <div class=""> |
| 26 | + <p class="lead">Install via Composer</p> |
| 27 | + <pre>$ composer require "codeception/codeception" <span class="text-muted">// ./vendor/bin/codecept</span></pre> |
| 28 | + <p><code class="text-muted">$ alias codecept='./vendor/bin/codecept'</code></p> |
29 | 29 | </div>
|
| 30 | +<hr> |
30 | 31 |
|
31 |
| - <div class="col-sm-6 col-lg-6"> |
32 |
| - <p>If you are using PHP 5.4 or PHP 5.5 < 5.5.9.</p> |
33 |
| - <a class="btn btn-lg btn-success" href="/thanks_php54" target="_blank">Download Codeception</a> |
34 |
| - |
35 |
| - <p class="text-muted">Alternatively download it from console</p> |
36 |
| - <div> |
37 |
| - <pre><code>wget http://codeception.com/php54/codecept.phar</code></pre> |
38 |
| - </div> |
39 |
| - </div> |
| 32 | +<p class="lead">Install PHAR locally</p> |
40 | 33 |
|
41 |
| - <div class="col-sm-6 col-lg-6"> |
42 |
| - Install via Composer |
| 34 | +<!-- phar --> |
| 35 | +<pre>$ wget http://codeception.com/codecept.phar<a href="/thanks" style="float:right" target="_blank">download <span class="glyphicon glyphicon-download"></span></a></pre> |
43 | 36 |
|
44 |
| -<pre><code>php composer.phar require "codeception/codeception:*"</code></pre> |
45 |
| - |
46 |
| -<p>Use <code>./vendor/bin/codecept</code> instead of codecept.phar in this case.</p> |
47 |
| - |
48 |
| - </div> |
| 37 | +<!-- phar php54 --> |
| 38 | +<pre>$ wget http://codeception.com/php54/codecept.phar <span class="text-muted">// PHP 5.4 >= 5.5.9</span><a href="/thanks_php54" style="float:right" target="_blank">download <span class="glyphicon glyphicon-download"></span></a></pre> |
| 39 | +<p><code class="text-muted">$ alias codecept='codecept.phar'</code></p> |
| 40 | + <div> |
| 41 | + </div> |
49 | 42 |
|
50 |
| - <div class="col-sm-6 col-lg-6"> |
51 |
| - Install Globally |
| 43 | +<hr> |
| 44 | + <p class="lead">Install PHAR globally</p> |
| 45 | + <pre>sudo curl -LsS http://codeception.com/codecept.phar -o /usr/local/bin/codecept</pre> |
| 46 | + <pre>sudo chmod a+x /usr/local/bin/codecept</pre> |
| 47 | + <p><code class="text-muted">$ codecept</code></p> |
52 | 48 |
|
53 |
| - <pre><code>sudo curl -LsS http://codeception.com/codecept.phar -o /usr/local/bin/codecept</code></pre> |
54 |
| - <pre><code>sudo chmod a+x /usr/local/bin/codecept</code></pre> |
55 |
| - <p>Use <code>codecept</code> instead of codecept.phar in this case.</p> |
| 49 | + <!-- <p>Use <code>codecept</code> instead of codecept.phar in this case.</p> --> |
| 50 | + </div> <!-- /.panel-body --> |
| 51 | + </div> <!-- /.panel --> |
56 | 52 |
|
| 53 | + <div class="panel panel-info"> |
| 54 | + <div class="panel-heading"><h4 class="panel-title">2. Install</h4></div> |
| 55 | + <div class="panel-body"> |
| 56 | + <p>Open console directory where you saved codecept.phar file and execute:</p> |
| 57 | + <div> |
| 58 | + <p> |
| 59 | + <pre>php codecept.phar bootstrap</pre> |
| 60 | + </p> |
57 | 61 | </div>
|
58 |
| - </div> |
59 |
| - |
| 62 | + <p class="text-muted">This creates |
| 63 | + <b>codeception.yml</b> file and <b>tests</b> directory.</p> |
| 64 | + </div> <!-- /.panel-body --> |
| 65 | + </div> <!-- /.panel --> |
| 66 | + |
| 67 | + <div class="panel panel-info"> |
| 68 | + <div class="panel-heading"><h4 class="panel-title">3. Create Test</h4></div> |
| 69 | + <div class="panel-body"> |
| 70 | + <p>Generate your first acceptance test. Acceptance tests emulate behavior |
| 71 | + of a real user visiting your site.</p> |
| 72 | + <div> |
| 73 | + <p> |
| 74 | + <pre>php codecept.phar generate:cept acceptance Welcome</pre> |
| 75 | + </p> |
| 76 | + </div> |
| 77 | + <p class="text-muted">Codeception scenario tests are called Cepts.</p> |
| 78 | + </div> <!-- /.panel-body --> |
| 79 | + </div> <!-- /.panel --> |
60 | 80 |
|
61 |
| - </div> |
62 |
| - </div> |
63 |
| - <div class="panel panel-info"> |
64 |
| - <div class="panel-heading"><h4 class="panel-title">2. Install</h4></div> |
65 |
| - <div class="panel-body"> |
66 |
| - <p>Open console directory where you saved codecept.phar file and execute:</p> |
67 |
| - <div> |
68 |
| - <p> |
69 |
| - <pre><code>php codecept.phar bootstrap</code></pre> |
70 |
| - </p> |
71 |
| - </div> |
72 |
| - <p class="text-muted">This creates |
73 |
| - <b>codeception.yml</b> file and |
74 |
| - <b>tests</b> directory.</p> |
75 |
| - </div> |
| 81 | +<div class="panel panel-info"> |
| 82 | + <div class="panel-heading"> |
| 83 | + <h4 class="panel-title">4. Write Basic Test</h4> |
76 | 84 | </div>
|
77 |
| - <div class="panel panel-info"> |
78 |
| - <div class="panel-heading"><h4 class="panel-title">3. Create Test</h4></div> |
79 |
| - <div class="panel-body"> |
80 |
| - <p>Generate your first acceptance test. Acceptance tests emulate behavior |
81 |
| - of a real user visiting your site.</p> |
82 |
| - <div> |
83 |
| - <p> |
84 |
| - <pre><code>php codecept.phar generate:cept acceptance Welcome</code></pre> |
85 |
| - </p> |
86 |
| - </div> |
87 |
| - <p class="text-muted">Codeception scenario tests are called Cepts.</p> |
88 |
| - </div> |
89 |
| - </div> |
90 |
| - <div class="panel panel-info"> |
91 |
| - <div class="panel-heading"><h4 class="panel-title">4. Write Basic Test</h4></div> |
92 |
| - <div class="panel-body"> |
93 |
| - <p>It's now time to write your first test. Edit the file we've just created |
94 |
| - <b>tests/acceptance/WelcomeCept.php</b> |
95 |
| - </p> |
96 |
| - <div> |
97 |
| - {% highlight php %} |
98 |
| -<?php |
99 |
| -$I = new AcceptanceTester($scenario); |
100 |
| -$I->wantTo('ensure that frontpage works'); |
101 |
| -$I->amOnPage('/'); |
102 |
| -$I->see('Home'); |
103 |
| -?>{% endhighlight %} |
104 |
| - |
105 |
| - </div> |
106 |
| - <p class="text-muted">It will check that your frontpage contains the word |
107 |
| - <b>Home</b> in it.</p> |
108 |
| - </div> |
| 85 | + <div class="panel-body"> |
| 86 | + <p>It's now time to write your first test. Edit the file we've just created |
| 87 | + <b>tests/acceptance/WelcomeCept.php</b> |
| 88 | + </p> |
| 89 | + <div> |
| 90 | + {% highlight php %} |
| 91 | + <?php |
| 92 | + $I = new AcceptanceTester($scenario); |
| 93 | + $I->wantTo('ensure that frontpage works'); |
| 94 | + $I->amOnPage('/'); |
| 95 | + $I->see('Home'); |
| 96 | + ?>{% endhighlight %} |
109 | 97 | </div>
|
110 |
| - <div class="panel panel-info"> |
111 |
| - <div class="panel-heading"><h4 class="panel-title">5. Configure Acceptance Tests</h4></div> |
112 |
| - <div class="panel-body"> |
113 |
| - <p>Please make sure your local |
114 |
| - <b>dev server</b>is running. Put application URL into: |
115 |
| - <b>tests/acceptance.suite.yml</b> </p> |
116 |
| - <div> |
117 |
| - <pre> |
118 |
| -class_name: AcceptanceTester |
119 |
| -modules: |
120 |
| - enabled: |
| 98 | + <p class="text-muted">It will check that your frontpage contains the word <b>Home</b> in it.</p> |
| 99 | + </div> <!-- /.panel-body --> |
| 100 | + </div> <!-- /.panel --> |
| 101 | + |
| 102 | +<div class="panel panel-info"> |
| 103 | +<div class="panel-heading"><h4 class="panel-title">5. Configure Acceptance Tests</h4></div> |
| 104 | +<div class="panel-body"> |
| 105 | + <p>Please make sure your local |
| 106 | + <b>dev server</b>is running. Put application URL into: |
| 107 | + <b>tests/acceptance.suite.yml</b> </p> |
| 108 | + <div> |
| 109 | + <pre> |
| 110 | + class_name: AcceptanceTester |
| 111 | + modules: |
| 112 | + enabled: |
121 | 113 | - PhpBrowser:
|
122 |
| - url: {YOUR APP'S URL} |
| 114 | + url: {YOUR APP'S URL} |
123 | 115 | - \Helper\Acceptance
|
124 |
| - </pre> |
125 |
| - </div> |
126 |
| - </div> |
| 116 | + </pre> |
127 | 117 | </div>
|
128 |
| - <div class="panel panel-info"> |
129 |
| - <div class="panel-heading"><h4 class="panel-title">6. Run!</h4></div> |
130 |
| - <div class="panel-body"> |
131 |
| - <p>Codeception are executed with 'run' command</p> |
132 |
| - <div> |
133 |
| - <p> |
134 |
| - <pre><code>php codecept.phar run</code></pre> |
135 |
| - </p> |
136 |
| - </div> |
137 |
| - <p class="text-muted">This will execute our Welcome test with |
138 |
| - <b>PhpBrowser</b>. It's PHP script that can check HTML page contents, click |
139 |
| - links, fill forms, and submit POST and GET requests. For more complex tests |
140 |
| - that require a browser use Selenium with |
141 |
| - <b>WebDriver</b> module.</p> |
142 |
| - </div> |
143 |
| -</div> |
144 |
| -</div> |
145 |
| -<div class="container"> |
146 |
| -<div class="row"> |
147 |
| - |
148 |
| - <div class="col-sm-8 col-lg-8"> |
| 118 | + </div> <!-- /.panel-body --> |
| 119 | + </div> <!-- /.panel --> |
149 | 120 |
|
150 |
| - <div class="panel panel-success"> |
151 |
| - <div class="panel-heading">If you did everything right and your app has "Home" text on frontpage you |
152 |
| - will see this in output</div> |
| 121 | +<div class="panel panel-info"> |
| 122 | + <div class="panel-heading"><h4 class="panel-title">6. Run!</h4></div> |
153 | 123 | <div class="panel-body">
|
154 |
| - <pre><code>Suite acceptance started |
155 |
| -Trying to <b>ensure that frontpage works</b> (WelcomeCept.php) - Ok |
156 |
| -Suite functional started |
157 |
| -Suite unit started |
| 124 | + <p>Codeception are executed with 'run' command</p> |
| 125 | + <div> |
| 126 | + <p> |
| 127 | + <pre>php codecept.phar run</pre> |
| 128 | + </p> |
| 129 | + </div> |
| 130 | + <p class="text-muted">This will execute our Welcome test with |
| 131 | + <b>PhpBrowser</b>. It's PHP script that can check HTML page contents, click |
| 132 | + links, fill forms, and submit POST and GET requests. For more complex tests |
| 133 | + that require a browser use Selenium with |
| 134 | + <b>WebDriver</b> module.</p> |
| 135 | + </div> <!-- /.panel-body --> |
| 136 | + </div> <!-- /.panel --> |
| 137 | +</div> <!-- /.col --> |
| 138 | +</div> <!-- /.row --> |
158 | 139 |
|
159 |
| -Time: 1 second, Memory: 21.00Mb |
160 |
| -<b>OK (1 test, 1 assertions)</b></code></pre> |
161 |
| - </div> |
162 |
| -</div> |
| 140 | +<div class="container"> |
| 141 | + <div class="row"> |
| 142 | +<div class="col-sm-8 col-lg-8"> |
| 143 | +<div class="panel panel-success"> |
| 144 | +<div class="panel-heading">If you did everything right and your app has "Home" text on frontpage you |
| 145 | + will see this in output</div> |
| 146 | + <div class="panel-body"> |
| 147 | + <pre><code>Suite acceptance started |
| 148 | + Trying to <b>ensure that frontpage works</b> (WelcomeCept.php) - Ok |
| 149 | + Suite functional started |
| 150 | + Suite unit started |
| 151 | + |
| 152 | + Time: 1 second, Memory: 21.00Mb |
| 153 | + <b>OK (1 test, 1 assertions)</b></code></pre> |
| 154 | + </div> <!-- /.panel-body --> |
| 155 | + </div> <!-- /.panel --> |
163 | 156 | </div>
|
164 | 157 |
|
165 |
| - |
166 |
| - <div class="col-sm-4 col-lg-4"> |
167 |
| - <p>Follow the Acceptance Testing chapter to learn how to test your |
168 |
| - web application by clicking links, filling forms, as your regular users |
169 |
| - do.</p> |
170 |
| - <div class="list-group"> |
171 |
| - <a class="list-group-item" href="/docs/02-GettingStarted">A Complete Getting Started Guide</a> |
172 |
| - <a class="list-group-item active" href="/docs/03-AcceptanceTests">Continue with Acceptance Tests</a> |
173 |
| - <a class="list-group-item" href="/docs/01-Introduction">The difference between Acceptance Tests and Unit Tests</a> |
174 |
| - </div> |
| 158 | +<div class="col-sm-4 col-lg-4"> |
| 159 | +<p>Follow the Acceptance Testing chapter to learn how to test your |
| 160 | + web application by clicking links, filling forms, as your regular users |
| 161 | + do.</p> |
| 162 | + <div class="list-group"> |
| 163 | + <a class="list-group-item" href="/docs/02-GettingStarted">A Complete Getting Started Guide</a> |
| 164 | + <a class="list-group-item active" href="/docs/03-AcceptanceTests">Continue with Acceptance Tests</a> |
| 165 | + <a class="list-group-item" href="/docs/01-Introduction">The difference between Acceptance Tests and Unit Tests</a> |
175 | 166 | </div>
|
176 | 167 | </div>
|
177 | 168 | </div>
|
| 169 | +</div> |
0 commit comments