diff --git a/examples/go/REAMDE.md b/examples/go/REAMDE.md new file mode 100644 index 0000000..22ef8c4 --- /dev/null +++ b/examples/go/REAMDE.md @@ -0,0 +1,45 @@ +# How to upload test results to Qase from the Go tests + +You can upload test results to Qase from the Go tests. + +First, you need to install the `gotestsum` package. This package is used to run the tests and save the results in the JUnit format. + +Then you can upload the test results to Qase using the `qasectl` tool. + +Step-by-step guide: + +1. Clone the repository + + ```bash + git clone https://github.com/qase-tms/qase-go.git + ``` + +2. Move to the directory with the examples + + ```bash + cd qase-go/examples/go + ``` + +3. Install the required packages + + ```bash + go mod tidy + ``` + +4. Install the `gotestsum` package + + ```bash + go install gotest.tools/gotestsum@latest + ``` + +5. Run the tests and save the results to the `test-results.xml` file + + ```bash + gotestsum --junitfile results/test-results.xml + ``` + +6. Upload the test results to Qase using the [qasectl](https://github.com/qase-tms/qasectl/blob/main/docs/command.md) tool + + ```bash + qli testops result upload --project DEMO --token token --id 1 --format junit --path /results/test-results.xml --verbose + ``` diff --git a/examples/go/go.mod b/examples/go/go.mod new file mode 100644 index 0000000..044f3f2 --- /dev/null +++ b/examples/go/go.mod @@ -0,0 +1,3 @@ +module examples/go + +go 1.22.5 diff --git a/examples/go/simple.go b/examples/go/simple.go new file mode 100644 index 0000000..f9b4bd3 --- /dev/null +++ b/examples/go/simple.go @@ -0,0 +1,5 @@ +package _go + +func Sum(a, b int) int { + return a + b +} diff --git a/examples/go/simple_test.go b/examples/go/simple_test.go new file mode 100644 index 0000000..e23308a --- /dev/null +++ b/examples/go/simple_test.go @@ -0,0 +1,17 @@ +package _go + +import "testing" + +func Test_SumSuccess(t *testing.T) { + result := Sum(1, 2) + if result != 3 { + t.Errorf("Sum(1, 2) = %d; want 3", result) + } +} + +func Test_SumFailed(t *testing.T) { + result := Sum(1, 2) + if result != 4 { + t.Errorf("Sum(1, 2) = %d; want 4", result) + } +}