MCPcopy
hub / github.com/keploy/keploy / TestBuildJUnitSuites_Basic

Function TestBuildJUnitSuites_Basic

pkg/service/report/junit_test.go:11–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestBuildJUnitSuites_Basic(t *testing.T) {
12 reports := map[string]*models.TestReport{
13 "test-set-1": {
14 Total: 3,
15 Success: 2,
16 Failure: 1,
17 TimeTaken: "1.5s",
18 Tests: []models.TestResult{
19 {
20 TestCaseID: "tc-1",
21 Name: "test-set-1",
22 Status: models.TestStatusPassed,
23 TimeTaken: "500ms",
24 },
25 {
26 TestCaseID: "tc-2",
27 Name: "test-set-1",
28 Status: models.TestStatusPassed,
29 TimeTaken: "400ms",
30 },
31 {
32 TestCaseID: "tc-3",
33 Name: "test-set-1",
34 Kind: models.HTTP,
35 Status: models.TestStatusFailed,
36 TimeTaken: "600ms",
37 Result: models.Result{
38 StatusCode: models.IntResult{
39 Normal: false,
40 Expected: 200,
41 Actual: 500,
42 },
43 },
44 FailureInfo: models.FailureInfo{
45 Risk: models.High,
46 },
47 },
48 },
49 },
50 }
51
52 suites := buildJUnitSuites(reports)
53
54 if suites.Tests != 3 {
55 t.Errorf("expected 3 total tests, got %d", suites.Tests)
56 }
57 if suites.Failures != 1 {
58 t.Errorf("expected 1 failure, got %d", suites.Failures)
59 }
60 if len(suites.Suites) != 1 {
61 t.Fatalf("expected 1 suite, got %d", len(suites.Suites))
62 }
63
64 suite := suites.Suites[0]
65 if suite.Name != "test-set-1" {
66 t.Errorf("expected suite name 'test-set-1', got %q", suite.Name)
67 }
68 if suite.Tests != 3 {

Callers

nothing calls this directly

Calls 2

buildJUnitSuitesFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected