-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathparallel_test.go
More file actions
85 lines (76 loc) · 2.04 KB
/
parallel_test.go
File metadata and controls
85 lines (76 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//go:build example
// +build example
package examples
import (
"context"
"net/http"
"testing"
"time"
"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/cute"
)
func Test_Async_1(t *testing.T) {
cute.NewTestBuilder().
Title("Title async test 1").
Tags("parallel_test").
Parallel().
Create().
BeforeExecuteT(
func(t cute.T, r *http.Request) error {
t.WithNewStep("insideBefore", func(stepCtx provider.StepCtx) {
time.Sleep(time.Second)
now := time.Now()
stepCtx.Logf("Test 1. Start time %v", now)
stepCtx.WithNewParameters("Test 1. Time", now)
})
return nil
},
).
AfterExecuteT(
func(t cute.T, resp *http.Response, errs []error) error {
t.WithNewStep("insideAfter", func(stepCtx provider.StepCtx) {
now := time.Now()
stepCtx.Logf("Test 1. Stop time %v", now)
stepCtx.WithNewParameters("Test 1. Stop time", now)
})
return nil
}).
RequestBuilder(
cute.WithURI("https://jsonplaceholder.typicode.com/posts/1/comments"),
cute.WithMethod(http.MethodGet),
).
ExecuteTest(context.Background(), t)
}
func Test_Async_2(t *testing.T) {
cute.NewTestBuilder().
Title("Title async test 2").
Tags("parallel_test").
Parallel().
Create().
BeforeExecuteT(
func(t cute.T, r *http.Request) error {
t.WithNewStep("insideBefore", func(stepCtx provider.StepCtx) {
now := time.Now()
stepCtx.Logf("Test 2. Start time %v", now)
stepCtx.WithNewParameters("Test 2. Start time", now)
time.Sleep(2 * time.Second)
})
return nil
},
).
AfterExecuteT(
func(t cute.T, resp *http.Response, errs []error) error {
t.WithNewStep("insideAfter", func(stepCtx provider.StepCtx) {
now := time.Now()
stepCtx.Logf("test 2. Stop time %v", now)
stepCtx.WithNewParameters("Test 2. Stop time", now)
})
return nil
}).
RequestBuilder(
cute.WithURI("https://jsonplaceholder.typicode.com/posts/1/comments"),
cute.WithMethod(http.MethodGet),
).
ExpectStatus(200).
ExecuteTest(context.Background(), t)
}