@@ -89,19 +89,18 @@ public function testValidation()
89
89
}
90
90
```
91
91
92
- ## Purpose
92
+ ## Use Case
93
93
94
- This tiny library makes your tests a bit readable, by organizing test in well described code blocks.
95
- Each code block is isolated.
94
+ This tiny library makes your tests readable by organizing them in nested code blocks.
95
+ This allows to combine similar tests into one but put them inside nested sections.
96
96
97
- This means call to ` $this->specify ` does not change values of properties of a test class.
98
- Isolated properties should be marked with ` @specify ` annotation.
97
+ This is very similar to BDD syntax as in RSpec or Mocha but works inside PHPUnit:
99
98
100
99
``` php
101
100
<?php
102
- class UserTest extends PHPUnit\Framework\TestCase {
103
-
104
- use Codeception\Specify;
101
+ class UserTest extends PHPUnit\Framework\TestCase
102
+ {
103
+ use Codeception\Specify;
105
104
106
105
/** @specify */
107
106
protected $user; // is cloned inside specify blocks
@@ -120,10 +119,13 @@ class UserTest extends PHPUnit\Framework\TestCase {
120
119
});
121
120
// user name is davert again
122
121
$this->assertEquals('davert', $this->user->name);
123
- }
122
+ }
124
123
}
125
124
```
126
125
126
+ Each code block is isolated. This means call to ` $this->specify ` does not change values of properties of a test class.
127
+ Isolated properties should be marked with ` @specify ` annotation.
128
+
127
129
Failure in ` specify ` block won't get your test stopped.
128
130
129
131
``` php
@@ -180,9 +182,7 @@ $this->specify('this should not fail', function () {
180
182
});
181
183
```
182
184
183
- ## Examples
184
-
185
- DataProviders alternative
185
+ ## Examples: DataProviders alternative
186
186
187
187
``` php
188
188
<?php
0 commit comments