Skip to content

BATS (Bash Automated Testing System) language support for VSCode.

License

Notifications You must be signed in to change notification settings

bats-core/bats-vscode

Repository files navigation

BATS (Bash Automated Testing System) for VSCode

Current Version Install Count downloads Count GitHub tag (latest SemVer) license

This extension adds language support for the Bats (Bash Automated Testing System) testing framework to VS Code.

tada Features

Bats overview

  • Bats language support for VSCode
  • Syntax highlighting for core functions
  • Syntax highlighting for community modules
  • Code Snippets for quick coding for core functions
  • Code Snippets for quick coding for community modules

Bats logo

bat 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.

Note
See bats-core README for documentation on how to use Bats.

Bats modules

Project version code snippets syntax highlighting
https://github.com/bats-core/bats-core bats-core project Y Y
https://github.com/bats-core/bats-assert bats-assert project Y Y
https://github.com/bats-core/bats-support bats-support project N Y
https://github.com/bats-core/bats-file bats-file project N Y
https://github.com/lox/bats-mock bats-mock project N Y

scissors Snippets

These modules have snippets:

Type BATS:*snippet* to use snippets.

bats-core snippets

  • BATS:env : shebang.
  • BATS:setup : Setup function.
  • BATS:teardown : Teardown function.
  • BATS:load : Load common code.
  • BATS:bats_load_library : Load system-wide libraries.
  • BATS:test : Test case.
  • BATS:status : Test status code.
  • BATS:output : Test output.
  • BATS:line : Test line output.
  • BATS:skip : Skip test.

bats-assert snippets

  • BATS:assert
  • BATS:assert_output
  • BATS:assert_line
  • BATS:assert_success
  • BATS:assert_failure
  • BATS:assert_equal
  • BATS:assert_not_equal
  • BATS:refute
  • BATS:refute_output
  • BATS:refute_line

flashlight Syntax highlighting

These modules have syntax highlighting support:

art 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:

Bats overview

Example after saving the editor.tokenColorCustomizations settings below.

Bats overview

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"
                }
            }
        ]
    }
}

Bats logo

Installation

Extension Marketplace

This extension is published in the VSCode marketplace.

  1. Run Install Extensions from the Command Palette
  2. Search and choose bats.

Release Notes

See Changelog.

exclamationKnown Issues

GitHub issues

Feel free to report any issues.

Related Projects

If you like Bats, you may also like ShellCheck and the VSCode extension

This extension was inspired by sublime-bats.

scroll License

humans.txt

MIT