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: docs/guides/action-groups.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Action Group Best Practices
2
2
3
-
We should strive to write tests using only action groups. Fortunately we have built up a large set of action groups to get started. We can make use of them and extend them for our own specific needs. In some cases, we may never even need to write action groups of our own. We may be able to simply chain together calls to existing action groups to implement our new test case.
3
+
We strive to write tests using only action groups. Fortunately, we have built up a large set of action groups to get started. We can make use of them and extend them for our own specific needs. In some cases, we may never even need to write action groups of our own. We may be able to simply chain together calls to existing action groups to implement our new test case.
4
4
5
5
## Why use Action Groups?
6
6
@@ -23,15 +23,15 @@ Action groups simplify maintainability by reducing duplication. Because they are
23
23
</actionGroup>
24
24
```
25
25
26
-
As you may be able to guess, logging in to the admin panel is one of the most used action groups. It is used around 1,500 times at the time of this writing.
26
+
Logging in to the admin panel is one of the most used action groups. It is used around 1,500 times at the time of this writing.
27
27
28
-
Imagine if this wasn't an action group and instead we were to copy and paste these 5 actions so many times. In that scenario, if we need to make a small change it would require a lot of work. But with the action group, we can make the change in one place.
28
+
Imagine if this was not an action group and instead we were to copy and paste these 5 actions every time. In that scenario, if a small change was needed, it would require a lot of work. But with the action group, we can make the change in one place.
29
29
30
-
## How can I extend Action Groups?
30
+
## How to extend action groups
31
31
32
-
Let's continue using `LoginAsAdmin` as our example. I have trimmed away metadata to clearly reveal that this action group performs 5 actions:
32
+
Again using `LoginAsAdmin` as our example, we trim away metadata to clearly reveal that this action group performs 5 actions:
33
33
34
-
```
34
+
```xml
35
35
<actionGroupname="LoginAsAdmin">
36
36
...
37
37
<amOnPageurl="{{AdminLoginPage.url}}" .../>
@@ -42,29 +42,29 @@ Let's continue using `LoginAsAdmin` as our example. I have trimmed away metadata
42
42
</actionGroup>
43
43
```
44
44
45
-
This works against the standard Magento admin panel login page. But let's imagine we're working on a Magento extension that adds a CAPTCHA field to the login page. If we create and activate this extension and then we try to run all existing tests, we can expect almost everything to fail because now we are unable to log in because we did not completely fill out all of the login form. The CAPTCHA field was left unfilled.
45
+
This works against the standard Magento admin panel login page. Bu imagine we are working on a Magento extension that adds a CAPTCHA field to the login page. If we create and activate this extension and then run all existing tests, we can expect almost everything to fail because the CAPTCHA field is left unfilled.
46
46
47
-
We can overcome this by making use of MFTF's extensibility. All we need to do is to provide a "merge" that modifies the existing `LoginAsAdmin` action group. Our simple merge file will look like this:
47
+
We can overcome this by making use of MFTF's extensibility. All we need to do is to provide a "merge" that modifies the existing `LoginAsAdmin` action group. Our merge file will look like:
Because the name of this merge is also `LoginAsAdmin`, the two get merged together and an additional step happens everytime this action group is made use of.
55
+
Because the name of this merge is also `LoginAsAdmin`, the two get merged together and an additional step happens everytime this action group is used.
56
56
57
-
To continue this demonstration, let's imagine someone else is working on a TwoFactor Authentication extension and they also provide a merge for the `LoginAsAdmin` action group. Their merge looks similar to what we've already seen. The only difference is that this time we fill a different field:
57
+
To continue this example, imagine someone else is working on a 'Two-Factor Authentication' extension and they also provide a merge for the `LoginAsAdmin` action group. Their merge looks similar to what we have already seen. The only difference is that this time we fill a different field:
Bringing it all together, our resulting `LoginAsAdmin` action group becomes this:
66
66
67
-
```
67
+
```xml
68
68
<actionGroupname="LoginAsAdmin">
69
69
...
70
70
<amOnPageurl="{{AdminLoginPage.url}}" .../>
@@ -77,6 +77,6 @@ Bringing it all together, our resulting `LoginAsAdmin` action group becomes this
77
77
</actionGroup>
78
78
```
79
79
80
-
Note that no file actually contains these exact contents above, but instead all three files come together to form this action group.
80
+
No one file contains this exact content as above, but instead all three files come together to form this action group.
81
81
82
-
One final thing to be aware of is that this extensibility can be applied in many ways. Obviously we need to use it if we want to affect existing Magento entities like tests, action groups, and data. But something not so obvious is that this can be used within the walls of your own entities in order to make them more maintainable too.
82
+
This extensibility can be applied in many ways. We can use it to affect existing Magento entities such as tests, action groups, and data. Not so obvious is that this tehcnique can be used within your own entities to make them more maintainable as well.
0 commit comments