Skip to content

Conversation

Steap2448
Copy link
Contributor

@Steap2448 Steap2448 commented Aug 20, 2021

Implement group parametrization

  -- Define parametrized groups
  local pg = t.group('pgroup', t.helpers.matrix({a = {1, 2}, b = {3, 4}}))
  pg.test_example_1 = function(cg) ... end
  -- type(cg.params.a) == 'number'
  pg.test_example_n = function(cg) ... end

  -- Hooks can be specified for one parameter
  pg.before_all(function() ... end)
  pg.before_each({a = 1}, function() ... end)
  pg.after_each({b = 3}, function() ... end)
  pg.after_test('test_example_1', {a = 2, b = 4}, function() ... end)

Test with specified params can be started from command line

luatest pgroup.a:2.b:3.test_example_1

I didn't forget about

  • Tests
  • Changelog
  • Documentation

Close #116

@Steap2448 Steap2448 force-pushed the 116-parametrization branch 2 times, most recently from 86a1646 to ac26e0b Compare August 20, 2021 15:22
Copy link
Contributor

@rosik rosik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about command-line arguments parsing? We discussed it orally. Are you going to implement it in a different PR?

We also discussed restricting types of parameters values. Because group name formatting a.b_1.c_3 doesn't look pretty, and in the case of a table it would be even worse. You can take a look at pytest which luatest was inspired by.

README.rst Outdated
@@ -73,6 +73,18 @@ Define tests.
g.test_example_2 = function() ... end
g.test_example_m = function() ... end

-- Define parametrized groups
local pg = t.group('pgroup', {param_1 = {1, 2}, param_2 = {3, 4}})
-- type(cg.params.param_1) == 'number'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- type(cg.params.param_1) == 'number'
-- type(pg.params.param_1) == 'number'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's ok

Comment on lines 22 to 25
t.assert_error_msg_contains(
'Parameter values should be table, got number',
function() t.group('parametrized', {['name'] = 1}) end
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about key-value tables instead of an array? Is it ever legal?

t.group('parametrized', {param = {key = 'value'}})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Illegal and banned

@Steap2448 Steap2448 force-pushed the 116-parametrization branch 4 times, most recently from 6186e40 to edd4eb3 Compare September 9, 2021 10:38
@ligurio
Copy link
Member

ligurio commented Sep 10, 2021

In PR's description checkbox "Documentation" is checked. But commit doesn't contain any feature description. Could you add a couple of words to the README?

@Steap2448
Copy link
Contributor Author

In PR's description checkbox "Documentation" is checked. But commit doesn't contain any feature description. Could you add a couple of words to the README?

I have added a new section about parametrization to README. There were some examples already, but it wasn't comprehensive

@Steap2448 Steap2448 requested a review from rosik September 10, 2021 12:42
@Steap2448 Steap2448 force-pushed the 116-parametrization branch 2 times, most recently from fa87476 to 007750a Compare September 10, 2021 12:45
@Steap2448 Steap2448 force-pushed the 116-parametrization branch 3 times, most recently from 0d58bc5 to 18891e3 Compare September 13, 2021 16:30
@Steap2448 Steap2448 requested a review from rosik September 13, 2021 16:31
@Steap2448 Steap2448 merged commit d98dce5 into master Sep 15, 2021
@Steap2448 Steap2448 deleted the 116-parametrization branch September 15, 2021 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement test parametrization
3 participants