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
Copy file name to clipboardExpand all lines: README.md
+36-26Lines changed: 36 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,55 +12,65 @@ Find unused and duplicated definitions easily – without running Behat test
12
12
composer require behastan/behastan --dev
13
13
```
14
14
15
-
## Features
15
+
## Usage
16
16
17
-
## 1. Find duplicated definitions
17
+
```bash
18
+
vendor/bin/behastan analyse tests
19
+
```
20
+
21
+
<br>
18
22
19
-
Some definitions have very similar masks, but even identical contents. Better use a one definitions with exact mask, to make your tests more precise and easier to maintain:
Some definitions have similar masks, even identical contents. Better use a one definitions with exact mask, to make your tests more precise and easier to maintain:
25
38
26
39
<br>
27
40
28
-
## 2. Find unused Behat definitions with static analysis
41
+
###2. Find duplicate masks
29
42
30
-
Behat uses `@When()`, `@Then()` and `@Given()` annotations and their PHP 8 attribute alternatives to define method to be called in `*.feature` files. Sometimes test change and lines from `*.feature` files are deleted. But what about definitions?
43
+
* identifier: `duplicated-masks`
31
44
32
-
This command helps you to spot definitions that are no longer needed. Just provide test directory (1 or more) and let it statically compare defined and used masks:
45
+
Same as services, there should be no 2 same definition masks. Make them unique with different behavior, or merge them and use one definition instead.
33
46
34
-
```bash
35
-
vendor/bin/behastan unused-definitions tests
36
-
```
47
+
<br>
37
48
38
-
↓
49
+
### 3. Find unused Behat definitions with static analysis
39
50
40
-
```bash
41
-
Checking static, named and regex masks from 100 *Feature files
Behat uses `@When()`, `@Then()` and `@Given()` annotations or attributes to define a class method that is called in `*.feature` files. Sometimes test change and lines from `*.feature` files are deleted. But what about definitions?
45
54
46
-
* 747 exact
47
-
* 106 /regex/
48
-
* 181 :named
55
+
This rule spots definitions that are no longer needed.
49
56
50
-
1036/1036 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
57
+
<br>
51
58
52
-
the product price is :value
53
-
tests/Behat/ProductContext.php
59
+
## Output example
54
60
55
-
/^I submit order form and see payment page$/
56
-
tests/Behat/OrderContext.php
61
+
```bash
62
+
Found 127 Context and 225 feature files
63
+
Extracting definitions masks...
57
64
65
+
Found 1367 masks:
66
+
* 863 exact
67
+
* 204 /regex/
68
+
* 298 :named
58
69
59
-
[ERROR] Found 2 unused definitions
70
+
Running analysis...
60
71
```
61
72
62
-
You can also add this command to CI, to get instant feedback about unused definitions.
63
-
73
+
Add this command to CI, to get instant feedback of any changes.
0 commit comments