|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8" /> |
| 5 | +<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> |
| 6 | +<title>WebTau: Introduction</title> |
| 7 | +<link rel="stylesheet" type="text/css" href="/webtau/static/css/katex.min.css"> |
| 8 | +<link rel="stylesheet" type="text/css" href="/webtau/static/main.css"> |
| 9 | +<link rel="stylesheet" type="text/css" href="/webtau/logo.css"> |
| 10 | +<link rel="stylesheet" type="text/css" href="/webtau/static/css/global-overrides.css"> |
| 11 | +</head> |
| 12 | +<link rel="shortcut icon" href="/webtau/favicon.png"type="image/ico"/> |
| 13 | +<body class="theme-znai-dark"> |
| 14 | +<script>(function() { |
| 15 | + var themeNameKey = 'znaiTheme'; |
| 16 | + var darkThemeName = 'znai-dark'; |
| 17 | + var lightThemeName = 'default'; |
| 18 | + |
| 19 | + var znaiTheme = { |
| 20 | + changeHandlers: [], |
| 21 | + addChangeHandler(handler) { |
| 22 | + this.changeHandlers.push(handler); |
| 23 | + }, |
| 24 | + removeChangeHandler(handler) { |
| 25 | + var idx = this.changeHandlers.indexOf(handler); |
| 26 | + this.changeHandlers.splice(idx, 1); |
| 27 | + }, |
| 28 | + set(name) { |
| 29 | + this.name = name; |
| 30 | + document.body.className = 'theme-' + name; |
| 31 | + |
| 32 | + var idx = 0; |
| 33 | + var len = this.changeHandlers.length; |
| 34 | + for (; idx < len; idx++) { |
| 35 | + this.changeHandlers[idx](name); |
| 36 | + } |
| 37 | + }, |
| 38 | + setExplicitly(name) { |
| 39 | + storeThemeName(name); |
| 40 | + this.set(name); |
| 41 | + }, |
| 42 | + setExplicitlyIfNotSetAlready(name) { |
| 43 | + const themeName = getStoredThemeName(); |
| 44 | + if (themeName) { |
| 45 | + return |
| 46 | + } |
| 47 | + |
| 48 | + this.setExplicitly(name) |
| 49 | + }, |
| 50 | + toggle() { |
| 51 | + this.setExplicitly(this.name === lightThemeName ? darkThemeName : lightThemeName) |
| 52 | + } |
| 53 | + }; |
| 54 | + |
| 55 | + var mediaThemeName = setLightMatchMediaListenerAndGetThemeName() |
| 56 | + var themeName = getStoredThemeName() || mediaThemeName; |
| 57 | + znaiTheme.set(themeName); |
| 58 | + |
| 59 | + window.znaiTheme = znaiTheme; |
| 60 | + |
| 61 | + function getStoredThemeName() { |
| 62 | + return localStorage.getItem(themeNameKey); |
| 63 | + } |
| 64 | + |
| 65 | + function storeThemeName(name) { |
| 66 | + return localStorage.setItem(themeNameKey, name); |
| 67 | + } |
| 68 | + |
| 69 | + function setLightMatchMediaListenerAndGetThemeName() { |
| 70 | + if (!window.matchMedia) { |
| 71 | + return darkThemeName; |
| 72 | + } |
| 73 | + |
| 74 | + var lightQuery = window.matchMedia('(prefers-color-scheme: light)'); |
| 75 | + lightQuery.addListener(function (e) { |
| 76 | + const newThemeName = e.matches ? lightThemeName : darkThemeName; |
| 77 | + znaiTheme.setExplicitly(newThemeName); |
| 78 | + }); |
| 79 | + |
| 80 | + return lightQuery.matches ? lightThemeName : darkThemeName; |
| 81 | + } |
| 82 | +})()</script> |
| 83 | +<div id="znai"><div id="znai-initial-page-loading" style="margin: -20px 0 0 -20px; padding: 0 40px 40px 0; width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center"> |
| 84 | + <div></div> |
| 85 | +</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;"> |
| 86 | +<article> |
| 87 | +<p>Webtau graphql. module let you exercise and validate GraphQL API. It provides a simplified way to access JSON response of an end-point and provides 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.Matchers.lessThan; import static org.testingisdocumenting.webtau.WebTauDsl.graphql; @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/report Report</p> |
| 88 | +</article> |
| 89 | +</section> |
| 90 | +</div> |
| 91 | +<script type="text/javascript" src="/webtau/toc.js"></script> |
| 92 | +<script type="text/javascript" src="/webtau/assets.js"></script> |
| 93 | +<script type="text/javascript" src="/webtau/static/main.js"></script> |
| 94 | +<script type="text/javascript" src="/webtau/search-index.js"></script> |
| 95 | +<script> |
| 96 | +document.getElementById('znai').innerHTML = ''; |
| 97 | +/*<!--*/ |
| 98 | +ReactDOM.render(React.createElement(Documentation, { |
| 99 | + "docMeta" : { |
| 100 | + "viewOn" : { |
| 101 | + "link" : "https://github.com/testingisdocumenting/webtau/tree/master/webtau-docs/znai", |
| 102 | + "title" : "View On GitHub" |
| 103 | + }, |
| 104 | + "id" : "webtau", |
| 105 | + "title" : "WebTau", |
| 106 | + "type" : "Guide", |
| 107 | + "previewEnabled" : false, |
| 108 | + "allowedGroups" : [ "admin" ] |
| 109 | + }, |
| 110 | + "page" : { |
| 111 | + "type" : "Page", |
| 112 | + "content" : [ { |
| 113 | + "type" : "Paragraph", |
| 114 | + "content" : [ { |
| 115 | + "text" : "Webtau ", |
| 116 | + "type" : "SimpleText" |
| 117 | + }, { |
| 118 | + "code" : "graphql.", |
| 119 | + "type" : "InlinedCode" |
| 120 | + }, { |
| 121 | + "text" : " module let you exercise and validate GraphQL API.", |
| 122 | + "type" : "SimpleText" |
| 123 | + }, { |
| 124 | + "type" : "SoftLineBreak" |
| 125 | + }, { |
| 126 | + "text" : "It provides a simplified way to access JSON response of an end-point and provides DSL to execute queries and mutations.", |
| 127 | + "type" : "SimpleText" |
| 128 | + } ] |
| 129 | + }, { |
| 130 | + "tabsContent" : [ { |
| 131 | + "name" : "Groovy", |
| 132 | + "content" : [ { |
| 133 | + "columns" : [ { |
| 134 | + "content" : [ { |
| 135 | + "lang" : "groovy", |
| 136 | + "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}", |
| 137 | + "title" : "GraphQL API test (Groovy specific runner)", |
| 138 | + "type" : "Snippet" |
| 139 | + }, { |
| 140 | + "lang" : "groovy", |
| 141 | + "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}", |
| 142 | + "title" : "GraphQL API test (JUnit4)", |
| 143 | + "type" : "Snippet" |
| 144 | + } ] |
| 145 | + }, { |
| 146 | + "content" : [ { |
| 147 | + "lang" : "json", |
| 148 | + "snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n", |
| 149 | + "lineNumber" : "", |
| 150 | + "title" : "Server Response", |
| 151 | + "type" : "Snippet" |
| 152 | + } ] |
| 153 | + } ], |
| 154 | + "config" : { }, |
| 155 | + "type" : "Columns" |
| 156 | + } ] |
| 157 | + }, { |
| 158 | + "name" : "Java", |
| 159 | + "content" : [ { |
| 160 | + "columns" : [ { |
| 161 | + "content" : [ { |
| 162 | + "lang" : "java", |
| 163 | + "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.Matchers.lessThan;\nimport static org.testingisdocumenting.webtau.WebTauDsl.graphql;\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}", |
| 164 | + "title" : "GraphQL API test (JUnit4 Java)", |
| 165 | + "type" : "Snippet" |
| 166 | + } ] |
| 167 | + }, { |
| 168 | + "content" : [ { |
| 169 | + "lang" : "json", |
| 170 | + "snippet" : "{\n \"data\": {\n \"weather\": {\n \"temperature\": 88\n }\n }\n}\n", |
| 171 | + "lineNumber" : "", |
| 172 | + "title" : "Server Response", |
| 173 | + "type" : "Snippet" |
| 174 | + } ] |
| 175 | + } ], |
| 176 | + "config" : { }, |
| 177 | + "type" : "Columns" |
| 178 | + } ] |
| 179 | + } ], |
| 180 | + "type" : "Tabs" |
| 181 | + }, { |
| 182 | + "type" : "Paragraph", |
| 183 | + "content" : [ { |
| 184 | + "text" : "Before diving further into writing tests for your GraphQL server, please read through the HTTP testing documentation", |
| 185 | + "type" : "SimpleText" |
| 186 | + }, { |
| 187 | + "type" : "SoftLineBreak" |
| 188 | + }, { |
| 189 | + "text" : "starting with the ", |
| 190 | + "type" : "SimpleText" |
| 191 | + }, { |
| 192 | + "url" : "/webtau/HTTP/data-node", |
| 193 | + "isFile" : false, |
| 194 | + "type" : "Link", |
| 195 | + "content" : [ { |
| 196 | + "text" : "Data node page", |
| 197 | + "type" : "SimpleText" |
| 198 | + } ] |
| 199 | + }, { |
| 200 | + "text" : " as much of the same core principles apply to GraphQL also.", |
| 201 | + "type" : "SimpleText" |
| 202 | + } ] |
| 203 | + }, { |
| 204 | + "type" : "Paragraph", |
| 205 | + "content" : [ { |
| 206 | + "text" : "The main GraphQL specific features are covered in the subsequent pages:", |
| 207 | + "type" : "SimpleText" |
| 208 | + } ] |
| 209 | + }, { |
| 210 | + "bulletMarker" : "*", |
| 211 | + "tight" : true, |
| 212 | + "type" : "BulletList", |
| 213 | + "content" : [ { |
| 214 | + "type" : "ListItem", |
| 215 | + "content" : [ { |
| 216 | + "type" : "Paragraph", |
| 217 | + "content" : [ { |
| 218 | + "url" : "/webtau/GraphQL/queries-and-mutations", |
| 219 | + "isFile" : false, |
| 220 | + "type" : "Link", |
| 221 | + "content" : [ { |
| 222 | + "text" : "Queries and Mutations", |
| 223 | + "type" : "SimpleText" |
| 224 | + } ] |
| 225 | + } ] |
| 226 | + } ] |
| 227 | + }, { |
| 228 | + "type" : "ListItem", |
| 229 | + "content" : [ { |
| 230 | + "type" : "Paragraph", |
| 231 | + "content" : [ { |
| 232 | + "url" : "/webtau/GraphQL/report", |
| 233 | + "isFile" : false, |
| 234 | + "type" : "Link", |
| 235 | + "content" : [ { |
| 236 | + "text" : "Report", |
| 237 | + "type" : "SimpleText" |
| 238 | + } ] |
| 239 | + } ] |
| 240 | + } ] |
| 241 | + } ] |
| 242 | + } ], |
| 243 | + "lastModifiedTime" : 1608332058182, |
| 244 | + "tocItem" : { |
| 245 | + "sectionTitle" : "GraphQL", |
| 246 | + "pageTitle" : "Introduction", |
| 247 | + "pageMeta" : { }, |
| 248 | + "dirName" : "GraphQL", |
| 249 | + "fileName" : "introduction", |
| 250 | + "viewOnRelativePath" : null, |
| 251 | + "pageSectionIdTitles" : [ ] |
| 252 | + } |
| 253 | + }, |
| 254 | + "footer" : { |
| 255 | + "type" : "Footer", |
| 256 | + "content" : [ { |
| 257 | + "type" : "Paragraph", |
| 258 | + "content" : [ { |
| 259 | + "text" : "If you have documentation suggestions, features or bugs to report, please create ", |
| 260 | + "type" : "SimpleText" |
| 261 | + }, { |
| 262 | + "url" : "https://github.com/testingisdocumenting/webtau/issues", |
| 263 | + "isFile" : false, |
| 264 | + "type" : "Link", |
| 265 | + "content" : [ { |
| 266 | + "text" : "GitHub Issue", |
| 267 | + "type" : "SimpleText" |
| 268 | + } ] |
| 269 | + } ] |
| 270 | + }, { |
| 271 | + "type" : "Paragraph", |
| 272 | + "content" : [ { |
| 273 | + "text" : "Contributions are welcome", |
| 274 | + "type" : "SimpleText" |
| 275 | + } ] |
| 276 | + } ] |
| 277 | + } |
| 278 | +}), document.getElementById("znai")); |
| 279 | +/*-->*/ |
| 280 | + |
| 281 | +</script> |
| 282 | + |
| 283 | +</body> |
| 284 | +</html> |
0 commit comments