1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Run tests task for Elixir in Visual Studio Code

12/02/2016

In order to learn Linux I'm biting off more than I can chew by trying to learn Elixir at the same time. From the available code editors for Linux I'm using Visual Studio Code.

Visual Studio Code has the ability to configure custom tasks.

To get to the custom task configuration you can use the command palette with Ctrl + Shift + P and type Tasks: Configure Task Runner. This will open "tasks.json". Replace the contents with:

{
    "version": "0.1.0",
    "command": "bash",
    "isShellCommand": true,
    "showOutput": "always",
    "args": [
        "-c"
    ],
    "tasks": [
        {
            "taskName": "Elixir-Test",
            "suppressTaskName": true,
            "isTestCommand": true,
            "args": ["mix test"]
        }
    ]
}

And save the file. Now if you use Ctrl + Shift + T mix will run your tests for the project (assuming you have the mix.exs level folder open) and print the output to the console.

This command could probably be improved by checking that it's executing in the correct folder first but I'm nowhere near confident enough with Bash to write it yet.

Further notes from adventures in Elixir

Function capturing (Capture operator)

This concept took me a little while to get to grips with because I couldn't think of an equivalent from C#.

A typical anonymous function in Elixir might take this form:

square = fn x -> x * x end

You would then call it with the dot "." between the function name and the argument like this:

...

Git for beginners

08/02/2016

Out of the different Source Control options Git is definitely the one most worth learning, however, it's also one of the most confusing.

With that in mind I'm going to add to the crowded market of "Git beginners" tutorials. Hopefully given that I can still remember the struggle of learning it and that my current level of understanding probably rates as "simpleton" this will be a useful tutorial.

I'm going to be writing for Git on Windows and will try to assume no existing knowledge beyond knowing what a file and folder is. Because of this I'm going to make a lot of oversimplifications.

Install It

Use the download link here or Google "Windows Git" and click the first link.

After using the installation defaults, you're done.

Where does it install?

Depending on which architecture version (x86/x64) you installed it will probably install in either C:\Program Files\Git or C:\Program Files (x86)\Git.

...

Fixie Data Driven tests

04/02/2016

I tend to spend all my coding time nowadays plagued with guilt. I try to be a good developer and refactor the code, after running the tests, after writing the code, after running the tests, after writing the tests. But in the interests of getting any code written at all, I end up skipping between one and all of these steps (generally not the writing code part).

If this sounds like you, I cannot recommend Fixie strongly enough.

It's a low ceremony test framework that presents the minimum possible barrier to entry for the guilt driven tester/developer.

Positives

Fixie is so nice for a few reasons. Firstly it's self contained. After installing from NuGet, the Visual Studio test runner for Fixie is already set up.

This means you don't have to locate the correct package for your Visual Studio version. If you're lazy like me then you'll appreciate this time-saver.

To install from the package manager console use:

Install-Package Fixie

Or search "fixie" on the NuGet package manager.

The next point in its favour is your tests are just code. While MSTest and to some extent NUnit are an alphabetti spaghetti of attributes which challenge you to remember the difference between your [TestFixture] and [TestClass] attributes, Fixie requires no attributes to start working.

...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17