Detected tests
Doc Detective can automatically generate tests based on your documentation source files and your fileTypes configuration. Detected tests are useful for large, complex test suites that you want to keep in sync with your documentation. To enable test detection, set detectSteps to true and define markup patterns and associated actions in the fileTypes.markup array of your config. Doc Detective uses those to extract steps from your doc source files. You can define multiple test patterns in your config to extract different types of tests from your documentation.
Detected tests are useful for keeping your tests in sync with your documentation. When you update your documentation, Doc Detective automatically updates the tests based on the new content. Detected tests are generated automatically. You can’t edit detected tests directly, but you can update your config or documentation source files to change the tests.
You can mix detected tests with inline tests to declare steps your content might not cover, such starting or stopping a recording.
Benefits of detected tests
Detected tests provide several advantages:
- Automatic synchronization: Tests update automatically when documentation changes
- Reduced maintenance: No need to manually update test specifications
- Consistent coverage: Ensures all documented procedures are tested
- Time savings: Eliminates the need to write many test specifications manually
Combine detected tests with inline tests for comprehensive test coverage with minimal manual effort.
Default markup patterns
Doc Detective includes default markup patterns for Markdown and DITA files. For comprehensive information about each input format and their patterns, see Input formats.
Markdown patterns
Doc Detective recognizes common Markdown patterns and converts them into test actions:
- checkHyperlink: Standard Markdown links like
[link text](https://example.com)generatecheckLinkactions - clickOnscreenText: Action verbs followed by bold text like
Click **Button Name**generateclickactions - findOnscreenText: Bold text like
**Any Bold Text**generatesfindactions - goToUrl: Navigation instructions with links like
Go to [Page Name](https://example.com)generategoToactions - screenshotImage: Images with a
.screenshotclass like{.screenshot}generatescreenshotactions - typeText: Typing instructions like
Type "Hello World"generatetypeactions - httpRequestFormat: HTTP request code blocks generate
httpRequestactions - runCode: Code blocks with language tags generate
runCodeactions
For the complete Markdown pattern configuration and detailed examples, see Markdown input format.
DITA patterns
Beta: DITA markup patterns are available in beta and subject to change.
Doc Detective extracts tests from DITA task topics using semantic markup. It recognizes DITA elements like <uicontrol>, <userinput>, <systemoutput>, <shortcut>, and <cmdname> within <cmd> elements and automatically generates tests from properly structured DITA content.
Key DITA patterns include:
- clickUiControl:
<cmd>Click the <uicontrol>Submit</uicontrol> button</cmd>generatesclickactions - typeIntoUiControl:
<cmd>Type <userinput>text</userinput> into the <uicontrol>Field</uicontrol></cmd>generatestypeactions - navigateToXref:
<cmd>Navigate to <xref href="https://example.com">Site</xref></cmd>generatesgoToactions - verifySystemOutput:
<cmd>Verify <systemoutput>Success</systemoutput></cmd>generatesfindactions - checkExternalXref: External links with
scope="external"generatecheckLinkactions
For the complete DITA pattern configuration and semantic element reference, see DITA input format.
Example with detected tests
With the default configuration, Doc Detective takes the following Markdown and generates tests automatically:
Markdown:
Detected tests:
Custom markup patterns
You can extend or override the default patterns by defining custom markup patterns in your configuration:
Default actions
If you only need to perform basic steps, you can define actions using a shorthand of only specifying the action name. Doc Detective uses default actions. It substitutes the first capture group from the regex pattern into the most common location for the action. When there are no capture groups, it substitutes the entire match.
The default actions are as follows:
checkLink
Check that the match returns a valid status code.
click
Click or tap the match.
goTo
Open the match as a URL in a browser.
find
Find an element on the current page that has an ARIA label that equals the match.
screenshot
Save a screenshot to a path equalling the match.
type
Type the match into the current page.
httpRequest
Make an GET request to the match.
runShell
Run the match as a shell command.
record
Start recording a video to a path equalling the match.
stopRecord
Stop recording a video.
wait
Wait for the specified duration.
loadVariables
Load environment variables from an .env file, where the path is the match.
saveCookie
Save a browser cookie by name to a default location.
loadCookie
Load a browser cookie by name from a default location.