Busted: Excluding Tags

Busted is a unit testing framework for Lua. Busted allows you to mark tests with tags, which look like this:

describe("User management controls #admin", function ()

    -- Here we define tests with it() or use describe() to further
    -- breakdown our tests into sub-groups.


Is this example #admin is the tag. One use for tags is that we can restrict which tests Busted will run. For example, if we only want to run tests with that tag we can do this:

$ busted --tags="admin"

The latest version of Busted at this time of writing, version 1.10, provides a new feature for tags: exclusion. Sometimes you may want to run every test except the ones marked by certain tags. Here is an example from a module of the game I’m developing. The tests have a #delay tag because they create intentional pauses, such as making a test wait ten seconds. That makes them the most time-consuming tests. So I often want Busted to skip those tests, and that is exactly what the new --exclude-tags option is for in Busted version 1.10. That means I can do this:

$ busted --exclude-tags="delay"

This significantly decreases the amount of time it takes to run the test suite. I configure Busted to exclude them by default so that I do not have to type the command-line option each time.

And that is all I wanted to talk about with this short post. If you use Busted and have time-consuming tests then you may find this feature useful for excluding those tests. You will see in the documentation that you can also mix using tags while excluding other tags, giving you even further control over exactly what tests to run and which ones to ignore.


Add Your Thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s