nao1215 / spectest

A simple and extensible behavioural testing library for Go. You can use api test to simplify REST API, HTTP handler and e2e tests.
MIT License
37 stars 1 forks source link

Feature: generate golden file #140

Closed nao1215 closed 1 year ago

nao1215 commented 1 year ago

Is your feature request related to a problem? Please describe.

We often manually create expectations for response data. This process is very tedious. Therefore, we will add a function to generate the expected value data in a specified path when the test is executed with a specific procedure.

Describe the solution you'd like

We would add the Golden() method. This method writes response body data to the specified file path. However, the write operation is performed only when certain flags are enabled.

The method to enable the flags is under consideration. For example, we can create a spectest cli command, and the Golden() method will generate a file if the --golden option of this command is enabled.

nao1215 commented 1 year ago

Done #195