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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
0c9b9a70
Commit
0c9b9a70
authored
May 22, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document the on-demand run of MySQL tests
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
d02d3e34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+22
-12
No files found.
doc/development/testing_guide/best_practices.md
View file @
0c9b9a70
...
...
@@ -2,19 +2,29 @@
## Test Design
Testing at GitLab is a first class citizen, not an afterthought. It's important we consider the design of our tests
as we do the design of our features.
Testing at GitLab is a first class citizen, not an afterthought. It's important we consider the design of our tests
as we do the design of our features.
When implementing a feature, we think about developing the right capabilities the right way, which helps us
narrow our scope to a manageable level. When implementing tests for a feature, we must think about developing
the right tests, but then cover _all_ the important ways the test may fail, which can quickly widen our scope to
When implementing a feature, we think about developing the right capabilities the right way, which helps us
narrow our scope to a manageable level. When implementing tests for a feature, we must think about developing
the right tests, but then cover _all_ the important ways the test may fail, which can quickly widen our scope to
a level that is difficult to manage.
Test heuristics can help solve this problem. They concisely address many of the common ways bugs
manifest themselves within our code. When designing our tests, take time to review known test heuristics to inform
our test design. We can find some helpful heuristics documented in the Handbook in the
Test heuristics can help solve this problem. They concisely address many of the common ways bugs
manifest themselves within our code. When designing our tests, take time to review known test heuristics to inform
our test design. We can find some helpful heuristics documented in the Handbook in the
[
Test Design
](
https://about.gitlab.com/handbook/engineering/quality/guidelines/test-engineering/test-design/
)
section.
## Run tests against MySQL
By default, tests are only run againts PostgreSQL, but you can run them on
demand against MySQL by following one of the following conventions:
| Convention | Valid example |
|:----------------------|:-----------------------------|
| Include
`mysql`
in your branch name |
`enhance-mysql-support`
|
| Include
`[run mysql]`
in your commit message |
`Fix MySQL support<br><br>[run mysql]`
|
## Test speed
GitLab has a massive test suite that, without [parallelization], can take hours
...
...
@@ -184,11 +194,11 @@ instead of 30+ seconds in case of a regular `spec_helper`.
### `let` variables
GitLab's RSpec suite has made extensive use of
`let`
(along with it strict, non-lazy
version
`let!`
) variables to reduce duplication. However, this sometimes
[
comes at the cost of clarity
][
lets-not
]
,
version
`let!`
) variables to reduce duplication. However, this sometimes
[
comes at the cost of clarity
][
lets-not
]
,
so we need to set some guidelines for their use going forward:
-
`let!`
variables are preferable to instance variables.
`let`
variables
are preferable to
`let!`
variables. Local variables are preferable to
are preferable to
`let!`
variables. Local variables are preferable to
`let`
variables.
-
Use
`let`
to reduce duplication throughout an entire spec file.
-
Don't use
`let`
to define variables used by a single test; define them as
...
...
@@ -199,8 +209,8 @@ so we need to set some guidelines for their use going forward:
-
Try to avoid overriding the definition of one
`let`
variable with another.
-
Don't define a
`let`
variable that's only used by the definition of another.
Use a helper method instead.
-
`let!`
variables should be used only in case if strict evaluation with defined
order is required, otherwise
`let`
will suffice. Remember that
`let`
is lazy and won't
-
`let!`
variables should be used only in case if strict evaluation with defined
order is required, otherwise
`let`
will suffice. Remember that
`let`
is lazy and won't
be evaluated until it is referenced.
[
lets-not
]:
https://robots.thoughtbot.com/lets-not
...
...
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