|
84 | 84 | <div></div> |
85 | 85 | </div><section style="max-width: 640px; margin-left: auto; margin-right: auto;"> |
86 | 86 | <article> |
87 | | -<p>The Webtau graphql. module lets you exercise and validate a GraphQL API. It provides a simplified way to access the JSON response of an end-point and provides a DSL to execute queries and mutations. Groovy package scenarios.rest import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario("check weather") { def query = "{ weather { temperature } }"; graphql.execute(query) { weather.temperature.shouldBe < 100 } } package com.example.tests.junit4 import org.junit.Test import org.junit.runner.RunWith import org.testingisdocumenting.webtau.junit4.WebTauRunner import static org.testingisdocumenting.webtau.WebTauDsl.graphql @RunWith(WebTauRunner.class) class GraphQLWeatherGroovyIT { @Test void checkWeather() { def query = "{ weather { temperature } }"; graphql.execute(query) { weather.temperature.shouldBe < 100 } } } json { "data": { "weather": { "temperature": 88 } } } Java package com.example.tests.junit4; import org.junit.Test; import org.junit.runner.RunWith; import org.testingisdocumenting.webtau.junit4.WebTauRunner; import static org.testingisdocumenting.webtau.WebTauDsl.*; @RunWith(WebTauRunner.class) public class GraphQLWeatherJavaIT { @Test public void checkWeather() { String query = "{ weather { temperature } }"; graphql.execute(query, (header, body) -> { body.get("data.weather.temperature").shouldBe(lessThan(100)); }); } } json { "data": { "weather": { "temperature": 88 } } } Before diving further into writing tests for your GraphQL server, please read through the HTTP testing documentation starting with the HTTP/data-node Data node page as much of the same core principles apply to GraphQL also.The main GraphQL specific features are covered in the subsequent pages: GraphQL/queries-and-mutations Queries and Mutations GraphQL/customized-graphql-urls Customized GraphQL URLs GraphQL/report Report</p> |
| 87 | +<p>Webtau graphql. module lets you exercise and validate a GraphQL API. It provides a simplified way to access the JSON response of an end-point and provides a DSL to execute queries and mutations. Groovy package scenarios.rest import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario("check weather") { def query = "{ weather { temperature } }"; graphql.execute(query) { weather.temperature.shouldBe < 100 } } package com.example.tests.junit4 import org.junit.Test import org.junit.runner.RunWith import org.testingisdocumenting.webtau.junit4.WebTauRunner import static org.testingisdocumenting.webtau.WebTauDsl.graphql @RunWith(WebTauRunner.class) class GraphQLWeatherGroovyIT { @Test void checkWeather() { def query = "{ weather { temperature } }"; graphql.execute(query) { weather.temperature.shouldBe < 100 } } } json { "data": { "weather": { "temperature": 88 } } } Java package com.example.tests.junit4; import org.junit.Test; import org.junit.runner.RunWith; import org.testingisdocumenting.webtau.junit4.WebTauRunner; import static org.testingisdocumenting.webtau.WebTauDsl.*; @RunWith(WebTauRunner.class) public class GraphQLWeatherJavaIT { @Test public void checkWeather() { String query = "{ weather { temperature } }"; graphql.execute(query, (header, body) -> { body.get("data.weather.temperature").shouldBe(lessThan(100)); }); } } json { "data": { "weather": { "temperature": 88 } } } Before diving further into writing tests for your GraphQL server, please read through the HTTP testing documentation starting with the HTTP/data-node Data node page as much of the same core principles apply to GraphQL also.The main GraphQL specific features are covered in the subsequent pages: GraphQL/queries-and-mutations Queries and Mutations GraphQL/customized-graphql-urls Customized GraphQL URLs GraphQL/report Report</p> |
88 | 88 | </article> |
89 | 89 | </section> |
90 | 90 | </div> |
91 | 91 | <script type="text/javascript" src="/webtau/footer.js"></script> |
92 | 92 | <script type="text/javascript" src="/webtau/toc.js"></script> |
| 93 | +<script type="text/javascript" src="/webtau/global-anchors.js"></script> |
93 | 94 | <script type="text/javascript" src="/webtau/documentation-references.js"></script> |
94 | 95 | <script type="text/javascript" src="/webtau/assets.js"></script> |
95 | 96 | <script type="text/javascript" src="/webtau/static/main.js"></script> |
|
114 | 115 | "content" : [ { |
115 | 116 | "type" : "Paragraph", |
116 | 117 | "content" : [ { |
117 | | - "text" : "The Webtau ", |
| 118 | + "text" : "Webtau ", |
118 | 119 | "type" : "SimpleText" |
119 | 120 | }, { |
120 | 121 | "code" : "graphql.", |
|
134 | 135 | "content" : [ { |
135 | 136 | "columns" : [ { |
136 | 137 | "content" : [ { |
137 | | - "lang" : "groovy", |
138 | 138 | "snippet" : "package scenarios.rest\n\nimport static org.testingisdocumenting.webtau.WebTauGroovyDsl.*\n\nscenario(\"check weather\") {\n def query = \"{ weather { temperature } }\";\n graphql.execute(query) {\n weather.temperature.shouldBe < 100\n }\n}", |
| 139 | + "type" : "Snippet", |
139 | 140 | "title" : "GraphQL API test (Groovy specific runner)", |
140 | | - "type" : "Snippet" |
| 141 | + "lang" : "groovy" |
141 | 142 | }, { |
142 | | - "lang" : "groovy", |
143 | 143 | "snippet" : "package com.example.tests.junit4\n\nimport org.junit.Test\nimport org.junit.runner.RunWith\nimport org.testingisdocumenting.webtau.junit4.WebTauRunner\n\nimport static org.testingisdocumenting.webtau.WebTauDsl.graphql\n\n@RunWith(WebTauRunner.class)\nclass GraphQLWeatherGroovyIT {\n @Test\n void checkWeather() {\n def query = \"{ weather { temperature } }\";\n graphql.execute(query) {\n weather.temperature.shouldBe < 100\n }\n }\n}", |
| 144 | + "type" : "Snippet", |
144 | 145 | "title" : "GraphQL API test (JUnit4)", |
145 | | - "type" : "Snippet" |
| 146 | + "lang" : "groovy" |
146 | 147 | } ] |
147 | 148 | }, { |
148 | 149 | "content" : [ { |
149 | | - "lang" : "json", |
150 | 150 | "snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n", |
151 | | - "lineNumber" : "", |
| 151 | + "type" : "Snippet", |
152 | 152 | "title" : "Server Response", |
153 | | - "type" : "Snippet" |
| 153 | + "lineNumber" : "", |
| 154 | + "lang" : "json" |
154 | 155 | } ] |
155 | 156 | } ], |
156 | | - "config" : { }, |
157 | | - "type" : "Columns" |
| 157 | + "type" : "Columns", |
| 158 | + "config" : { } |
158 | 159 | } ] |
159 | 160 | }, { |
160 | 161 | "name" : "Java", |
161 | 162 | "content" : [ { |
162 | 163 | "columns" : [ { |
163 | 164 | "content" : [ { |
164 | | - "lang" : "java", |
165 | 165 | "snippet" : "package com.example.tests.junit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.testingisdocumenting.webtau.junit4.WebTauRunner;\n\nimport static org.testingisdocumenting.webtau.WebTauDsl.*;\n\n@RunWith(WebTauRunner.class)\npublic class GraphQLWeatherJavaIT {\n @Test\n public void checkWeather() {\n String query = \"{ weather { temperature } }\";\n graphql.execute(query, (header, body) -> {\n body.get(\"data.weather.temperature\").shouldBe(lessThan(100));\n });\n }\n}", |
| 166 | + "type" : "Snippet", |
166 | 167 | "title" : "GraphQL API test (JUnit4 Java)", |
167 | | - "type" : "Snippet" |
| 168 | + "lang" : "java" |
168 | 169 | } ] |
169 | 170 | }, { |
170 | 171 | "content" : [ { |
171 | | - "lang" : "json", |
172 | 172 | "snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n", |
173 | | - "lineNumber" : "", |
| 173 | + "type" : "Snippet", |
174 | 174 | "title" : "Server Response", |
175 | | - "type" : "Snippet" |
| 175 | + "lineNumber" : "", |
| 176 | + "lang" : "json" |
176 | 177 | } ] |
177 | 178 | } ], |
178 | | - "config" : { }, |
179 | | - "type" : "Columns" |
| 179 | + "type" : "Columns", |
| 180 | + "config" : { } |
180 | 181 | } ] |
181 | 182 | } ], |
182 | 183 | "type" : "Tabs" |
|
191 | 192 | "text" : "starting with the ", |
192 | 193 | "type" : "SimpleText" |
193 | 194 | }, { |
194 | | - "url" : "/webtau/HTTP/data-node", |
195 | 195 | "isFile" : false, |
196 | 196 | "type" : "Link", |
197 | 197 | "content" : [ { |
198 | 198 | "text" : "Data node page", |
199 | 199 | "type" : "SimpleText" |
200 | | - } ] |
| 200 | + } ], |
| 201 | + "url" : "/webtau/HTTP/data-node" |
201 | 202 | }, { |
202 | 203 | "text" : " as much of the same core principles apply to GraphQL also.", |
203 | 204 | "type" : "SimpleText" |
|
210 | 211 | } ] |
211 | 212 | }, { |
212 | 213 | "bulletMarker" : "*", |
213 | | - "tight" : true, |
214 | 214 | "type" : "BulletList", |
| 215 | + "tight" : true, |
215 | 216 | "content" : [ { |
216 | 217 | "type" : "ListItem", |
217 | 218 | "content" : [ { |
218 | 219 | "type" : "Paragraph", |
219 | 220 | "content" : [ { |
220 | | - "url" : "/webtau/GraphQL/queries-and-mutations", |
221 | 221 | "isFile" : false, |
222 | 222 | "type" : "Link", |
223 | 223 | "content" : [ { |
224 | 224 | "text" : "Queries and Mutations", |
225 | 225 | "type" : "SimpleText" |
226 | | - } ] |
| 226 | + } ], |
| 227 | + "url" : "/webtau/GraphQL/queries-and-mutations" |
227 | 228 | } ] |
228 | 229 | } ] |
229 | 230 | }, { |
230 | 231 | "type" : "ListItem", |
231 | 232 | "content" : [ { |
232 | 233 | "type" : "Paragraph", |
233 | 234 | "content" : [ { |
234 | | - "url" : "/webtau/GraphQL/customized-graphql-urls", |
235 | 235 | "isFile" : false, |
236 | 236 | "type" : "Link", |
237 | 237 | "content" : [ { |
238 | 238 | "text" : "Customized GraphQL URLs", |
239 | 239 | "type" : "SimpleText" |
240 | | - } ] |
| 240 | + } ], |
| 241 | + "url" : "/webtau/GraphQL/customized-graphql-urls" |
241 | 242 | } ] |
242 | 243 | } ] |
243 | 244 | }, { |
244 | 245 | "type" : "ListItem", |
245 | 246 | "content" : [ { |
246 | 247 | "type" : "Paragraph", |
247 | 248 | "content" : [ { |
248 | | - "url" : "/webtau/GraphQL/report", |
249 | 249 | "isFile" : false, |
250 | 250 | "type" : "Link", |
251 | 251 | "content" : [ { |
252 | 252 | "text" : "Report", |
253 | 253 | "type" : "SimpleText" |
254 | | - } ] |
| 254 | + } ], |
| 255 | + "url" : "/webtau/GraphQL/report" |
255 | 256 | } ] |
256 | 257 | } ] |
257 | 258 | } ] |
258 | 259 | } ], |
259 | | - "lastModifiedTime" : 1634267317640, |
| 260 | + "lastModifiedTime" : 1640922026328, |
260 | 261 | "tocItem" : { |
261 | 262 | "sectionTitle" : "GraphQL", |
262 | 263 | "pageTitle" : "Introduction", |
|
0 commit comments