Skip to content

Commit

Permalink
feature: add go examples
Browse files Browse the repository at this point in the history
Add test examples and instruction on how to upload test results to the Qase
  • Loading branch information
gibiw committed Jul 23, 2024
1 parent 8e12500 commit b464b67
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
45 changes: 45 additions & 0 deletions examples/go/REAMDE.md
Original file line number Diff line number Diff line change
@@ -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
```
3 changes: 3 additions & 0 deletions examples/go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module examples/go

go 1.22.5
5 changes: 5 additions & 0 deletions examples/go/simple.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package _go

func Sum(a, b int) int {
return a + b
}
17 changes: 17 additions & 0 deletions examples/go/simple_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit b464b67

Please sign in to comment.