Skip to content

Commit 4f7baa6

Browse files
committed
Minor enhancements in readme and doc
1 parent 7c34981 commit 4f7baa6

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

README.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@ Define tests.
7474
g.test_example_m = function() ... end
7575
7676
-- Define parametrized groups
77-
local pg = t.group('pgroup', t.helpers.matrix({param_1 = {1, 2}, param_2 = {3, 4}}))
78-
pg.test_example_1 = function(cg) ... end
79-
-- type(cg.params.param_1) == 'number'
80-
pg.test_example_n = function(cg) ... end
77+
local pg = t.group('pgroup', {{engine = 'memtx'}, {engine = 'vinyl'}})
78+
pg.test_example_3 = function(cg)
79+
-- Use cg.params here
80+
box.schema.space.create('test', {
81+
engine = cg.params.engine,
82+
})
83+
end
8184
8285
-- Hooks can be specified for one parameter
83-
pg.before_all(function() ... end)
84-
pg.before_each({param_1 = 1}, function() ... end)
85-
pg.after_each({param_2 = 3}, function() ... end)
86-
pg.after_test('test_example_1', {param_1 = 2, param_2 = 4}, function() ... end)
86+
pg.before_all({engine = 'memtx'}, function() ... end)
87+
pg.before_each({engine = 'memtx'}, function() ... end)
88+
pg.before_test('test_example_3', {engine = 'vinyl'}, function() ... end)
8789
8890
8991
Run them.
@@ -258,17 +260,21 @@ Test group can be parametrized.
258260
259261
g.test_params = function(cg)
260262
...
261-
local param_a_val = cg.params.a
262-
local param_b_val = cg.params.b
263+
log.info('a = %s', cg.params.a)
264+
log.info('b = %s', cg.params.b)
263265
...
264266
end
265267
266-
Group can be parametrized with a matrix of parameters using helper.
268+
Group can be parametrized with a matrix of parameters using `luatest.helpers`:
267269

268270
.. code-block:: Lua
269271
270272
local g = t.group('pgroup', t.helpers.matrix({a = {1, 2}, b = {3, 4}}))
271-
273+
-- Will run:
274+
-- * a = 1, b = 3
275+
-- * a = 1, b = 4
276+
-- * a = 2, b = 3
277+
-- * a = 2, b = 4
272278
273279
Each test will be performed for every params combination. Hooks will work as usual
274280
unless there are specified params. The order of execution in the hook group is

luatest/helpers.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ end
8080
--
8181
-- helpers.matrix({a = {1, 2}, b = {3, 4}})
8282
--
83-
-- {{a = 1, b = 3},
84-
-- {a = 2, b = 3},
85-
-- {a = 1, b = 4},
86-
-- {a = 2, b = 4}}
83+
-- {
84+
-- {a = 1, b = 3},
85+
-- {a = 2, b = 3},
86+
-- {a = 1, b = 4},
87+
-- {a = 2, b = 4},
88+
-- }
8789
--
8890
-- @tab params
8991
function helpers.matrix(params)

luatest/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ luatest.groups = {}
3535
--- Create group of tests.
3636
--
3737
-- @string[opt] name
38+
-- @table[opt] params
3839
-- @return Group object
3940
-- @see luatest.group
4041
function luatest.group(name, params)

0 commit comments

Comments
 (0)