Skip to main content

Invalid utPLSQL context structure

ZPA rule for PL/SQL and Oracle SQL · InvalidUtPlSqlContextStructure

utPLSQL groups tests in contexts opened by %context and closed by %endcontext, optionally named by %name. When the structure is wrong, utPLSQL ignores the annotation or gives the context an automatic name, and the suite is not built as written, though the package compiles.

This rule reports a %context without its %endcontext, a %name outside a context, an invalid name, and a name already used by a sibling context. utPLSQL uses the first %name before a nested context and ignores later ones; an empty %name gives an automatic name.

Examples​

Noncompliant Code Example
create package crate_test as
--%suite
--%context(Open crates)
--%name(crates)
--%endcontext
--%context(Closed crates)
--%name(crates) -- Noncompliant
--%endcontext
end;
Compliant Solution
create package crate_test as
--%suite
--%context(Open crates)
--%name(open_crates)
--%endcontext
--%context(Closed crates)
--%name(closed_crates)
--%endcontext
end;