Skip to content

❄️ A simple testing framework for lua with no dependencies

License

Notifications You must be signed in to change notification settings

weswigham/least

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

least

A simple testing framework for lua with the least amount of bloat and dependencies possible.

####Using least Make sure least.lua is in your package.path, then simply

local describe = require("least")

And start testing!

####Example

local describe = require("least")

describe("least lets you organize your tests by suite",function(_ENV)
    describe("least supports sub-suites and sub-suites with sub-suites, and so on",function()
        it("has basic assertions",function()
            assert(true)
        end)
        
        it("supports truthy/falsey/nil checks",function()
            assert.truthy(true)
            assert.falsey(false)
            assert.falsey(nil)
            assert.isNil(nil)
        end)
        
        it.should.fail("when truthy is given a false value",function()
            assert.truthy(false)
        end)
    end)
end)

You might notice that I import the module as the describe function; this is because the module conviently maps its call attribute to the least.describe function.

Additionally, a fake environment is created when calling your testing functions, giving them access to all of the functions below without the least namespace.

You may notice the _ENV argument to the topmost function; this is only required to create the fake environment in lua 5.2. Otherwise, it may be omitted.

####Output By default, least prints out any failed tests, asserts, or suites, and a quick dot-summary at the end of each suite. You can turn off the printing of dots on successful tests by setting least.quiet to true.

####Functions ######least.describe

least.describe ( description, func )
least.suite    ( description, func )

In least, 'suite' and 'describe' are synonymous.

######least.it

least.test ( description, func )
least.it   ( description, func )
least.test.should.pass ( description, func )
least.it.should.pass   ( description, func )

As are 'test' and 'it'. You can use whichever fits your preference.

######least.it.should.fail

least.test.should.fail ( description, func )
least.it.should.fail   ( description, func )

######least.assert

least.assert ( statement )
least.assert.truthy ( statement )

######least.assert.falsy

least.assert.falsy ( statement )

######least.assert.isNil

least.assert.isNil ( statement )

About

❄️ A simple testing framework for lua with no dependencies

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages