Exemplo n.º 1
0
func setupFakeReporter() (*fakeReporter, *fakeGoTest) {
	myReporter := fakeReporter{}
	myReporter.calls = []string{}
	reporter = &myReporter
	runner = execution.NewRunner()
	runner.UpgradeReporter(reporter)
	return &myReporter, &fakeGoTest{}
}
Exemplo n.º 2
0
func TestMissingTopLevelGoTestReferenceCausesPanic(t *testing.T) {
	runner = execution.NewRunner()

	output := map[string]bool{}

	defer expectEqual(t, false, output["good"])
	defer requireGoTestReference(t)

	Convey("Hi", func() {
		output["bad"] = true // this shouldn't happen
	})
}
Exemplo n.º 3
0
func TestMissingTopLevelGoTestReferenceAfterGoodExample(t *testing.T) {
	runner = execution.NewRunner()

	output := map[string]bool{}

	defer func() {
		expectEqual(t, true, output["good"])
		expectEqual(t, false, output["bad"])
	}()
	defer requireGoTestReference(t)

	Convey("Good example", t, func() {
		output["good"] = true
	})

	Convey("Bad example", func() {
		output["bad"] = true // shouldn't happen
	})
}
Exemplo n.º 4
0
func TestExtraReferencePanics(t *testing.T) {
	runner = execution.NewRunner()
	output := map[string]bool{}

	defer func() {
		err := recover()
		if err == nil {
			t.Error("We should have recovered a panic here (because of an extra *testing.T reference)!")
		} else if !strings.HasPrefix(fmt.Sprintf("%v", err), execution.ExtraGoTest) {
			t.Error("Should have panicked with the 'extra go test' error!")
		}
		if output["bad"] {
			t.Error("We should NOT have run the bad example!")
		}
	}()

	Convey("Good example", t, func() {
		Convey("Bad example - passing in *testing.T a second time!", t, func() {
			output["bad"] = true // shouldn't happen
		})
	})
}
Exemplo n.º 5
0
func (self *suiteContext) Run(entry *execution.Registration) {
	key := resolveTestPackageAndFunctionName()
	if self.currentRunner() != nil {
		panic(execution.ExtraGoTest)
	}
	reporter := buildReporter()
	runner := execution.NewRunner()
	runner.UpgradeReporter(reporter)

	self.lock.Lock()
	self.runners[key] = runner
	self.reporters[key] = reporter
	self.lock.Unlock()

	runner.Begin(entry)
	runner.Run()

	self.lock.Lock()
	delete(self.runners, key)
	delete(self.reporters, key)
	self.lock.Unlock()
}
Exemplo n.º 6
0
func (self *suiteContext) Run(entry *execution.Registration) {
	if self.current() != nil {
		panic(execution.ExtraGoTest)
	}

	reporter := buildReporter()
	runner := execution.NewRunner()
	runner.UpgradeReporter(reporter)

	testName, location, _ := suiteAnchor()

	self.lock.Lock()
	self.locations[location] = testName
	self.runners[testName] = runner
	self.lock.Unlock()

	runner.Begin(entry)
	runner.Run()

	self.lock.Lock()
	delete(self.locations, location)
	delete(self.runners, testName)
	self.lock.Unlock()
}
Exemplo n.º 7
0
func prepare() string {
	runner = execution.NewRunner()
	reporting.QuietMode()
	return ""
}
Exemplo n.º 8
0
func configureRunner() {
	reporter = buildReporter()
	runner = execution.NewRunner()
	runner.UpgradeReporter(reporter)
}