|
85 | 85 | </div><section style="max-width: 640px; margin-left: auto; margin-right: auto;"> |
86 | 86 | <article> |
87 | 87 | <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 = "http://localhost:8180" graphQLEnabled = true reportGenerator = Report.&generateReport Where Report.&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: { "graphQLSkippedQueries" : [ { "name" : "taskById", "type" : "query" }, { "name" : "uncomplete", "type" : "mutation" }, { "name" : "allTasks", "type" : "query" }, { "name" : "complete", "type" : "mutation" } ], "graphQLCoveredQueries" : [ { "name" : "weather", "type" : "query" } ], "graphQLCoverageSummary" : { "coverage" : 0.2, "types" : { "mutation" : { "coverage" : 0.0, "declaredQueries" : 2, "coveredQueries" : 0.0 }, "query" : { "coverage" : 0.3333333333333333, "declaredQueries" : 3, "coveredQueries" : 1.0 } }, "totalDeclaredQueries" : 5.0, "totalCoveredQueries" : 1.0 }, "graphQLQueryTimeStatistics" : [ { "name" : "weather", "type" : "query", "statistics" : { "mean" : 5.0, "min" : 5, "max" : 5, "count" : 1, "p95" : 5.0, "p99" : 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 = "http://localhost:8180" graphQLIgnoreIntrospectionFailures = false reportGenerator = Report.&generateReport Where Report.&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: { "graphQLSkippedQueries" : [ { "name" : "allTasks", "type" : "query" }, { "name" : "taskById", "type" : "query" }, { "name" : "uncomplete", "type" : "mutation" }, { "name" : "complete", "type" : "mutation" } ], "graphQLCoveredQueries" : [ { "name" : "weather", "type" : "query" } ], "graphQLCoverageSummary" : { "coverage" : 0.2, "types" : { "mutation" : { "coverage" : 0.0, "declaredQueries" : 2, "coveredQueries" : 0.0 }, "query" : { "coverage" : 0.3333333333333333, "declaredQueries" : 3, "coveredQueries" : 1.0 } }, "totalDeclaredQueries" : 5.0, "totalCoveredQueries" : 1.0 }, "graphQLQueryTimeStatistics" : [ { "name" : "weather", "type" : "query", "statistics" : { "mean" : 6.0, "min" : 6, "max" : 6, "count" : 1, "p95" : 6.0, "p99" : 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> |
89 | 89 | </article> |
90 | 90 | </section> |
91 | 91 | </div> |
|
127 | 127 | } ] |
128 | 128 | }, { |
129 | 129 | "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", |
131 | 131 | "title" : "webtau.cfg.groovy", |
132 | 132 | "type" : "Snippet" |
133 | 133 | }, { |
|
156 | 156 | } ] |
157 | 157 | }, { |
158 | 158 | "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}", |
160 | 160 | "title" : "webtau.graphql-report.json", |
161 | 161 | "type" : "Snippet" |
162 | 162 | }, { |
|
200 | 200 | } ] |
201 | 201 | } ] |
202 | 202 | } ], |
203 | | - "lastModifiedTime" : 1604459318229, |
| 203 | + "lastModifiedTime" : 1604812521923, |
204 | 204 | "tocItem" : { |
205 | 205 | "sectionTitle" : "GraphQL", |
206 | 206 | "pageTitle" : "Report", |
|
0 commit comments