summaryrefslogtreecommitdiff
path: root/doc/development/testing_guide
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-02 00:06:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-02 00:06:26 +0000
commit587794b4b8a6e919e77ee4abe8215fa291e6a91d (patch)
tree380d6578d1ab5902bb521071128bafd4f70472ef /doc/development/testing_guide
parente0bd3a45d9dc6c74cac1a33ea8c03d6d8334249b (diff)
downloadgitlab-ce-587794b4b8a6e919e77ee4abe8215fa291e6a91d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/testing_guide')
-rw-r--r--doc/development/testing_guide/best_practices.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md
index 223ebdc6ee4..01db92b09c9 100644
--- a/doc/development/testing_guide/best_practices.md
+++ b/doc/development/testing_guide/best_practices.md
@@ -202,8 +202,36 @@ so we need to set some guidelines for their use going forward:
order is required, otherwise `let` will suffice. Remember that `let` is lazy and won't
be evaluated until it is referenced.
+### `let_it_be` variables
+
+In some cases there is no need to recreate the same object for tests
+again for each example. For example, a project is needed to test issues
+on the same project, one project will do for the entire file. This can
+be achieved by using
+[`let_it_be`](https://test-prof.evilmartians.io/#/let_it_be) variables
+from the [`test-prof` gem](https://rubygems.org/gems/test-prof).
+
+Note that if you modify an object defined inside a `let_it_be` block,
+then you will need to reload the object as needed, or specify the `reload`
+option to reload for every example.
+
+```
+let_it_be(:project, reload: true) { create(:project) }
+```
+
+You can also specify the `refind` option as well to completely load a
+new object.
+
+```
+let_it_be(:project, refind: true) { create(:project) }
+```
+
### `set` variables
+NOTE: **Note:**
+We are incrementally removing `set` in favour of `let_it_be`. See the
+[removal issue](https://gitlab.com/gitlab-org/gitlab/issues/27922).
+
In some cases there is no need to recreate the same object for tests again for
each example. For example, a project is needed to test issues on the same
project, one project will do for the entire file. This can be achieved by using