-
Notifications
You must be signed in to change notification settings - Fork 186
Stop/skip test execution #990
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
Comments
There is an annotion |
Cool idea @lwasylow. But this does not work. Here's an example:
Output is
|
The best alternative is |
Ahh annotation parser reading from dba_source and conditonal compilation breaking pattern. |
It's not about annotation parser. This works as you would like it to: create or replace package test_xyz is
--%suite
--%suitepath(alltests)
$if dbms_db_version.version > 10 $then
--%disabled
--%test
procedure t1;
$else
--%test
procedure t1;
$end
--%test
--%disabled
procedure t2;
end test_xyz;
/
set serveroutput on size unlimited
execute ut.run('test_xyz'); Test procedure t1 is disabled on some versions of Oracle. Reason why original example didn't work is that after running through pre-processor, the package spec looks like this: create or replace package test_xyz is
--%suite
--%suitepath(alltests)
--%test
procedure t1;
--%test
--%disabled
procedure t2;
end test_xyz; On Oracle >10 it looks like this: create or replace package test_xyz is
--%suite
--%suitepath(alltests)
--%test
--%disabled
procedure t1;
--%test
--%disabled
procedure t2;
end test_xyz; So the test and disabled annotations are "floating" and so:
|
@PetrShchukin - does that answer your question? |
@jgebal Thanks, that works fine when we need skip one-two tests, but if our test contains ~10 tests and we need to skip five, it becomes clumsy. I tried to use disable annotation to context but it seems it doesn't work. |
Sorry, I don't see what's wrong here, in the first case there is no disable annotation, in the second disable annotation is below test annotation. Why should a suite be disabled? Do lines between annotation play a role? |
What do you mean it doesn't work? Can you give an example? Why do you need to run part of tests conditionally? If you provide a bit more context maybe we can suggest a better solution. You said:
What kind of system setting do you have in mind? The better you describe the problem, the more likely you are to get a valuable and helpful answer. |
Yes. |
Documentation is pretty comprehensive, still studying) |
Conditional compilation , disabling tests isn't probably what you are looking for. But yes, you can do this: create or replace package tst is
--%suite
--%context(first)
--%disabled
--%test
procedure t1;
--%endcontext
--%context(second)
--%test
procedure t2;
--%endcontext
end;
/
create or replace package body tst is
procedure t1 is begin ut.expect(1).to_equal(2); end;
procedure t2 is begin ut.expect(1).to_equal(2); end;
end;
/
exec ut.run('tst'); |
Thanks! |
You can also use tags, as mentioned by @PhilippSalvisberg create or replace package tst is
--%suite
--%context(first)
--%tags(integration)
--%test
procedure t1;
--%endcontext
--%context(second)
--%tags(microservice)
--%test
procedure t2;
--%endcontext
end;
/
create or replace package body tst is
procedure t1 is begin ut.expect(1).to_equal(2); end;
procedure t2 is begin ut.expect(1).to_equal(2); end;
end;
/
exec ut.run('tst', a_tags=>'microservice');
exec ut.run('tst', a_tags=>'microservice,integration');
exec ut.run('tst', a_tags=>'integration');
exec ut.run('tst'); I would personally separate integration tests from standalone micro-service tests |
The isolation could be done by:
suites and tags seems like most flexible way. |
Yeah, probably it would be better to use separation on a higher level, thanks! |
Another option would be to have separate test suites (packages) for different types of tests. So it seems there are few ways to address your question. |
Hi, is there any way to stop or skip tests? I want to skip some tests depends on system settings or stop a whole test in initial (beforeall) procedure. Now I have to create "if" statement in each procedure in my test file. Is there another fancy way to do it?
The text was updated successfully, but these errors were encountered: