rspec中的let和let!区别

文档

https://relishapp.com/rspec/rspec-core/v/2-5/docs/helper-methods/let-and-let

从上面文档中得出 

let

1 只会在一个example(一个it 代码块)中调用一次,并不会在多个example中共享 ,

2 必须被显示调用,不会被隐世提前调用

 

let!

1 每个example执行前被隐式自动调用

2 在其他example中返回已经调用的内存中的引用,不会重新调用 ,意味着在多个example中,后面的example可以使用前面调用过的版本

posted on 2017-11-17 23:03  c3tc3tc3t  阅读(460)  评论(0编辑  收藏  举报