Giter Club home page Giter Club logo

jltest's Introduction

JLTest

Build Status

A unittest framework for Julia (inspired by Python's unittest)

Usage


using JLTest

@testcase begin
    @casename "Mytest Tests"

    #Some code
    x = 0

    #Function to be called before each test (optional)
    @setUp () -> (x+=1)

    #Function to be called after each test (optional)
    @tearDown () -> (x=0)

    @test begin
        @testname "A Simple Test" #Name of test (optional)
        @assertEqual(x,1)
    end

    #more tests or code...

end # end of test case

Available Test Macros

NOTE: [...] below indicates optional args not array

###@testcase begin ... end

Setup a test case (collection of related tests)

###@test begin ... end

Setup a test

###@testskip [cond] begin ... end

Skip this test if cond is true or always skip if cond ommited

###@casename "test case name"

Names the test case. Will be output when status is displayed

###@testname "test name"

Names the test. Will be displayed in message if test fails. If ommitedd name will be Test n where n=1 for first test.

###@setUp function

Set a function to be called before each test starts

###@tearDown function

Set a function to be called after each test finishes

###@setUpCase function

Set a function to be called before testcase starts

###@tearDownCase function

Set a function to be called after testcase finishes

###@assertEqual(a,b)

a == b

###@assertNotEqual(a,b)

a != b

###@assertLess(a,b)

a < b

###@assertLessEqual(a,b)

a <= b

###@assertGreater(a,b)

a > b

###@assertGreaterEqual(a,b)

a >= b

###@assertIs(a,b)

a === b

###@assertIsNot(a,b)

a !== b

###@assertIn(a,collection)

a in collection

###@assertNotIn(a, collection)

! (a in collection)

###@assertItemsEqual(col1, col2)

sort(col1) == sort(col2)

###@assertIsA(obj, type) ###@assertIsNotA(obj, type)

###@assertMatches(regex, string)

###@assertNotMatches(regex, string)

###@assertTrue(bool)

###@assertFalse(bool)

###@testFailed(msg)

Fail test and display msg

###@expectFailures(n)

Declare that n assertion failures expected at this point in test and should be ignored

###@expectErrors

Declare that n errors are expected at this point in test and should be ignored Errors are unexpected exceptions raised during a test

###@assertThrows block|expr|function

Declare that some code is expected to throw an exception

###@assertThrows [ex1,ex2,...] block|expr|function

Declare that some code is expected to throw an exception of type ex1 or ex2, ...

###@testreport

Output a summary of number of tests run, passed, failed, errored, skipped

jltest's People

Watchers

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