Пример #1
0
func (s *FoundationS) TestExpectFailureSucceed(c *gocheck.C) {
	helper := ExpectFailureSucceedHelper{}
	output := String{}
	result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output})

	c.Assert(output.value, gocheck.Equals, "")
	c.Assert(result.ExpectedFailures, gocheck.Equals, 1)
}
Пример #2
0
func (s *BootstrapS) TestRunDoesntShowSuccesses(c *gocheck.C) {
	output := String{}
	gocheck.Run(&SuccessHelper{}, &gocheck.RunConf{Output: &output})
	if strings.Index(output.value, "Expected success!") != -1 {
		critical(fmt.Sprintf("RunWithWriter() output contained a successful "+
			"test! Got: %#v",
			output.value))
	}
}
Пример #3
0
func (s *BootstrapS) TestRunShowsErrors(c *gocheck.C) {
	output := String{}
	gocheck.Run(&FailHelper{}, &gocheck.RunConf{Output: &output})
	if strings.Index(output.value, "Expected failure!") == -1 {
		critical(fmt.Sprintf("RunWithWriter() output did not contain the "+
			"expected failure! Got: %#v",
			output.value))
	}
}
Пример #4
0
func (s *FoundationS) TestSkip(c *gocheck.C) {
	helper := SkipTestHelper{}
	output := String{}
	gocheck.Run(&helper, &gocheck.RunConf{Output: &output})

	if output.value != "" {
		c.Error("Skip() logged something:\n", output.value)
	}
}
Пример #5
0
func (s *FoundationS) TestSkipVerbose(c *gocheck.C) {
	helper := SkipTestHelper{}
	output := String{}
	gocheck.Run(&helper, &gocheck.RunConf{Output: &output, Verbose: true})

	expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" +
		" \\(Wrong platform or whatever\\)"
	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("Skip() didn't log properly:\n", output.value)
	}
}
Пример #6
0
func (s *HelpersS) TestMkDir(c *gocheck.C) {
	helper := MkDirHelper{}
	output := String{}
	gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
	c.Assert(output.value, gocheck.Equals, "")
	c.Check(helper.isDir1, gocheck.Equals, true)
	c.Check(helper.isDir2, gocheck.Equals, true)
	c.Check(helper.isDir3, gocheck.Equals, true)
	c.Check(helper.isDir4, gocheck.Equals, true)
	c.Check(helper.path1, gocheck.Not(gocheck.Equals),
		helper.path2)
	c.Check(isDir(helper.path1), gocheck.Equals, false)
	c.Check(isDir(helper.path2), gocheck.Equals, false)
}
Пример #7
0
func (s *FoundationS) TestFailureHeader(c *gocheck.C) {
	output := String{}
	failHelper := FailHelper{}
	gocheck.Run(&failHelper, &gocheck.RunConf{Output: &output})
	header := fmt.Sprintf(""+
		"\n-----------------------------------"+
		"-----------------------------------\n"+
		"FAIL: gocheck_test.go:%d: FailHelper.TestLogAndFail\n",
		failHelper.testLine)
	if strings.Index(output.value, header) == -1 {
		c.Errorf(""+
			"Failure didn't print a proper header.\n"+
			"... Got:\n%s... Expected something with:\n%s",
			output.value, header)
	}
}
Пример #8
0
func (s *FoundationS) TestExpectFailureSucceedVerbose(c *gocheck.C) {
	helper := ExpectFailureSucceedHelper{}
	output := String{}
	result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output, Verbose: true})

	expected := "" +
		"FAIL EXPECTED: foundation_test\\.go:[0-9]+:" +
		" ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n"

	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("ExpectFailure() didn't log properly:\n", output.value)
	}

	c.Assert(result.ExpectedFailures, gocheck.Equals, 1)
}
Пример #9
0
func (s *FoundationS) TestExpectFailureFail(c *gocheck.C) {
	helper := ExpectFailureFailHelper{}
	output := String{}
	result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output})

	expected := "" +
		"^\n-+\n" +
		"FAIL: foundation_test\\.go:[0-9]+:" +
		" ExpectFailureFailHelper\\.TestFail\n\n" +
		"\\.\\.\\. Error: Test succeeded, but was expected to fail\n" +
		"\\.\\.\\. Reason: Bug #XYZ\n$"

	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("ExpectFailure() didn't log properly:\n", output.value)
	}

	c.Assert(result.ExpectedFailures, gocheck.Equals, 0)
}