gotest.go 674 B

123456789101112131415161718192021222324252627282930313233
  1. package reporting
  2. type gotestReporter struct{ test T }
  3. func (self *gotestReporter) BeginStory(story *StoryReport) {
  4. self.test = story.Test
  5. }
  6. func (self *gotestReporter) Enter(scope *ScopeReport) {}
  7. func (self *gotestReporter) Report(r *AssertionResult) {
  8. if !passed(r) {
  9. self.test.Fail()
  10. }
  11. }
  12. func (self *gotestReporter) Exit() {}
  13. func (self *gotestReporter) EndStory() {
  14. self.test = nil
  15. }
  16. func (self *gotestReporter) Write(content []byte) (written int, err error) {
  17. return len(content), nil // no-op
  18. }
  19. func NewGoTestReporter() *gotestReporter {
  20. return new(gotestReporter)
  21. }
  22. func passed(r *AssertionResult) bool {
  23. return r.Error == nil && r.Failure == ""
  24. }