Results
test.Execute() returns a detailed result and a boolean that indicates whether the complete pipeline met its expectations.
The result retains the response and comparison of each step. It can be explained in the terminal, stored in files or included in the detailed output of Execution.
Execute
result, match := test.Execute(config, pipeline) match is true when all the steps match. result contains the information necessary to know what was executed and why a comparison failed.
Pass
test.Pass() records one or more successful messages.
if match {
test.Pass("La sesión se conservó durante todo el pipeline")
} The messages appear below the result of the function.
Fail
test.Fail() records a failure and makes the function reported as FAIL.
if !match {
test.Fail("La respuesta no cumple el contrato")
} It can be used to assess additional conditions that are not part of the expectations.
Explain
test.Explain() generates a legible explanation when the result contains differences.
test.Explain(result) The explanation may include:
- Status code expected and received.
- Absent headers or cookies and different values.
- Fragments found or absent in the body.
- First difference between texts.
- Routes and JSON values that don't match.
- Error or result received from an Action.
The extensive bodies are summarized to keep the output readable.
Save
test.Save() writes the individual result as JSON within tests/results/.
test.Save(result) In test mode also creates a folder responses/ together with the result and save an HTTP representation of each response. These files allow you to review the full status code, headers, cookies and body.
During a Benchmark, Save() retains the JSON metrics, but does not generate response devices.
Results per step
Each step may include:
| Information | Description |
|---|---|
| Contents | Position inside the pipeline. |
| Type | HTTP, Action or error request. |
| Method and URL | Operation executed. |
| Response | Response captured. |
| Status | Status code comparison. |
| Headers | Comparison of headers. |
| Cookies | Cookies comparison. |
| Body | Body comparison. |
| Action | Comparison of error and result. |
| Match | The overall outcome of the step. |
Global report
The option gox test -out writes a report of the entire execution. Unlike test.Save(), includes all the selected functions and their totals.
See Execution to know the route resolution and command options.
Integration with Go
The result is a serializable structure that brings together secondary structures for each type of comparison. This allows you to inspect it from the test code or process the JSON generated with other tools.
test.Fail() uses the context installed by the runner to record the failure of the current function. Explain() and Save() they consume the result without rerunning the pipeline.
Best practices
- Always assess the value
matchreturned bytest.Execute(). - It uses error messages that describe the unfulfilled contract.
- Executed
test.Explain()to obtain useful diagnoses. - Save results when you need to keep or compare complete responses.
- Use
-outfor global reports andtest.Save()for individual executions.