1.5.6 • Published 9 months ago

gs-lua-unit v1.5.6

Weekly downloads
1
License
MIT
Repository
github
Last release
9 months ago

Create lua unit tests

-- test.lua

dofile('./node_modules/gs-lua-unit/lua-src/common.lua')
-- lua setup stuff

runTests(generateTests({
  foo = {{
    tag = 'Testing file foo',
    doTest = function(fooModule)
      return fooModule.doStuff()
    end,
    expect = function(resultFromDoTest, expector, fooModule)
      -- expector has all sorts of goodies
      expector:expectStrictEqual(resultFromDoTest.result1, 'fooResult1')
      expector:expectTruthy(resultFromDoTest.result2)
      expector:expectFalsy(resultFromDoTest.result3)
      expector:expectDeepEqual(resultFromDoTest.resultObj, {foo = 1, bar = 2})
      return true -- must return true here
      -- its not required to use the expector, you can do stuff like
      -- return result and result[1].foo == 'bar'
      -- but the expector provides detailed assertion failures
    end
  }, {
    -- more tests
  }},

  bar = {{
    -- more tests
  }}
})

And then

lua /path/to/test.lua

What are foo and bar

foo = ... and bar = ... point to files that exist in a directory with lua scripts named foo and bar.

By default, gs-lua-unit looks in the directory "target/test_scripts/", but this directory can also be specified with the third argument to runTests.

What about Redis?

A redis.call method is provided for you, and works on an active redis.

gs-lua-unit looks for redis in a "redis.yaml" of the current working directory.

# redis.yaml
mockRedis:
 host: localhost
 port: 6379

Redis location can also be passed as the second argument to runTests above

runTests(generateTests({ ... }), redisConfig)
1.5.6

9 months ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago