forked from Azure/aks-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
32 lines (25 loc) · 865 Bytes
/
util.go
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package test
import (
"fmt"
"testing"
"path/filepath"
"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/reporters"
"github.com/onsi/gomega"
)
var (
// JUnitOutDir grabs the root of the git path from Makefile
JUnitOutDir = ""
)
// RunSpecsWithReporters bootstraps Ginkgo/Gomega tests to function and results go to the /test/junit directory and log output
func RunSpecsWithReporters(t *testing.T, junitprefix string, suitename string) {
gomega.RegisterFailHandler(ginkgo.Fail)
if JUnitOutDir == "" {
ginkgo.RunSpecs(t, suitename)
return
}
junitReporter := reporters.NewJUnitReporter(filepath.Join(JUnitOutDir, fmt.Sprintf("%s-junit.xml", junitprefix)))
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, suitename, []ginkgo.Reporter{junitReporter})
}