Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b0409589
Commit
b0409589
authored
Sep 28, 2019
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Developer docs: document let_it_be
Deprecate set in favor of let_it_be.
parent
68684a3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+28
-0
No files found.
doc/development/testing_guide/best_practices.md
View file @
b0409589
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment