★ wanayoo — archive 1999 https://github.com/utPLSQL/utPLSQL/issues/491Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow beforetest/aftertest procedures to accept parameters #491

Open
kyleholgate opened this issue Oct 10, 2017 · 3 comments
Open

Allow beforetest/aftertest procedures to accept parameters #491

kyleholgate opened this issue Oct 10, 2017 · 3 comments

Comments

@kyleholgate
Copy link

@kyleholgate kyleholgate commented 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.

@jgebal
Copy link
Member

@jgebal jgebal commented Oct 12, 2017

@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.

@jgebal
Copy link
Member

@jgebal jgebal commented Oct 14, 2017

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;
/
@jgebal
Copy link
Member

@jgebal jgebal commented Oct 17, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.