Testing

There are many aspects to testing software throughout the development lifecycle.

Category Description
Unit testing Assertion based testing of specific functions (units)
Specification testing Checking data and functions conform to clojure.spec specifications
Generative testing Automatically generated data to test specifications
Integration testing Tests across system components and multiple systems, typically during the build process
Performance testing Measuring the resources taken during function calls and system events
Load testing Measuring the capacity for the system to manage concurrent events

Unit testing

clojure.test is the de facto unit testing framework for Clojure. Tests have a simple syntax using deftest to contain multiple assertions defined with is. It is part of the Clojure.core library and therefore accessible to all Clojure projects.

expectations.clojure.test library can be added to clojure test to provide expectations style assertions (expect, more, more-of, etc.).

Specification testing - clojure.spec

Defining specifications around functions and data structures, testing to ensure those contracts are not broken. Instrumentation of functions ensures that function calls follow specifications, including arguments, return values and a relationship between both.

Generative Testing

Tests are only as good as the thought that goes into them. Generative testing can create a wider range of testing scenarios by providing generated data for tests. This approach is very good at catching conditions that were not considered.

Integration testing

Using Continuous Integration (CI) tools: CircleCI, Travis, GitLabs, etc.

Clojure has several test runners that can be used with CI servers

  • cognitect-labs test runner
  • Koacha
  • eftest
  • midje test runner

deps.edn aliases for Clojure test runners

Performance testing

Tesing the execution time of specific functions or groups of functions, typically within a namespace.

time is a quick and easy tool to give a rough comparison of performance.

criterium provides more accurate guidance on performance

Load / Stress Testing

Testing the whole system under loads to simulate the stress the system would be placed under in normal production environments.

Gattling is a JVM load tool.

There are many on-line load testing tools if you have a web facing application.

results matching ""

    No results matching ""