Skip to content

Commit b464b67

Browse files
committed
feature: add go examples
Add test examples and instruction on how to upload test results to the Qase
1 parent 8e12500 commit b464b67

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

examples/go/REAMDE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# How to upload test results to Qase from the Go tests
2+
3+
You can upload test results to Qase from the Go tests.
4+
5+
First, you need to install the `gotestsum` package. This package is used to run the tests and save the results in the JUnit format.
6+
7+
Then you can upload the test results to Qase using the `qasectl` tool.
8+
9+
Step-by-step guide:
10+
11+
1. Clone the repository
12+
13+
```bash
14+
git clone https://github.com/qase-tms/qase-go.git
15+
```
16+
17+
2. Move to the directory with the examples
18+
19+
```bash
20+
cd qase-go/examples/go
21+
```
22+
23+
3. Install the required packages
24+
25+
```bash
26+
go mod tidy
27+
```
28+
29+
4. Install the `gotestsum` package
30+
31+
```bash
32+
go install gotest.tools/gotestsum@latest
33+
```
34+
35+
5. Run the tests and save the results to the `test-results.xml` file
36+
37+
```bash
38+
gotestsum --junitfile results/test-results.xml
39+
```
40+
41+
6. Upload the test results to Qase using the [qasectl](https://github.com/qase-tms/qasectl/blob/main/docs/command.md) tool
42+
43+
```bash
44+
qli testops result upload --project DEMO --token token --id 1 --format junit --path /results/test-results.xml --verbose
45+
```

examples/go/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module examples/go
2+
3+
go 1.22.5

examples/go/simple.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package _go
2+
3+
func Sum(a, b int) int {
4+
return a + b
5+
}

examples/go/simple_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package _go
2+
3+
import "testing"
4+
5+
func Test_SumSuccess(t *testing.T) {
6+
result := Sum(1, 2)
7+
if result != 3 {
8+
t.Errorf("Sum(1, 2) = %d; want 3", result)
9+
}
10+
}
11+
12+
func Test_SumFailed(t *testing.T) {
13+
result := Sum(1, 2)
14+
if result != 4 {
15+
t.Errorf("Sum(1, 2) = %d; want 4", result)
16+
}
17+
}

0 commit comments

Comments
 (0)