DAGDA SEARCH | Back to results | Support the Project

Allow beforetest/aftertest procedures to accept parameters · utPLSQL/utPLSQL · Discussion #1328 · GitHub

Source: https://github.com/utPLSQL/utPLSQL/discussions/1328

Repository navigation

Allow beforetest/aftertest procedures to accept parameters #1328

Unanswered kyleholgate asked this question in Feature Requests Allow beforetest/aftertest procedures to accept parameters #1328 @kyleholgate kyleholgate Oct 10, 2017 · 4 comments Return to top Discussion options

{{title}}

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

{{editor}}'s edit

{{actor}} deleted this content .

{{editor}}'s edit

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kyleholgate Oct 10, 2017

You can call procedures with beforetest or aftertest annotation, but it doesn't seem possible to pass any parameters through them. Is it possible to add this capability?

For example -

--% beforetest(build_user(123))
--% beforetest(build_user('missing_name'))

It would allow much greater reusability of setup procedures.

You must be logged in to vote All reactions

Replies: 4 comments

Comment options

{{title}}

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jgebal Oct 12, 2017 Maintainer

@Hkyle
That is a nice idea. It is related to #151
It not trivial to implement, if we want to get it done right.
Definitely worth doing.

You must be logged in to vote All reactions 0 replies Comment options

{{title}}

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jgebal Oct 14, 2017 Maintainer

I am having a second thought now.
To achieve this, you can simply call the setup inside a test, if the setup is test-specific.
so instead of:

create or replace package my_test is
  --%suite

  procedure build_user(a_param varchar2);

  --%test
  --%beforetest( build_user(123) )
  procedure do_the_test;
end;
/

create or replace package body my_test is
  procedure build_user(a_param varchar2) is
  begin
    --do some stuff here
    null;
  end;

  procedure do_the_test is
  begin
    --Assert
    ut.expect(get_user()).to_equal('123');
  end;
end;
/

You could have:

create or replace package my_test is
  --%suite

  --%test
  procedure do_the_test;
end;
/

create or replace package body my_test is
  procedure build_user(a_param varchar2) is
  begin
    --do some stuff here
    null;
  end;

  procedure do_the_test is
  begin
    --Arrange
    build_user(123);
    --Assert
    ut.expect(get_user()).to_equal('123');
  end;

end;
/
You must be logged in to vote All reactions 0 replies Comment options

{{title}}

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

{{editor}}'s edit

{{actor}} deleted this content .

{{editor}}'s edit

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jgebal Oct 17, 2017 Maintainer

@Hkyle
The main benefit of having beforetest/aftertest invoked from the framework than from within test procedure is that it will be executed outside of the test and that it will get executed even if the test throws an exception.
Though adding parameters procedures in annotations is something I have in mind it requires significant amount of work. We will probably get there at some point, just not now.

You must be logged in to vote All reactions 0 replies Comment options

{{title}}

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

{{editor}}'s edit

{{actor}} deleted this content .

{{editor}}'s edit

Something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

t3mp0rary Aug 10, 2023

Since at least in version 3.1.13 it is possible to pass parameters to procedures called in before... and after.. annotations, the problem described by @kyleholgate is solved, isn't it?

But I have a follow-up question:
Currently it is only possible to pass a single parameter because the , is interpreted as a splitter between methods, not between parameters.

--%beforetest(do_something('value1', 'value2')) will result in Call params for beforetest are not valid: USER.SUITE.DO_SOMETHING('VALUE1

Also note the capitalization of the passed value. This could sometimes lead to confusion 😅

Is there any way to pass more than one value?

You must be logged in to vote All reactions 0 replies Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Category 💡 Feature Requests Labels enhancement idea 3 participants @kyleholgate @jgebal @t3mp0rary Converted from issue

This discussion was converted from issue #491 on May 09, 2026 17:04.

Heading Bold Italic Quote Code Link
Numbered list Unordered list Task list
Attach files Mention Reference Menu

Select a reply

Loading

Uh oh!

There was an error while loading. Please reload this page.

Create a new saved reply reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji