当前位置: 首页>>代码示例>>Golang>>正文


Golang Context.Assume方法代码示例

本文整理汇总了Golang中github.com/orfjackal/nanospec/go/src/nanospec.Context.Assume方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Assume方法的具体用法?Golang Context.Assume怎么用?Golang Context.Assume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/orfjackal/nanospec/go/src/nanospec.Context的用法示例。


在下文中一共展示了Context.Assume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ExpectationsSpec

func ExpectationsSpec(c nanospec.Context) {

	c.Specify("When a spec has passing expectations or assumptions", func() {
		results := runSpec(func(c Context) {
			c.Expect(1, Equals, 1)
			c.Assume(1, Equals, 1)
			c.Specify("Child", func() {})
		})

		c.Specify("then the spec passes", func() {
			c.Expect(results.FailCount()).Equals(0)
		})
		c.Specify("then its children are executed", func() {
			c.Expect(results.TotalCount()).Equals(2)
		})
	})

	c.Specify("When a spec has failing expectations", func() {
		results := runSpec(func(c Context) {
			c.Expect(1, Equals, 2)
			c.Specify("Child", func() {})
		})

		c.Specify("then the spec fails", func() {
			c.Expect(results.FailCount()).Equals(1)
		})
		c.Specify("then its children are executed", func() {
			c.Expect(results.TotalCount()).Equals(2)
		})
	})

	c.Specify("When a spec has failing assumptions", func() {
		results := runSpec(func(c Context) {
			c.Assume(1, Equals, 2)
			c.Specify("Child", func() {})
		})

		c.Specify("then the spec fails", func() {
			c.Expect(results.FailCount()).Equals(1)
		})
		c.Specify("then its children are NOT executed", func() {
			c.Expect(results.TotalCount()).Equals(1)
		})
	})

	c.Specify("The location of a failed expectation is reported", func() {
		results := runSpec(func(c Context) {
			c.Expect(1, Equals, 2)
		})
		c.Expect(fileOfError(results)).Equals("expectations_test.go")
	})
	c.Specify("The location of a failed assumption is reported", func() {
		results := runSpec(func(c Context) {
			c.Assume(1, Equals, 2)
		})
		c.Expect(fileOfError(results)).Equals("expectations_test.go")
	})
}
开发者ID:rafrombrc,项目名称:gospec,代码行数:58,代码来源:expectations_test.go


注:本文中的github.com/orfjackal/nanospec/go/src/nanospec.Context.Assume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。