-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Testing
In the Ruby-based Magento documentation projects, the content testing is implemented using rake
tasks (https://github.com/ruby/rake). There are basic tasks check
and test
, whereas each runs prerequisite tasks that run actual tests.
There are two simple rules to remember about testing:
- Before you commit, run
rake check
. This will run tests on modified files only. - After you committed, run
rake test
. This will run tests on committed files only.
To see all available tasks, run rake --tasks
for shorten descriptions, or rake --describe
for full descriptions. You can filter tasks by attaching the filtering phrase to those commands such as rake --tasks check
or rake --describe test
. To view tasks with prerequisites, run rake --prereqs
. For more rake options, use rake --help
.
Runs local tests before you commit your changes. It check only uncommitted files:
- Markdown files are checked for correspondence to Markdown formatting style declared in rules at _checks/styles/style-rules-dev. We use the mdl tool for this (https://github.com/markdownlint/markdownlint).
- Images are checked for optimization with the image_optim tool (https://github.com/toy/image_optim).
rake check
is declared in the Rakefile and runs check
's dependencies sequentially to check images and Markdown formatting. You can trace the dependencies using the --dry-run
option:
$ rake --dry-run check
** Invoke check (first_time)
** Invoke check:image_optim (first_time)
** Execute (dry run) check:image_optim
** Invoke check:mdl (first_time)
** Execute (dry run) check:mdl
** Execute (dry run) check
The output demonstrates that all dependencies are declared with a check
namespace. All namespaces are declared in separate .rake
files at the rakelib directory.
Runs the Markdown linter (mdl) to check if content of the committed .md
files satisfies rules defined in the _checks/styles/style-rules-prod file. If no Markdown issues were found, the task cleans the local site after last build, runs a new build, and checks HTML using html-proofer
(https://github.com/gjtorikian/html-proofer) configured at _config.checks.yml. It will generate and launch a report about HTML check. The report will be stored at the tmp/.htmlproofer
directory in both Markdown and HTML formats.
rake test
is declared in the Rakefile and runs test
's dependencies sequentially to check images and Markdown formatting. You can trace the dependencies using the --dry-run
option:
$ rake test --dry-run
** Invoke test (first_time)
** Invoke test:md (first_time)
** Execute (dry run) test:md
** Invoke test:report (first_time)
** Invoke test:links (first_time)
** Invoke build (first_time)
** Invoke clean (first_time)
** Execute (dry run) clean
** Execute (dry run) build
** Invoke test:links_no_build (first_time)
** Execute (dry run) test:links_no_build
** Execute (dry run) test:links
** Execute (dry run) test:report
** Execute (dry run) test
The output contains dependencies with and without namespaces. The tasks without namespaces are declared at the Rakefile, and the tasks with a test
namespace are declared at the rakelib/test.rake file .