Julia v1.5 Testing: How to Organize Tests

We explore how Julia tests are organized differently from what you may be used to in other testing frameworks.

Erik Engheim
Published in
7 min readJan 21, 2021

Julia development practices will likely not be the same as what you have experienced in Java, JavaScript, Python, Ruby and other popular programming languages.

Thus in this story I will do a sort of quick recap of how testing is often done in other languages and compare that with the common practice followed in Julia as exemplified by the Julia standard library.

How to effectively run tests: Julia v1.5 Testing: Best Practices.

No Tests But Nested Test Sets

Testing in Julia is a lot more free form than what you may be used to. For contrast let me show some examples from other tests frameworks.


Pytest is a frequently used testing framework for Python. Here one simply prefixes functions that represents tests with test_ as shown below:

# Python: Pytest

def capital_case(x):
return x.capitalize()

def test_capital_case():
assert capital_case('semaphore') == 'Semaphore'

In Python one would execute these tests by running:

$ pytest

Go Unit Tests

Go comes with a builtin unit testing framework. Why I am showing all these frameworks instead of jumping straight to Julia? Because these work how people are used to. And I need something to contrast with to help clarify how Julia testing is different.

// Go
package main

import "testing"

func TestSum(t *testing.T) {
total := Sum(5, 5)
if total != 10 {
t.Errorf("Sum was incorrect, got: %d, want: %d.", total, 10)

For Go tests you put them in a file which ends with _test such as foobar_test.go. Each test is placed in a function starting with Test.

$ go test

This will look for the files ending with _test.go and treat every function with a Test prefix taking a testing.T type argument as a test.




Erik Engheim

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.