1+ ---
2+ layout: bootstrap
3+ title: Quick Start Codeception
4+ ---
5+
6+ < div class ="page-header ">
7+ < h1 > Codeception Quickstart Guide</ h1 >
8+ </ div >
9+ < p class ="lead "> Codeception PHP Testing Framework is designed work just out of the box.
10+ This means it's 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+ < div class ="row ">
15+ < div class ="span4 ">
16+ < div class ="well ">
17+ < span class ="badge badge-warning pull-right "> Step 1</ span >
18+ < h4 > 1. Download</ h4 >
19+ < p > Download and save the
20+ < b > phar</ b > archive to the root of your web application. </ p >
21+ < a class ="btn btn-large btn-success "
22+ href ="# "> < span class ="btn-label "> Download Codeception</ span > </ a >
23+ < p class ="muted "> alternatively download it from terminal</ p >
24+ < div >
25+ < p >
26+ < code > wget http://codeception.com/codecept.phar .</ code >
27+ </ p >
28+ </ div >
29+ </ div >
30+ </ div >
31+ < div class ="span4 ">
32+ < div class ="well ">
33+ < span class ="badge badge-warning pull-right "> Step 2</ span >
34+ < h4 > 2. Install</ h4 >
35+ < p > Open console directory where you saved codecept.phar file and execute:</ p >
36+ < div >
37+ < p >
38+ < code > php codecept.phar bootstrap</ code >
39+ </ p >
40+ </ div >
41+ < p class ="muted "> This creates
42+ < b > codeception.yml</ b > file and
43+ < b > tests</ b > directory. </ p >
44+ </ div >
45+ </ div >
46+ < div class ="span4 ">
47+ < div class ="well ">
48+ < span class ="badge badge-warning pull-right "> Step 3</ span >
49+ < h4 > 3. Create Test</ h4 >
50+ < p > Generate your first acceptance test. Acceptance tests emulate behavior
51+ of a real user visiting your site.</ p >
52+ < div >
53+ < p >
54+ < code > php codecept.phar generate:cept Welcome</ code >
55+ </ p >
56+ </ div >
57+ < p class ="muted "> Codeception scenario tests are called Cepts.</ p >
58+ </ div >
59+ </ div >
60+ </ div >
61+ < div class ="container ">
62+ < div class ="row ">
63+ < div class ="span4 ">
64+ < div class ="well ">
65+ < span class ="badge badge-warning pull-right "> Step 4</ span >
66+ < h4 > 4. Write Basic Test</ h4 >
67+ < p > It's not time to write your first test. Edit the file we've just created
68+ < b > tests/acceptance/WelcomeCept.php </ b >
69+ </ p >
70+ < div >
71+ < p > </ p >
72+ < pre > $I = new WebGuy($scenario); $I->wantTo('ensure that frontpage works');
73+ $I->amOnPage('/'); $I->see('Home');</ pre >
74+ < p > </ p >
75+ </ div >
76+ < p class ="muted "> It will check that your frontpage contains the word
77+ < b > Home</ b > in it.</ p >
78+ </ div >
79+ </ div >
80+ < div class ="span4 ">
81+ < div class ="well ">
82+ < span class ="badge badge-warning pull-right "> Step 5</ span >
83+ < h4 > 5. Configure Acceptance Tests</ h4 >
84+ < p > Please make sure your local
85+ < b > dev server</ b > is running. Put application URL into:
86+ < b > tests/acceptance.suite.yml</ b > </ p >
87+ < div >
88+ < p > </ p >
89+ < pre > class_name: WebGuy modules: enabled: [PhpBrowser, WebHelper] config: PhpBrowser:
90+ url: '
91+ < b > {YOUR APP'S URL}</ b > '</ pre >
92+ < p > </ p >
93+ </ div >
94+ </ div >
95+ </ div >
96+ < div class ="span4 ">
97+ < div class ="well ">
98+ < span class ="badge badge-warning pull-right "> Final Step</ span >
99+ < h4 > 6. Run!</ h4 >
100+ < p > Codeception are executed with 'run' command</ p >
101+ < div >
102+ < p >
103+ < code > php codecept.phar run</ code >
104+ </ p >
105+ </ div >
106+ < p class ="muted "> This will execute our Welcome test with
107+ < b > PhpBrowser</ b > . It's PHP script that can check HTML page contents, click
108+ links, fill forms, and submit POST and GET requests. For more complex tests
109+ that require a browser use Selenium with
110+ < b > Selenium2</ b > module.</ p >
111+ </ div >
112+ </ div >
113+ </ div >
114+ </ div >
115+ < div class ="row ">
116+ < div class ="span6 ">
117+ < p > If you did everything right and your app has Home text on frontpage you
118+ will see this in output</ p >
119+ < div >
120+ < pre > Suite acceptance started Trying
121+ < b > ensure that frontpage works</ b > (WelcomeCept.php) - Ok Suite functional
122+ started Suite unit started Time: 1 second, Memory: 21.00Mb
123+ < b > OK (1 test, 1 assertions)</ b >
124+ </ pre >
125+ </ div >
126+ </ div >
127+ < div class ="span6 ">
128+ < div class ="btn-group "> </ div >
129+ < a class ="btn btn-large btn-info pull-right " href ="# "> < span class ="btn-label "> Proceed Testing -></ span > </ a >
130+ < p class =" lead "> Follow the Acceptance Testing chapter to learn how to test your
131+ web application by clicking links, filling forms, as your regular users
132+ do. </ p >
133+ < h4 > Also to Read</ h4 >
134+ < div >
135+ < br >
136+ </ div >
137+ < div >
138+ < ul >
139+ < li > Alternative Installations (PEAR, Composer)</ li >
140+ < li > A Complete Getting Started Guide</ li >
141+ < li > What's the difference between Acceptance Tests and Unit Tests?</ li >
142+ </ ul >
143+ </ div >
144+ < p > </ p >
145+ </ div >
146+ </ div >
0 commit comments