Giter Club home page Giter Club logo

nixt's Introduction

Nixt

Nixt is a unit-testing tool for Nixlang.

Installation

  • Add this repository to nixpkgs.overlays
  • Add nixt to environment.systemPackages or home.packages

Help

Run Nixlang unit-tests

Usage:
  nixt [options] [path]

Arguments:
  [path]           Path of source and tests (default: .)

Options:
  -d, --debug                Print debug information
  -v, --verbose              Print extra information
  -l, --list                 List discovered test suites
  -h, --help                 Show this help

Getting Started

The nixt CLI discovers and runs tests located at path:

# nixt ~/fooproj/src

Found 3 test suites
> always passes (/home/ldlework/fooproj/src/tests/always-pass.nix)
-- ✔ always true
> always fails (/home/ldlework/fooproj/src/tests/always-pass.nix)
-- ✗ always false
> syntax error (/home/ldlework/fooproj/src/tests/syntax-error.nix)
-- ✗ missing semicolon

⚠ 1 test PASSED but 2 tests FAILED ⚠

Adding in the -v/--verbose flag will show additional information on failed test cases:

# nixt -v ~/fooproj/src

Found 3 test suites
> always passes (/home/ldlework/fooproj/src/tests/always-pass.nix)
-- ✔ always true
> always fails (/home/ldlework/fooproj/src/tests/always-pass.nix)
-- ✗ always false
> syntax error (/home/ldlework/fooproj/src/tests/syntax-error.nix)
-- ✗ missing semicolon
error: syntax error, unexpected $end, expecting ';', at /home/ldlework/src/fooproj/src/options1.nix:10:2
(use '--show-trace' to show detailed location information)
⚠ 1 test PASSED but 2 tests FAILED ⚠

Two -v -v verbose flags implies --show-trace.

Writing Tests

Nixt tests are written in .nix files that:

  • Contain a function taking attrset args pkgs and nixt
  • Evaluate to a call to nixt.mkSuite
{ pkgs ? import <nixpkgs> {}, nixt }:

nixt.mkSuite "always passes" {
  "always true" = true;
}

nixt.mkSuite

mkSuite takes two arguments:

  • suite name/description
  • attrset of test cases

Each test case maps from case name/description to result.

Test case results should be a boolean specifying whether the case passed or failed.

Test cases may also throw a string to provide additional information about a failure.

nixt's People

Contributors

dustinlacewell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.