Update go dependencies

This commit is contained in:
Manuel de Brito Fontes 2018-05-26 11:27:53 -04:00 committed by Manuel Alejandro de Brito Fontes
parent 15ffb51394
commit bb4d483837
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
1621 changed files with 86368 additions and 284392 deletions

View file

@ -66,7 +66,7 @@ func (reporter *DefaultReporter) SpecDidComplete(specSummary *types.SpecSummary)
case types.SpecStatePending:
reporter.stenographer.AnnouncePendingSpec(specSummary, reporter.config.NoisyPendings && !reporter.config.Succinct)
case types.SpecStateSkipped:
reporter.stenographer.AnnounceSkippedSpec(specSummary, reporter.config.Succinct, reporter.config.FullTrace)
reporter.stenographer.AnnounceSkippedSpec(specSummary, reporter.config.Succinct || !reporter.config.NoisySkippings, reporter.config.FullTrace)
case types.SpecStateTimedOut:
reporter.stenographer.AnnounceSpecTimedOut(specSummary, reporter.config.Succinct, reporter.config.FullTrace)
case types.SpecStatePanicked:

View file

@ -1,414 +0,0 @@
package reporters_test
import (
"time"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/reporters"
st "github.com/onsi/ginkgo/reporters/stenographer"
"github.com/onsi/ginkgo/types"
. "github.com/onsi/gomega"
)
var _ = Describe("DefaultReporter", func() {
var (
reporter *reporters.DefaultReporter
reporterConfig config.DefaultReporterConfigType
stenographer *st.FakeStenographer
ginkgoConfig config.GinkgoConfigType
suite *types.SuiteSummary
spec *types.SpecSummary
)
BeforeEach(func() {
stenographer = st.NewFakeStenographer()
reporterConfig = config.DefaultReporterConfigType{
NoColor: false,
SlowSpecThreshold: 0.1,
NoisyPendings: false,
Verbose: true,
FullTrace: true,
}
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
})
call := func(method string, args ...interface{}) st.FakeStenographerCall {
return st.NewFakeStenographerCall(method, args...)
}
Describe("SpecSuiteWillBegin", func() {
BeforeEach(func() {
suite = &types.SuiteSummary{
SuiteDescription: "A Sweet Suite",
NumberOfTotalSpecs: 10,
NumberOfSpecsThatWillBeRun: 8,
}
ginkgoConfig = config.GinkgoConfigType{
RandomSeed: 1138,
RandomizeAllSpecs: true,
}
})
Context("when a serial (non-parallel) suite begins", func() {
BeforeEach(func() {
ginkgoConfig.ParallelTotal = 1
reporter.SpecSuiteWillBegin(ginkgoConfig, suite)
})
It("should announce the suite, then announce the number of specs", func() {
Ω(stenographer.Calls()).Should(HaveLen(2))
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", "A Sweet Suite", ginkgoConfig.RandomSeed, true, false)))
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceNumberOfSpecs", 8, 10, false)))
})
})
Context("when a parallel suite begins", func() {
BeforeEach(func() {
ginkgoConfig.ParallelTotal = 2
ginkgoConfig.ParallelNode = 1
suite.NumberOfSpecsBeforeParallelization = 20
reporter.SpecSuiteWillBegin(ginkgoConfig, suite)
})
It("should announce the suite, announce that it's a parallel run, then announce the number of specs", func() {
Ω(stenographer.Calls()).Should(HaveLen(2))
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", "A Sweet Suite", ginkgoConfig.RandomSeed, true, false)))
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceParallelRun", 1, 2, false)))
})
})
})
Describe("BeforeSuiteDidRun", func() {
Context("when the BeforeSuite passes", func() {
It("should announce nothing", func() {
reporter.BeforeSuiteDidRun(&types.SetupSummary{
State: types.SpecStatePassed,
})
Ω(stenographer.Calls()).Should(BeEmpty())
})
})
Context("when the BeforeSuite fails", func() {
It("should announce the failure", func() {
summary := &types.SetupSummary{
State: types.SpecStateFailed,
}
reporter.BeforeSuiteDidRun(summary)
Ω(stenographer.Calls()).Should(HaveLen(1))
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceBeforeSuiteFailure", summary, false, true)))
})
})
})
Describe("AfterSuiteDidRun", func() {
Context("when the AfterSuite passes", func() {
It("should announce nothing", func() {
reporter.AfterSuiteDidRun(&types.SetupSummary{
State: types.SpecStatePassed,
})
Ω(stenographer.Calls()).Should(BeEmpty())
})
})
Context("when the AfterSuite fails", func() {
It("should announce the failure", func() {
summary := &types.SetupSummary{
State: types.SpecStateFailed,
}
reporter.AfterSuiteDidRun(summary)
Ω(stenographer.Calls()).Should(HaveLen(1))
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceAfterSuiteFailure", summary, false, true)))
})
})
})
Describe("SpecWillRun", func() {
Context("When running in verbose mode", func() {
Context("and the spec will run", func() {
BeforeEach(func() {
spec = &types.SpecSummary{}
reporter.SpecWillRun(spec)
})
It("should announce that the spec will run", func() {
Ω(stenographer.Calls()).Should(HaveLen(1))
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecWillRun", spec)))
})
})
Context("and the spec will not run", func() {
Context("because it is pending", func() {
BeforeEach(func() {
spec = &types.SpecSummary{
State: types.SpecStatePending,
}
reporter.SpecWillRun(spec)
})
It("should announce nothing", func() {
Ω(stenographer.Calls()).Should(BeEmpty())
})
})
Context("because it is skipped", func() {
BeforeEach(func() {
spec = &types.SpecSummary{
State: types.SpecStateSkipped,
}
reporter.SpecWillRun(spec)
})
It("should announce nothing", func() {
Ω(stenographer.Calls()).Should(BeEmpty())
})
})
})
})
Context("When running in verbose & succinct mode", func() {
BeforeEach(func() {
reporterConfig.Succinct = true
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
spec = &types.SpecSummary{}
reporter.SpecWillRun(spec)
})
It("should announce nothing", func() {
Ω(stenographer.Calls()).Should(BeEmpty())
})
})
Context("When not running in verbose mode", func() {
BeforeEach(func() {
reporterConfig.Verbose = false
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
spec = &types.SpecSummary{}
reporter.SpecWillRun(spec)
})
It("should announce nothing", func() {
Ω(stenographer.Calls()).Should(BeEmpty())
})
})
})
Describe("SpecDidComplete", func() {
JustBeforeEach(func() {
reporter.SpecDidComplete(spec)
})
BeforeEach(func() {
spec = &types.SpecSummary{}
})
Context("When the spec passed", func() {
BeforeEach(func() {
spec.State = types.SpecStatePassed
})
Context("When the spec was a measurement", func() {
BeforeEach(func() {
spec.IsMeasurement = true
})
It("should announce the measurement", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, false)))
})
})
Context("When the spec is slow", func() {
BeforeEach(func() {
spec.RunTime = time.Second
})
It("should announce that it was slow", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, false)))
})
})
Context("Otherwise", func() {
It("should announce the succesful spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec)))
})
})
})
Context("When the spec is pending", func() {
BeforeEach(func() {
spec.State = types.SpecStatePending
})
It("should announce the pending spec, succinctly", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, false)))
})
})
Context("When the spec is skipped", func() {
BeforeEach(func() {
spec.State = types.SpecStateSkipped
})
It("should announce the skipped spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSkippedSpec", spec, false, true)))
})
})
Context("When the spec timed out", func() {
BeforeEach(func() {
spec.State = types.SpecStateTimedOut
})
It("should announce the timedout spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecTimedOut", spec, false, true)))
})
})
Context("When the spec panicked", func() {
BeforeEach(func() {
spec.State = types.SpecStatePanicked
})
It("should announce the panicked spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecPanicked", spec, false, true)))
})
})
Context("When the spec failed", func() {
BeforeEach(func() {
spec.State = types.SpecStateFailed
})
It("should announce the failed spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecFailed", spec, false, true)))
})
})
Context("in noisy pendings mode", func() {
BeforeEach(func() {
reporterConfig.Succinct = false
reporterConfig.NoisyPendings = true
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
})
Context("When the spec is pending", func() {
BeforeEach(func() {
spec.State = types.SpecStatePending
})
It("should announce the pending spec, noisily", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, true)))
})
})
})
Context("in succinct mode", func() {
BeforeEach(func() {
reporterConfig.Succinct = true
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
})
Context("When the spec passed", func() {
BeforeEach(func() {
spec.State = types.SpecStatePassed
})
Context("When the spec was a measurement", func() {
BeforeEach(func() {
spec.IsMeasurement = true
})
It("should announce the measurement", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, true)))
})
})
Context("When the spec is slow", func() {
BeforeEach(func() {
spec.RunTime = time.Second
})
It("should announce that it was slow", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, true)))
})
})
Context("Otherwise", func() {
It("should announce the succesful spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec)))
})
})
})
Context("When the spec is pending", func() {
BeforeEach(func() {
spec.State = types.SpecStatePending
})
It("should announce the pending spec, succinctly", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, false)))
})
})
Context("When the spec is skipped", func() {
BeforeEach(func() {
spec.State = types.SpecStateSkipped
})
It("should announce the skipped spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSkippedSpec", spec, true, true)))
})
})
Context("When the spec timed out", func() {
BeforeEach(func() {
spec.State = types.SpecStateTimedOut
})
It("should announce the timedout spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecTimedOut", spec, true, true)))
})
})
Context("When the spec panicked", func() {
BeforeEach(func() {
spec.State = types.SpecStatePanicked
})
It("should announce the panicked spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecPanicked", spec, true, true)))
})
})
Context("When the spec failed", func() {
BeforeEach(func() {
spec.State = types.SpecStateFailed
})
It("should announce the failed spec", func() {
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecFailed", spec, true, true)))
})
})
})
})
Describe("SpecSuiteDidEnd", func() {
BeforeEach(func() {
suite = &types.SuiteSummary{}
reporter.SpecSuiteDidEnd(suite)
})
It("should announce the spec run's completion", func() {
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceSpecRunCompletion", suite, false)))
})
})
})

View file

@ -21,6 +21,7 @@ import (
type JUnitTestSuite struct {
XMLName xml.Name `xml:"testsuite"`
TestCases []JUnitTestCase `xml:"testcase"`
Name string `xml:"name,attr"`
Tests int `xml:"tests,attr"`
Failures int `xml:"failures,attr"`
Time float64 `xml:"time,attr"`
@ -59,6 +60,7 @@ func NewJUnitReporter(filename string) *JUnitReporter {
func (reporter *JUnitReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
reporter.suite = JUnitTestSuite{
Name: summary.SuiteDescription,
TestCases: []JUnitTestCase{},
}
reporter.testSuiteName = summary.SuiteDescription

View file

@ -1,247 +0,0 @@
package reporters_test
import (
"encoding/xml"
"io/ioutil"
"os"
"time"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/internal/codelocation"
"github.com/onsi/ginkgo/reporters"
"github.com/onsi/ginkgo/types"
. "github.com/onsi/gomega"
)
var _ = Describe("JUnit Reporter", func() {
var (
outputFile string
reporter Reporter
)
readOutputFile := func() reporters.JUnitTestSuite {
bytes, err := ioutil.ReadFile(outputFile)
Ω(err).ShouldNot(HaveOccurred())
var suite reporters.JUnitTestSuite
err = xml.Unmarshal(bytes, &suite)
Ω(err).ShouldNot(HaveOccurred())
return suite
}
BeforeEach(func() {
f, err := ioutil.TempFile("", "output")
Ω(err).ShouldNot(HaveOccurred())
f.Close()
outputFile = f.Name()
reporter = reporters.NewJUnitReporter(outputFile)
reporter.SpecSuiteWillBegin(config.GinkgoConfigType{}, &types.SuiteSummary{
SuiteDescription: "My test suite",
NumberOfSpecsThatWillBeRun: 1,
})
})
AfterEach(func() {
os.RemoveAll(outputFile)
})
Describe("a passing test", func() {
BeforeEach(func() {
beforeSuite := &types.SetupSummary{
State: types.SpecStatePassed,
}
reporter.BeforeSuiteDidRun(beforeSuite)
afterSuite := &types.SetupSummary{
State: types.SpecStatePassed,
}
reporter.AfterSuiteDidRun(afterSuite)
spec := &types.SpecSummary{
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
State: types.SpecStatePassed,
RunTime: 5 * time.Second,
}
reporter.SpecWillRun(spec)
reporter.SpecDidComplete(spec)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 0,
RunTime: 10 * time.Second,
})
})
It("should record the test as passing", func() {
output := readOutputFile()
Ω(output.Tests).Should(Equal(1))
Ω(output.Failures).Should(Equal(0))
Ω(output.Time).Should(Equal(10.0))
Ω(output.TestCases).Should(HaveLen(1))
Ω(output.TestCases[0].Name).Should(Equal("A B C"))
Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
Ω(output.TestCases[0].FailureMessage).Should(BeNil())
Ω(output.TestCases[0].Skipped).Should(BeNil())
Ω(output.TestCases[0].Time).Should(Equal(5.0))
})
})
Describe("when the BeforeSuite fails", func() {
var beforeSuite *types.SetupSummary
BeforeEach(func() {
beforeSuite = &types.SetupSummary{
State: types.SpecStateFailed,
RunTime: 3 * time.Second,
Failure: types.SpecFailure{
Message: "failed to setup",
ComponentCodeLocation: codelocation.New(0),
Location: codelocation.New(2),
},
}
reporter.BeforeSuiteDidRun(beforeSuite)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 1,
RunTime: 10 * time.Second,
})
})
It("should record the test as having failed", func() {
output := readOutputFile()
Ω(output.Tests).Should(Equal(1))
Ω(output.Failures).Should(Equal(1))
Ω(output.Time).Should(Equal(10.0))
Ω(output.TestCases[0].Name).Should(Equal("BeforeSuite"))
Ω(output.TestCases[0].Time).Should(Equal(3.0))
Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
Ω(output.TestCases[0].FailureMessage.Type).Should(Equal("Failure"))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("failed to setup"))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(beforeSuite.Failure.ComponentCodeLocation.String()))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(beforeSuite.Failure.Location.String()))
Ω(output.TestCases[0].Skipped).Should(BeNil())
})
})
Describe("when the AfterSuite fails", func() {
var afterSuite *types.SetupSummary
BeforeEach(func() {
afterSuite = &types.SetupSummary{
State: types.SpecStateFailed,
RunTime: 3 * time.Second,
Failure: types.SpecFailure{
Message: "failed to setup",
ComponentCodeLocation: codelocation.New(0),
Location: codelocation.New(2),
},
}
reporter.AfterSuiteDidRun(afterSuite)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 1,
RunTime: 10 * time.Second,
})
})
It("should record the test as having failed", func() {
output := readOutputFile()
Ω(output.Tests).Should(Equal(1))
Ω(output.Failures).Should(Equal(1))
Ω(output.Time).Should(Equal(10.0))
Ω(output.TestCases[0].Name).Should(Equal("AfterSuite"))
Ω(output.TestCases[0].Time).Should(Equal(3.0))
Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
Ω(output.TestCases[0].FailureMessage.Type).Should(Equal("Failure"))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("failed to setup"))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(afterSuite.Failure.ComponentCodeLocation.String()))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(afterSuite.Failure.Location.String()))
Ω(output.TestCases[0].Skipped).Should(BeNil())
})
})
specStateCases := []struct {
state types.SpecState
message string
}{
{types.SpecStateFailed, "Failure"},
{types.SpecStateTimedOut, "Timeout"},
{types.SpecStatePanicked, "Panic"},
}
for _, specStateCase := range specStateCases {
specStateCase := specStateCase
Describe("a failing test", func() {
var spec *types.SpecSummary
BeforeEach(func() {
spec = &types.SpecSummary{
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
State: specStateCase.state,
RunTime: 5 * time.Second,
Failure: types.SpecFailure{
ComponentCodeLocation: codelocation.New(0),
Location: codelocation.New(2),
Message: "I failed",
},
}
reporter.SpecWillRun(spec)
reporter.SpecDidComplete(spec)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 1,
RunTime: 10 * time.Second,
})
})
It("should record test as failing", func() {
output := readOutputFile()
Ω(output.Tests).Should(Equal(1))
Ω(output.Failures).Should(Equal(1))
Ω(output.Time).Should(Equal(10.0))
Ω(output.TestCases[0].Name).Should(Equal("A B C"))
Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
Ω(output.TestCases[0].FailureMessage.Type).Should(Equal(specStateCase.message))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("I failed"))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(spec.Failure.ComponentCodeLocation.String()))
Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(spec.Failure.Location.String()))
Ω(output.TestCases[0].Skipped).Should(BeNil())
})
})
}
for _, specStateCase := range []types.SpecState{types.SpecStatePending, types.SpecStateSkipped} {
specStateCase := specStateCase
Describe("a skipped test", func() {
var spec *types.SpecSummary
BeforeEach(func() {
spec = &types.SpecSummary{
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
State: specStateCase,
RunTime: 5 * time.Second,
}
reporter.SpecWillRun(spec)
reporter.SpecDidComplete(spec)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 0,
RunTime: 10 * time.Second,
})
})
It("should record test as failing", func() {
output := readOutputFile()
Ω(output.Tests).Should(Equal(1))
Ω(output.Failures).Should(Equal(0))
Ω(output.Time).Should(Equal(10.0))
Ω(output.TestCases[0].Name).Should(Equal("A B C"))
Ω(output.TestCases[0].Skipped).ShouldNot(BeNil())
})
})
}
})

View file

@ -1,13 +0,0 @@
package reporters_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestReporters(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Reporters Suite")
}

View file

@ -178,7 +178,7 @@ func (s *consoleStenographer) AnnounceSpecRunCompletion(summary *types.SuiteSumm
}
s.print(0,
"%s -- %s | %s | %s | %s ",
"%s -- %s | %s | %s | %s\n",
status,
s.colorize(greenColor+boldStyle, "%d Passed", summary.NumberOfPassedSpecs),
s.colorize(redColor+boldStyle, "%d Failed", summary.NumberOfFailedSpecs)+flakes,

View file

@ -10,10 +10,11 @@ package reporters
import (
"fmt"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/types"
"io"
"strings"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/types"
)
const (

View file

@ -1,213 +0,0 @@
package reporters_test
import (
"bytes"
"fmt"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/internal/codelocation"
"github.com/onsi/ginkgo/reporters"
"github.com/onsi/ginkgo/types"
. "github.com/onsi/gomega"
"time"
)
var _ = Describe("TeamCity Reporter", func() {
var (
buffer bytes.Buffer
reporter Reporter
)
BeforeEach(func() {
buffer.Truncate(0)
reporter = reporters.NewTeamCityReporter(&buffer)
reporter.SpecSuiteWillBegin(config.GinkgoConfigType{}, &types.SuiteSummary{
SuiteDescription: "Foo's test suite",
NumberOfSpecsThatWillBeRun: 1,
})
})
Describe("a passing test", func() {
BeforeEach(func() {
beforeSuite := &types.SetupSummary{
State: types.SpecStatePassed,
}
reporter.BeforeSuiteDidRun(beforeSuite)
afterSuite := &types.SetupSummary{
State: types.SpecStatePassed,
}
reporter.AfterSuiteDidRun(afterSuite)
spec := &types.SpecSummary{
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
State: types.SpecStatePassed,
RunTime: 5 * time.Second,
}
reporter.SpecWillRun(spec)
reporter.SpecDidComplete(spec)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 0,
RunTime: 10 * time.Second,
})
})
It("should record the test as passing", func() {
actual := buffer.String()
expected :=
"##teamcity[testSuiteStarted name='Foo|'s test suite']" +
"##teamcity[testStarted name='A B C']" +
"##teamcity[testFinished name='A B C' duration='5000']" +
"##teamcity[testSuiteFinished name='Foo|'s test suite']"
Ω(actual).Should(Equal(expected))
})
})
Describe("when the BeforeSuite fails", func() {
var beforeSuite *types.SetupSummary
BeforeEach(func() {
beforeSuite = &types.SetupSummary{
State: types.SpecStateFailed,
RunTime: 3 * time.Second,
Failure: types.SpecFailure{
Message: "failed to setup\n",
ComponentCodeLocation: codelocation.New(0),
},
}
reporter.BeforeSuiteDidRun(beforeSuite)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 1,
RunTime: 10 * time.Second,
})
})
It("should record the test as having failed", func() {
actual := buffer.String()
expected := fmt.Sprintf(
"##teamcity[testSuiteStarted name='Foo|'s test suite']"+
"##teamcity[testStarted name='BeforeSuite']"+
"##teamcity[testFailed name='BeforeSuite' message='%s' details='failed to setup|n']"+
"##teamcity[testFinished name='BeforeSuite' duration='3000']"+
"##teamcity[testSuiteFinished name='Foo|'s test suite']", beforeSuite.Failure.ComponentCodeLocation.String(),
)
Ω(actual).Should(Equal(expected))
})
})
Describe("when the AfterSuite fails", func() {
var afterSuite *types.SetupSummary
BeforeEach(func() {
afterSuite = &types.SetupSummary{
State: types.SpecStateFailed,
RunTime: 3 * time.Second,
Failure: types.SpecFailure{
Message: "failed to setup\n",
ComponentCodeLocation: codelocation.New(0),
},
}
reporter.AfterSuiteDidRun(afterSuite)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 1,
RunTime: 10 * time.Second,
})
})
It("should record the test as having failed", func() {
actual := buffer.String()
expected := fmt.Sprintf(
"##teamcity[testSuiteStarted name='Foo|'s test suite']"+
"##teamcity[testStarted name='AfterSuite']"+
"##teamcity[testFailed name='AfterSuite' message='%s' details='failed to setup|n']"+
"##teamcity[testFinished name='AfterSuite' duration='3000']"+
"##teamcity[testSuiteFinished name='Foo|'s test suite']", afterSuite.Failure.ComponentCodeLocation.String(),
)
Ω(actual).Should(Equal(expected))
})
})
specStateCases := []struct {
state types.SpecState
message string
}{
{types.SpecStateFailed, "Failure"},
{types.SpecStateTimedOut, "Timeout"},
{types.SpecStatePanicked, "Panic"},
}
for _, specStateCase := range specStateCases {
specStateCase := specStateCase
Describe("a failing test", func() {
var spec *types.SpecSummary
BeforeEach(func() {
spec = &types.SpecSummary{
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
State: specStateCase.state,
RunTime: 5 * time.Second,
Failure: types.SpecFailure{
ComponentCodeLocation: codelocation.New(0),
Message: "I failed",
},
}
reporter.SpecWillRun(spec)
reporter.SpecDidComplete(spec)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 1,
RunTime: 10 * time.Second,
})
})
It("should record test as failing", func() {
actual := buffer.String()
expected :=
fmt.Sprintf("##teamcity[testSuiteStarted name='Foo|'s test suite']"+
"##teamcity[testStarted name='A B C']"+
"##teamcity[testFailed name='A B C' message='%s' details='I failed']"+
"##teamcity[testFinished name='A B C' duration='5000']"+
"##teamcity[testSuiteFinished name='Foo|'s test suite']", spec.Failure.ComponentCodeLocation.String())
Ω(actual).Should(Equal(expected))
})
})
}
for _, specStateCase := range []types.SpecState{types.SpecStatePending, types.SpecStateSkipped} {
specStateCase := specStateCase
Describe("a skipped test", func() {
var spec *types.SpecSummary
BeforeEach(func() {
spec = &types.SpecSummary{
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
State: specStateCase,
RunTime: 5 * time.Second,
}
reporter.SpecWillRun(spec)
reporter.SpecDidComplete(spec)
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
NumberOfSpecsThatWillBeRun: 1,
NumberOfFailedSpecs: 0,
RunTime: 10 * time.Second,
})
})
It("should record test as ignored", func() {
actual := buffer.String()
expected :=
"##teamcity[testSuiteStarted name='Foo|'s test suite']" +
"##teamcity[testStarted name='A B C']" +
"##teamcity[testIgnored name='A B C']" +
"##teamcity[testFinished name='A B C' duration='5000']" +
"##teamcity[testSuiteFinished name='Foo|'s test suite']"
Ω(actual).Should(Equal(expected))
})
})
}
})