Skip to content

Conversation

@mandesero
Copy link
Contributor

@mandesero mandesero commented Nov 26, 2025

Before this patch, luatest accepted two ways to register hooks:

  • call-style API: group.before_all(function() ... end)
  • direct assignment: group.before_all = function() ... end

The second form does not work correctly with parametrized tests. We already encountered this on the Tarantool side and had to rewrite such assignments in tarantool/tarantool#8187.

With this change, luatest enforces a single, consistent way to register hooks:

  • hooks must be registered via calls like
    • before_each(function() ... end)
    • after_each(function() ... end)
    • before_all(function() ... end)
    • after_all(function() ... end)
    • before_suite(function() ... end)
    • after_suite(function() ... end)
    • before_test('name', function() ... end)
    • after_test('name', function() ... end)
  • assigning to these names (e.g. group.before_each = fn) now raises an error with a clear message.

Legacy group.setup / group.teardown are no longer supported; use before_each/after_each instead.

Closes #390

@mandesero mandesero requested a review from locker November 28, 2025 07:58
@locker locker self-assigned this Nov 28, 2025
@locker locker assigned mandesero and unassigned locker Dec 1, 2025
@mandesero mandesero requested a review from locker December 1, 2025 14:34
@mandesero mandesero assigned locker and unassigned mandesero Dec 1, 2025
@locker locker assigned mandesero and unassigned locker Dec 1, 2025
Before this patch luatest accepted two ways to register hooks:

* call-style API: `group.before_all(function() ... end)`
* direct assignment: `group.before_all = function() ... end`

The second form does not work correctly with parametrized tests.
We already encountered this on the tarantool side and had to
rewrite such assignments in tarantool/tarantool#8187.

With this change luatest enforces a single, consistent way to
register hooks:

* hooks must be registered via calls like
  `before_each(function() ... end)`,
  `after_each(function() ... end)`,
  `before_all(function() ... end)`,
  `after_all(function() ... end)`,
  `before_suite(function() ... end)`,
  `after_suite(function() ... end)`,
  `before_test('name', function() ... end)` and
  `after_test('name', function() ... end)`;
* assigning to these names (e.g. `group.before_each = fn`) now
  raises an error with a clear message.

Legacy `group.setup` / `group.teardown` remain supported and are
not affected by this change.

Legacy `group.setup` / `group.teardown` are no longer supported;
use `before_each`/`after_each` instead.

Closes tarantool#390
@mandesero mandesero requested a review from locker December 1, 2025 15:44
@mandesero mandesero assigned locker and unassigned mandesero Dec 1, 2025
@locker locker merged commit 2dcbed7 into tarantool:master Dec 1, 2025
8 checks passed
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.

Parameterization for group breaks tests, before_all is not executed

2 participants