Giter Club home page Giter Club logo

uno's Introduction

 _ _ ___ ___
| | |   | . |
|___|_|_|___|

Uno: The simplest unit testing framework possible!

  • One file uno.js
  • One function uno
  • No dependencies
  • Results are printed to console.log

How to test functions

Example: Math.round function:

uno(Math.round, [1.5], 2)

Output:

   logs:  "Uno test passed: round(1.5) == 2"
returns:  true

Usage:

uno(name, fn, args, expected)
  • name (optional) The name of the test. Excepts {inputs}, see below.
  • fn The function to test
  • args A list of arguments passed to fn
  • expected What fn(args) should return

How to test methods

Example: Date object:

var date = new Date("October 31, 2012");
uno(date, date.getFullYear, [], 2012)

Output:

   logs:  "Uno test passed: object.getFullYear() == 2012"
returns:  true

Usage:

uno(name, object, method, args, expected)
  • name (optional) The name of the test. Excepts {inputs}, see below.
  • object The object to test
  • method The method to test (in the context of object)
  • args A list of arguments passed to method
  • expected What object.method(args) should return

{inputs}

All name options support {input} strings. Here is a full list:

{method}             // alias: {function} {fn} {f}
{args}               // alias: {arguments} {input} {in}
{result}             // alias: {output} {out}
{expected}

Example: Math.round function with custom name

uno('Math.{fn}({args}), result: {result}, expected: {expected}', Math.round, [1.5], 2)

Output:

   logs:  "Uno test passed: Math.round(1.5), result: 2, expected: 2]"
returns:  true

Example: Date object with a custom name:

var date = new Date("October 31, 2012");
uno('date.{method}({args}) == {expected}', date, date.getFullYear, [], 2012)

Output:

   logs:  "Uno test passed: date.getFullYear() == 2012"
returns:  true

Full {input} list

How to test values

(Almost done coding this)

How to profile

(Still coding this one)

But wait... there is more!

  • Uno hooks into other unit testing frameworks and does the right thing to make them work too.
  • Uno auto names tests using the function name and arguments

Supported unit testing frameworks

  • qunit (close to finished)
  • fireunit (close to finished)
  • junit (just starting support)

Install by source

Install to node

npm install uno

Usage in node

uno = require('uno')

uno(Math.round, [1.5], 2)      // logs: "Uno test passed: round(1.5) == 2"

uno's People

Contributors

evanmoran avatar

Stargazers

 avatar Andrija Cacanović avatar  avatar

Watchers

 avatar James Cloos 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.