|
| 1 | +# Extend tests |
| 2 | + |
| 3 | +Data objects can be merged to cover the needs of your extension. |
| 4 | + |
| 5 | +In this example, we add an action group to a new copy of the original test for our extension. |
| 6 | + |
| 7 | +## Starting test |
| 8 | + |
| 9 | +```xml |
| 10 | +<test name="AdminCreateSimpleProductTest"> |
| 11 | + <annotations> |
| 12 | + <features value="Catalog"/> |
| 13 | + <stories value="Create a Simple Product via Admin"/> |
| 14 | + <title value="Admin should be able to create a Simple Product"/> |
| 15 | + <description value="Admin should be able to create a Simple Product"/> |
| 16 | + <severity value="CRITICAL"/> |
| 17 | + <testCaseId value="MAGETWO-23414"/> |
| 18 | + <group value="product"/> |
| 19 | + </annotations> |
| 20 | + <before> |
| 21 | + <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> |
| 22 | + </before> |
| 23 | + <after> |
| 24 | + <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> |
| 25 | + <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> |
| 26 | + </after> |
| 27 | + |
| 28 | + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> |
| 29 | + <actionGroup ref="FillAdminSimpleProductForm" stepKey="fillProductFieldsInAdmin"> |
| 30 | + <argument name="category" value="$$createPreReqCategory$$"/> |
| 31 | + <argument name="simpleProduct" value="_defaultProduct"/> |
| 32 | + </actionGroup> |
| 33 | + <actionGroup ref="AssertProductInStorefrontCategoryPage" stepKey="assertProductInStorefront1"> |
| 34 | + <argument name="category" value="$$createPreReqCategory$$"/> |
| 35 | + <argument name="product" value="_defaultProduct"/> |
| 36 | + </actionGroup> |
| 37 | + <actionGroup ref="AssertProductInStorefrontProductPage" stepKey="assertProductInStorefront2"> |
| 38 | + <argument name="product" value="_defaultProduct"/> |
| 39 | + </actionGroup> |
| 40 | +</test> |
| 41 | +``` |
| 42 | + |
| 43 | +## File to merge |
| 44 | + |
| 45 | +```xml |
| 46 | +<test name="AdminCreateSimpleProductExtensionTest" extends="AdminCreateSimpleProductTest"> |
| 47 | + <!-- Since this is its own test you need the annotations block --> |
| 48 | + <annotations> |
| 49 | + <features value="Catalog"/> |
| 50 | + <stories value="Create a Simple Product via Admin"/> <!-- you should leave this the same since it is part of the same group --> |
| 51 | + <title value="Admin should be able to create a Simple Product with my extension"/> |
| 52 | + <description value="Admin should be able to create a Simple Product with my extension via the product grid"/> |
| 53 | + <severity value="CRITICAL"/> |
| 54 | + <testCaseId value="Extension/Github Issue Number"/> |
| 55 | + <group value="product"/> |
| 56 | + </annotations> |
| 57 | + <!-- This will be added after the step "fillProductFieldsInAdmin" on line 20 in the above test. --> |
| 58 | + <actionGroup ref="AddMyExtensionData" stepKey="extensionField" after="fillProductFieldsInAdmin"> |
| 59 | + <argument name="extensionData" value="_myData"/> |
| 60 | + </actionGroup> |
| 61 | + |
| 62 | + <!-- This will be added after the step "assertProductInStorefront2" on line 28 in the above test. --> |
| 63 | + <actionGroup ref="AssertMyExtensionDataExists" stepKey="assertExtensionInformation" after="assertProductInStorefront2"> |
| 64 | + <argument name="extensionData" value="_myData"/> |
| 65 | + </actionGroup> |
| 66 | +</test> |
| 67 | +``` |
| 68 | + |
| 69 | +## Resultant test |
| 70 | + |
| 71 | +Note that there are now two tests below. |
| 72 | + |
| 73 | +```xml |
| 74 | +<test name="AdminCreateSimpleProductTest"> |
| 75 | + <annotations> |
| 76 | + <features value="Catalog"/> |
| 77 | + <stories value="Create a Simple Product via Admin"/> |
| 78 | + <title value="Admin should be able to create a Simple Product"/> |
| 79 | + <description value="Admin should be able to create a Simple Product"/> |
| 80 | + <severity value="CRITICAL"/> |
| 81 | + <testCaseId value="MAGETWO-23414"/> |
| 82 | + <group value="product"/> |
| 83 | + </annotations> |
| 84 | + <before> |
| 85 | + <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> |
| 86 | + </before> |
| 87 | + <after> |
| 88 | + <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> |
| 89 | + <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> |
| 90 | + </after> |
| 91 | + |
| 92 | + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> |
| 93 | + <actionGroup ref="FillAdminSimpleProductForm" stepKey="fillProductFieldsInAdmin"> |
| 94 | + <argument name="category" value="$$createPreReqCategory$$"/> |
| 95 | + <argument name="simpleProduct" value="_defaultProduct"/> |
| 96 | + </actionGroup> |
| 97 | + <actionGroup ref="AssertProductInStorefrontCategoryPage" stepKey="assertProductInStorefront1"> |
| 98 | + <argument name="category" value="$$createPreReqCategory$$"/> |
| 99 | + <argument name="product" value="_defaultProduct"/> |
| 100 | + </actionGroup> |
| 101 | + <actionGroup ref="AssertProductInStorefrontProductPage" stepKey="assertProductInStorefront2"> |
| 102 | + <argument name="product" value="_defaultProduct"/> |
| 103 | + </actionGroup> |
| 104 | +</test> |
| 105 | +<test name="AdminCreateSimpleProductExtensionTest"> |
| 106 | + <annotations> |
| 107 | + <features value="Catalog"/> |
| 108 | + <stories value="Create a Simple Product via Admin"/> |
| 109 | + <title value="Admin should be able to create a Simple Product with my extension"/> |
| 110 | + <description value="Admin should be able to create a Simple Product with my extension via the product grid"/> |
| 111 | + <severity value="CRITICAL"/> |
| 112 | + <testCaseId value="Extension/Github Issue Number"/> |
| 113 | + <group value="product"/> |
| 114 | + </annotations> |
| 115 | + <before> |
| 116 | + <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> |
| 117 | + </before> |
| 118 | + <after> |
| 119 | + <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> |
| 120 | + <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> |
| 121 | + </after> |
| 122 | + |
| 123 | + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> |
| 124 | + <actionGroup ref="FillAdminSimpleProductForm" stepKey="fillProductFieldsInAdmin"> |
| 125 | + <argument name="category" value="$$createPreReqCategory$$"/> |
| 126 | + <argument name="simpleProduct" value="_defaultProduct"/> |
| 127 | + </actionGroup> |
| 128 | + |
| 129 | + <actionGroup ref="AddMyExtensionData" stepKey="extensionField"> |
| 130 | + <argument name="extensionData" value="_myData"/> |
| 131 | + </actionGroup> |
| 132 | + |
| 133 | + <actionGroup ref="AssertProductInStorefrontCategoryPage" stepKey="assertProductInStorefront1"> |
| 134 | + <argument name="category" value="$$createPreReqCategory$$"/> |
| 135 | + <argument name="product" value="_defaultProduct"/> |
| 136 | + </actionGroup> |
| 137 | + <actionGroup ref="AssertProductInStorefrontProductPage" stepKey="assertProductInStorefront2"> |
| 138 | + <argument name="product" value="_defaultProduct"/> |
| 139 | + </actionGroup> |
| 140 | + |
| 141 | + <actionGroup ref="AssertMyExtensionDataExists" stepKey="assertExtensionInformation"> |
| 142 | + <argument name="extensionData" value="_myData"/> |
| 143 | + </actionGroup> |
| 144 | +</test> |
| 145 | +``` |
0 commit comments