Custom Report
ScanAPI enables you to generate personalized reports. With the Custom Report
feature, you can export your results in any style and format you want
(.html, .md, .txt, .xmlβ¦).
Letβs export your ScanAPI results you have so far as a .csv file. For that, the first step is
to create a Jinja template file. Create a csv_template.jinja file in root with the
following content:
"project_name"{{- "," -}}
"generated_at"{{- "," -}}
"total_successes"{{- "," -}}
"total_failures"{{- "," -}}
"total_errors"{{- "," -}}
"started_at"{{- "," -}}
"total_time"{{- "," -}}
"url"{{- "," -}}
"all_tests_passed"{{- "," -}}
"test_name"
{% for result in results -%}
{% for test in result.tests_results -%}
"{{ project_name }}"{{- "," -}}
"{{ now }}"{{- "," -}}
{{ session.successes }}{{- "," -}}
{{ session.failures }}{{- "," -}}
{{ session.errors }}{{- "," -}}
"{{ session.started_at }}"{{- "," -}}
"{{ session.elapsed_time() }}"{{- "," -}}
"{{ result.response.request.url }}"{{- "," -}}
{{ result.no_failure }}{{- "," -}}
"{{ test.name }}"
{% endfor %}
{%- endfor %}
The folder structure should look like this now:
- scanapi (root directory)
|ββ .env
|ββ csv_template.jinja
|ββ scanapi-report.html
|ββ scanapi.conf
|ββ scanapi.yaml
|___ snippets.yaml
Letβs run ScanAPI using the new csv template and sava the results in the scanapi-report.csv file:
$ scanapi run -t csv_template.jinja -o scanapi-report.csv
The .csv result:
This should be the final folder structure:
- scanapi (root directory)
|ββ .env
|ββ csv_template.jinja
|ββ scanapi-report.csv
|ββ scanapi-report.html
|ββ scanapi.conf
|ββ scanapi.yaml
|___ snippets.yaml
Congratulations, you have finished documenting and testing the Snippets API using ScanAPI! π
Great, but it is still missing one last piece. How can I add ScanAPI to my own API? How can I add ScanAPI to my project and to my pipeline? Letβs go to our final lesson!