Skip to Content

Visual Studio Code - Tasks

Since switching to VSCode I’ve started to explore some of it’s more advanced features.

At work currently we’re still using SVN (sigh) and I have no easy access to pre/post commit hooks like in Git. Usually I’d have a hook to run my unit tests locally before I commit. Reading through the docs I discovered VSCode has the concept of tasks to ‘integrate with external tools’… hmmmmm.

Ideally tasks are supposed to be used to build/compile/etc and can be used with things like Grunt and Gulp but I thought I could use it to quickly run my unit tests on request. With TestBox I can call my tests via URL in a browser and see results. This is a bit tedious to do manually but using a task I could make this a simple keypress in my editor.

When you use VSCode it will create a .vscode directory in your project to store settings, etc. Within that directory that you can create a file named tasks.json and copy the following snippet of code into that file:

    // See
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
			"label": "Run tests",
			"command": "Chrome",
			"windows": {
				"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
			"args": [
			"group": {
				"kind": "build",
				"isDefault": true

This assumes a few things

  1. I have Chrome installed (I’m using Windows) and available at the path in the ‘command’ statement
  2. My TestBox tests can be run via the URL defined in the args statement “http://ims.local/_tests"

In VSCode I can now hit CTRL+SHIFT+B (or Terminal > Run Build Task) and Chrome will be opened the the specified URL and my tests will run.

This is a simple example but solved a problem for me and was a great way to get started with tasks.

In my next post I’ll dive into a more complex task to run our Robot Framework tests.