Skip to content

Commit c9f1df7

Browse files
deploy: 4570f70
1 parent 45026df commit c9f1df7

63 files changed

Lines changed: 681 additions & 127 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

GraphQL/getting-started/index.html

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<article>
8787
<header><h1>Minimal Groovy Setup</h1></header>
88-
<p>Download and unzip https://repo.maven.apache.org/maven2/org/testingisdocumenting/webtau/webtau-dist/1.33/webtau-dist-1.33-webtau.zip webtau. Add it to your PATH . Generate webtau examples webtau --example Navigate into graphql example cd examples/graphql import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario('fetch types from schema') { def query = '{ __schema { types { name } } }' graphql.execute(query) { __schema.types.numberOfElements().shouldBe &gt; 0 } } To run test webtau introspection.groovy --url=http://localhost:8080 Note: using import is optional and is mainly for IDE auto completion. Imports are added implicitly during command line run. Url parameter can be moved to a webtau.cfg.groovy file. Please note that WebTau will automatically append /graphql to the url.You may also wish to add a graphQLEnabled = true property which will result in WebTau recording coverage and timing information per query for your tests. url = &quot;http://localhost:8080/&quot; graphQLEnabled = true configuration/environments Specify multiple environments to streamline test execution.</p>
88+
<p>Download and unzip https://repo.maven.apache.org/maven2/org/testingisdocumenting/webtau/webtau-dist/1.33/webtau-dist-1.33-webtau.zip webtau. Add it to your PATH . Generate webtau examples webtau --example Navigate into graphql example cd examples/graphql import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* scenario('fetch types from schema') { def query = '{ __schema { types { name } } }' graphql.execute(query) { __schema.types.numberOfElements().shouldBe &gt; 0 } } To run test webtau introspection.groovy --url=http://localhost:8080 Note: using import is optional and is mainly for IDE auto completion. Imports are added implicitly during command line run. Url parameter can be moved to a webtau.cfg.groovy file. Please note that WebTau will automatically append /graphql to the url.Webtau will attempt to send an introspection query in order to obtain information about the GraphQL schema. If this fails, it will not be able to record coverage information for GraphQL. Should you wish to fail the test if introspection fails, please set the graphQLIgnoreIntrospectionFailures property to false . url = &quot;http://localhost:8080/&quot; graphQLIgnoreIntrospectionFailures = false configuration/environments Specify multiple environments to streamline test execution.</p>
8989
</article>
9090

9191
<article>
9292
<header><h1>Minimal JUnit Setup</h1></header>
93-
<p>Groovy &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau-groovy&lt;/artifactId&gt; &lt;version&gt;1.33&lt;/version&gt; &lt;/dependency&gt; Java &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau&lt;/artifactId&gt; &lt;version&gt;1.33&lt;/version&gt; &lt;/dependency&gt; Groovy package com.example.tests.junit4 import org.testingisdocumenting.webtau.junit4.WebTauRunner import org.junit.Test import org.junit.runner.RunWith import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* @RunWith(WebTauRunner.class) class WeatherGroovyIT { @Test void checkWeather() { http.get(&quot;/weather&quot;) { temperature.shouldBe &lt; 100 } } } Java package com.example.tests.junit4; import org.testingisdocumenting.webtau.junit4.WebTauRunner; import org.junit.Test; import org.junit.runner.RunWith; import static org.testingisdocumenting.webtau.WebTauDsl.*; @RunWith(WebTauRunner.class) public class WeatherJavaIT { @Test public void checkWeather() { http.get(&quot;/weather&quot;, (header, body) -&gt; { body.get(&quot;temperature&quot;).shouldBe(lessThan(100)); }); } } Add webtau.properties to test class path url = http://localhost graphQLEnabled = true</p>
93+
<p>Groovy &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau-groovy&lt;/artifactId&gt; &lt;version&gt;1.33&lt;/version&gt; &lt;/dependency&gt; Java &lt;dependency&gt; &lt;groupId&gt;org.testingisdocumenting.webtau&lt;/groupId&gt; &lt;artifactId&gt;webtau&lt;/artifactId&gt; &lt;version&gt;1.33&lt;/version&gt; &lt;/dependency&gt; Groovy 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 = &quot;{ weather { temperature } }&quot;; graphql.execute(query) { weather.temperature.shouldBe &lt; 100 } } } 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 = &quot;{ weather { temperature } }&quot;; graphql.execute(query, (header, body) -&gt; { body.get(&quot;data.weather.temperature&quot;).shouldBe(lessThan(100)); }); } } Add webtau.properties to test class path url = http://localhost graphQLIgnoreIntrospectionFailures = false</p>
9494
</article>
9595

9696
<article>
@@ -240,23 +240,34 @@
240240
}, {
241241
"type" : "Paragraph",
242242
"content" : [ {
243-
"text" : "You may also wish to add a ",
243+
"text" : "Webtau will attempt to send an introspection query in order to obtain information about the GraphQL schema. If this fails, it",
244244
"type" : "SimpleText"
245245
}, {
246-
"code" : "graphQLEnabled = true",
247-
"type" : "InlinedCode"
246+
"type" : "SoftLineBreak"
248247
}, {
249-
"text" : " property which will result in WebTau recording coverage and timing information",
248+
"text" : "will not be able to record coverage information for GraphQL. Should you wish to fail the test if introspection fails, please",
250249
"type" : "SimpleText"
251250
}, {
252251
"type" : "SoftLineBreak"
253252
}, {
254-
"text" : "per query for your tests.",
253+
"text" : "set the ",
254+
"type" : "SimpleText"
255+
}, {
256+
"code" : "graphQLIgnoreIntrospectionFailures",
257+
"type" : "InlinedCode"
258+
}, {
259+
"text" : " property to ",
260+
"type" : "SimpleText"
261+
}, {
262+
"code" : "false",
263+
"type" : "InlinedCode"
264+
}, {
265+
"text" : ".",
255266
"type" : "SimpleText"
256267
} ]
257268
}, {
258269
"lang" : "groovy",
259-
"snippet" : "url = \"http://localhost:8080/\"\ngraphQLEnabled = true",
270+
"snippet" : "url = \"http://localhost:8080/\"\ngraphQLIgnoreIntrospectionFailures = false",
260271
"title" : "webtau.cfg.groovy",
261272
"type" : "Snippet"
262273
}, {
@@ -302,15 +313,15 @@
302313
"name" : "Groovy",
303314
"content" : [ {
304315
"lang" : "groovy",
305-
"snippet" : "package com.example.tests.junit4\n\nimport org.testingisdocumenting.webtau.junit4.WebTauRunner\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\nimport static org.testingisdocumenting.webtau.WebTauGroovyDsl.*\n\n@RunWith(WebTauRunner.class)\nclass WeatherGroovyIT {\n @Test\n void checkWeather() {\n http.get(\"/weather\") {\n temperature.shouldBe < 100\n }\n }\n}",
316+
"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}",
306317
"title" : "JUnit 4 example",
307318
"type" : "Snippet"
308319
} ]
309320
}, {
310321
"name" : "Java",
311322
"content" : [ {
312323
"lang" : "java",
313-
"snippet" : "package com.example.tests.junit4;\n\nimport org.testingisdocumenting.webtau.junit4.WebTauRunner;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.testingisdocumenting.webtau.WebTauDsl.*;\n\n@RunWith(WebTauRunner.class)\npublic class WeatherJavaIT {\n @Test\n public void checkWeather() {\n http.get(\"/weather\", (header, body) -> {\n body.get(\"temperature\").shouldBe(lessThan(100));\n });\n }\n}",
324+
"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}",
314325
"title" : "JUnit 4 example",
315326
"type" : "Snippet"
316327
} ]
@@ -335,7 +346,7 @@
335346
} ]
336347
}, {
337348
"lang" : "properties",
338-
"snippet" : "url = http://localhost\ngraphQLEnabled = true",
349+
"snippet" : "url = http://localhost\ngraphQLIgnoreIntrospectionFailures = false",
339350
"title" : "webtau.properties",
340351
"type" : "Snippet"
341352
} ]
@@ -406,7 +417,7 @@
406417
} ]
407418
} ]
408419
} ],
409-
"lastModifiedTime" : 1604459318229,
420+
"lastModifiedTime" : 1604812521923,
410421
"tocItem" : {
411422
"sectionTitle" : "GraphQL",
412423
"pageTitle" : "Getting Started",

GraphQL/queries-and-mutations/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
} ]
275275
} ]
276276
} ],
277-
"lastModifiedTime" : 1604459318229,
277+
"lastModifiedTime" : 1604812521923,
278278
"tocItem" : {
279279
"sectionTitle" : "GraphQL",
280280
"pageTitle" : "Queries And Mutations",

GraphQL/report/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
</div><section style="max-width: 640px; margin-left: auto; margin-right: auto;">
8686
<article>
8787
<header><h1>Additional Reports</h1></header>
88-
<p>To generate custom reports or upload report data to your server, specify a reportGenerator config property. package scenarios.graphql url = &quot;http://localhost:8180&quot; graphQLEnabled = true reportGenerator = Report.&amp;generateReport Where Report.&amp;generateReport is implemented as follows: package scenarios.graphql import org.testingisdocumenting.webtau.console.ConsoleOutputs import org.testingisdocumenting.webtau.console.ansi.Color import org.testingisdocumenting.webtau.report.ReportDataProviders import org.testingisdocumenting.webtau.reporter.WebTauReport import org.testingisdocumenting.webtau.utils.JsonUtils import static org.testingisdocumenting.webtau.WebTauDsl.cfg class Report { static void generateReport(WebTauReport report) { def additionalData = [:] ReportDataProviders.provide(report.tests) .map { it.toMap() } .forEach { additionalData.putAll(it) } def reportData = [:] reportData.graphQLSkippedQueries = additionalData.graphQLSkippedQueries // All queries present in the GraphQL schema but not tested reportData.graphQLCoveredQueries = additionalData.graphQLCoveredQueries // All queries present in the GraphQL schema and tested reportData.graphQLCoverageSummary = additionalData.graphQLCoverageSummary // Summary of test coverage compared to the GraphQL schema reportData.graphQLQueryTimeStatistics = additionalData.graphQLQueryTimeStatistics // Summary of timing by query def reportPath = cfg.workingDir.resolve('webtau.graphql-report.json') ConsoleOutputs.out('generating report: ', Color.PURPLE, reportPath) reportPath.toFile().text = JsonUtils.serializePrettyPrint(reportData) } } The output looks as follows: { &quot;graphQLSkippedQueries&quot; : [ { &quot;name&quot; : &quot;taskById&quot;, &quot;type&quot; : &quot;query&quot; }, { &quot;name&quot; : &quot;uncomplete&quot;, &quot;type&quot; : &quot;mutation&quot; }, { &quot;name&quot; : &quot;allTasks&quot;, &quot;type&quot; : &quot;query&quot; }, { &quot;name&quot; : &quot;complete&quot;, &quot;type&quot; : &quot;mutation&quot; } ], &quot;graphQLCoveredQueries&quot; : [ { &quot;name&quot; : &quot;weather&quot;, &quot;type&quot; : &quot;query&quot; } ], &quot;graphQLCoverageSummary&quot; : { &quot;coverage&quot; : 0.2, &quot;types&quot; : { &quot;mutation&quot; : { &quot;coverage&quot; : 0.0, &quot;declaredQueries&quot; : 2, &quot;coveredQueries&quot; : 0.0 }, &quot;query&quot; : { &quot;coverage&quot; : 0.3333333333333333, &quot;declaredQueries&quot; : 3, &quot;coveredQueries&quot; : 1.0 } }, &quot;totalDeclaredQueries&quot; : 5.0, &quot;totalCoveredQueries&quot; : 1.0 }, &quot;graphQLQueryTimeStatistics&quot; : [ { &quot;name&quot; : &quot;weather&quot;, &quot;type&quot; : &quot;query&quot;, &quot;statistics&quot; : { &quot;mean&quot; : 5.0, &quot;min&quot; : 5, &quot;max&quot; : 5, &quot;count&quot; : 1, &quot;p95&quot; : 5.0, &quot;p99&quot; : 5.0 } } ] } WebTau will implicitly invoke your GraphQL server's introspection queries in order to fetch a subset of the schema. It uses this schema in conjunction with the requests in tests to compute:query coverage - which queries were invoked by tests and which were not as well as an overall summary of coveragetiming information - http call timing statistics by query</p>
88+
<p>To generate custom reports or upload report data to your server, specify a reportGenerator config property. package scenarios.graphql url = &quot;http://localhost:8180&quot; graphQLIgnoreIntrospectionFailures = false reportGenerator = Report.&amp;generateReport Where Report.&amp;generateReport is implemented as follows: package scenarios.graphql import org.testingisdocumenting.webtau.console.ConsoleOutputs import org.testingisdocumenting.webtau.console.ansi.Color import org.testingisdocumenting.webtau.report.ReportDataProviders import org.testingisdocumenting.webtau.reporter.WebTauReport import org.testingisdocumenting.webtau.utils.JsonUtils import static org.testingisdocumenting.webtau.WebTauDsl.cfg class Report { static void generateReport(WebTauReport report) { def additionalData = [:] ReportDataProviders.provide(report.tests) .map { it.toMap() } .forEach { additionalData.putAll(it) } def reportData = [:] reportData.graphQLSkippedQueries = additionalData.graphQLSkippedQueries // All queries present in the GraphQL schema but not tested reportData.graphQLCoveredQueries = additionalData.graphQLCoveredQueries // All queries present in the GraphQL schema and tested reportData.graphQLCoverageSummary = additionalData.graphQLCoverageSummary // Summary of test coverage compared to the GraphQL schema reportData.graphQLQueryTimeStatistics = additionalData.graphQLQueryTimeStatistics // Summary of timing by query def reportPath = cfg.workingDir.resolve('webtau.graphql-report.json') ConsoleOutputs.out('generating report: ', Color.PURPLE, reportPath) reportPath.toFile().text = JsonUtils.serializePrettyPrint(reportData) } } The output looks as follows: { &quot;graphQLSkippedQueries&quot; : [ { &quot;name&quot; : &quot;allTasks&quot;, &quot;type&quot; : &quot;query&quot; }, { &quot;name&quot; : &quot;taskById&quot;, &quot;type&quot; : &quot;query&quot; }, { &quot;name&quot; : &quot;uncomplete&quot;, &quot;type&quot; : &quot;mutation&quot; }, { &quot;name&quot; : &quot;complete&quot;, &quot;type&quot; : &quot;mutation&quot; } ], &quot;graphQLCoveredQueries&quot; : [ { &quot;name&quot; : &quot;weather&quot;, &quot;type&quot; : &quot;query&quot; } ], &quot;graphQLCoverageSummary&quot; : { &quot;coverage&quot; : 0.2, &quot;types&quot; : { &quot;mutation&quot; : { &quot;coverage&quot; : 0.0, &quot;declaredQueries&quot; : 2, &quot;coveredQueries&quot; : 0.0 }, &quot;query&quot; : { &quot;coverage&quot; : 0.3333333333333333, &quot;declaredQueries&quot; : 3, &quot;coveredQueries&quot; : 1.0 } }, &quot;totalDeclaredQueries&quot; : 5.0, &quot;totalCoveredQueries&quot; : 1.0 }, &quot;graphQLQueryTimeStatistics&quot; : [ { &quot;name&quot; : &quot;weather&quot;, &quot;type&quot; : &quot;query&quot;, &quot;statistics&quot; : { &quot;mean&quot; : 6.0, &quot;min&quot; : 6, &quot;max&quot; : 6, &quot;count&quot; : 1, &quot;p95&quot; : 6.0, &quot;p99&quot; : 6.0 } } ] } WebTau will implicitly invoke your GraphQL server's introspection queries in order to fetch a subset of the schema. It uses this schema in conjunction with the requests in tests to compute:query coverage - which queries were invoked by tests and which were not as well as an overall summary of coveragetiming information - http call timing statistics by query</p>
8989
</article>
9090
</section>
9191
</div>
@@ -127,7 +127,7 @@
127127
} ]
128128
}, {
129129
"lang" : "groovy",
130-
"snippet" : "package scenarios.graphql\n\nurl = \"http://localhost:8180\"\n\ngraphQLEnabled = true\n\nreportGenerator = Report.&generateReport",
130+
"snippet" : "package scenarios.graphql\n\nurl = \"http://localhost:8180\"\n\ngraphQLIgnoreIntrospectionFailures = false\n\nreportGenerator = Report.&generateReport",
131131
"title" : "webtau.cfg.groovy",
132132
"type" : "Snippet"
133133
}, {
@@ -156,7 +156,7 @@
156156
} ]
157157
}, {
158158
"lang" : "json",
159-
"snippet" : "{\n \"graphQLSkippedQueries\" : [ {\n \"name\" : \"taskById\",\n \"type\" : \"query\"\n }, {\n \"name\" : \"uncomplete\",\n \"type\" : \"mutation\"\n }, {\n \"name\" : \"allTasks\",\n \"type\" : \"query\"\n }, {\n \"name\" : \"complete\",\n \"type\" : \"mutation\"\n } ],\n \"graphQLCoveredQueries\" : [ {\n \"name\" : \"weather\",\n \"type\" : \"query\"\n } ],\n \"graphQLCoverageSummary\" : {\n \"coverage\" : 0.2,\n \"types\" : {\n \"mutation\" : {\n \"coverage\" : 0.0,\n \"declaredQueries\" : 2,\n \"coveredQueries\" : 0.0\n },\n \"query\" : {\n \"coverage\" : 0.3333333333333333,\n \"declaredQueries\" : 3,\n \"coveredQueries\" : 1.0\n }\n },\n \"totalDeclaredQueries\" : 5.0,\n \"totalCoveredQueries\" : 1.0\n },\n \"graphQLQueryTimeStatistics\" : [ {\n \"name\" : \"weather\",\n \"type\" : \"query\",\n \"statistics\" : {\n \"mean\" : 5.0,\n \"min\" : 5,\n \"max\" : 5,\n \"count\" : 1,\n \"p95\" : 5.0,\n \"p99\" : 5.0\n }\n } ]\n}",
159+
"snippet" : "{\n \"graphQLSkippedQueries\" : [ {\n \"name\" : \"allTasks\",\n \"type\" : \"query\"\n }, {\n \"name\" : \"taskById\",\n \"type\" : \"query\"\n }, {\n \"name\" : \"uncomplete\",\n \"type\" : \"mutation\"\n }, {\n \"name\" : \"complete\",\n \"type\" : \"mutation\"\n } ],\n \"graphQLCoveredQueries\" : [ {\n \"name\" : \"weather\",\n \"type\" : \"query\"\n } ],\n \"graphQLCoverageSummary\" : {\n \"coverage\" : 0.2,\n \"types\" : {\n \"mutation\" : {\n \"coverage\" : 0.0,\n \"declaredQueries\" : 2,\n \"coveredQueries\" : 0.0\n },\n \"query\" : {\n \"coverage\" : 0.3333333333333333,\n \"declaredQueries\" : 3,\n \"coveredQueries\" : 1.0\n }\n },\n \"totalDeclaredQueries\" : 5.0,\n \"totalCoveredQueries\" : 1.0\n },\n \"graphQLQueryTimeStatistics\" : [ {\n \"name\" : \"weather\",\n \"type\" : \"query\",\n \"statistics\" : {\n \"mean\" : 6.0,\n \"min\" : 6,\n \"max\" : 6,\n \"count\" : 1,\n \"p95\" : 6.0,\n \"p99\" : 6.0\n }\n } ]\n}",
160160
"title" : "webtau.graphql-report.json",
161161
"type" : "Snippet"
162162
}, {
@@ -200,7 +200,7 @@
200200
} ]
201201
} ]
202202
} ],
203-
"lastModifiedTime" : 1604459318229,
203+
"lastModifiedTime" : 1604812521923,
204204
"tocItem" : {
205205
"sectionTitle" : "GraphQL",
206206
"pageTitle" : "Report",

JVM-business-logic/data-driven/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
} ]
235235
} ]
236236
} ],
237-
"lastModifiedTime" : 1604459318229,
237+
"lastModifiedTime" : 1604812521923,
238238
"tocItem" : {
239239
"sectionTitle" : "JVM Business Logic",
240240
"pageTitle" : "Data Driven",

0 commit comments

Comments
 (0)