BATS (Bash Automated Testing System) for VSCode
This extension adds language support for the Bats (Bash Automated Testing System) testing framework to VS Code.
Features
- [x] Bats language support for VSCode
- [x] Syntax highlighting for core functions
- [x] Syntax highlighting for community modules
- [x] Code Snippets for quick coding for core functions
- [x] Code Snippets for quick coding for community modules
Bats
Bash Automated Testing System (2021) is a community-maintained Bats project.
(c) 2011-2016 Sam Stephenson
(c) 2017-2021 bats-core organization
Bats is a TAP-compliant testing framework for Bash. It provides a simple way to verify that the UNIX programs you write behave as expected.
A .bats
test file is a Bash script with special syntax for defining test cases. Under the hood, each test case is just a function with a description.
See bats-core README for documentation on how to use Bats.
Bats modules
Snippets
These modules have snippets:
Type BATS:*snippet*
to use snippets.
- [x] BATS:env : shebang.
- [x] BATS:setup : Setup function.
- [x] BATS:teardown : Teardown function.
- [x] BATS:load : Load common code.
- [x] BATS:bats_load_library : Load system-wide libraries.
- [x] BATS:test : Test case.
- [x] BATS:status : Test status code.
- [x] BATS:output : Test output.
- [x] BATS:line : Test line output.
- [x] BATS:skip : Skip test.
- [x] BATS:assert
- [x] BATS:assert_output
- [x] BATS:assert_line
- [x] BATS:assert_success
- [x] BATS:assert_failure
- [x] BATS:assert_equal
- [x] BATS:assert_not_equal
- [x] BATS:refute
- [x] BATS:refute_output
- [x] BATS:refute_line
Syntax highlighting
These modules have syntax highlighting support:
Color customizations
If you want Bats
syntax highlighting to look different to shellscript
syntax, you can change your user preferences or workspace settings (.vscode/settings.json
).
Default theme, for shellscript
:
Example after saving the editor.tokenColorCustomizations
settings below.
Add this to your VS Code settings.
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "keyword.control.bats",
"settings": {
"foreground": "#9f1fd1",
"fontStyle": "italic"
}
},
{
"scope": "support.function.bats",
"settings": {
"foreground": "#d41515",
"fontStyle": "italic"
}
},
{
"scope": "support.variable.bats",
"settings": {
"foreground": "#329432",
"fontStyle": "italic"
}
}
]
}
}
Installation
Extension Marketplace
This extension is published in the VSCode marketplace.
- Run Install Extensions from the Command Palette
- Search and choose
bats
.
Release Notes
See Changelog.
Known Issues
Feel free to report any issues.
If you like Bats, you may also like ShellCheck and the VSCode extension
This extension was inspired by sublime-bats.
MIT