Skip to content

smangano/JLTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Julia unit test framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages