diff --git a/.gitattributes b/.gitattributes index 02d2d5e4e..2cda5ad55 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,18 @@ +.github export-ignore +.idea export-ignore +development export-ignore +test export-ignore .gitattributes export-ignore .gitignore export-ignore .gitmodules export-ignore -.travis.yml export-ignore mkdocs.yml export-ignore -.travis export-ignore +BUILD_NO export-ignore +mkdocs_offline.yml export-ignore sonar-project.properties export-ignore -tests export-ignore -development export-ignore -node_modules export-ignore -^docs/* linguist-documentation +^docs/** linguist-documentation +*.pkb linguist-language=PLSQL +*.pks linguist-language=PLSQL +*.sql linguist-language=PLSQL +*.tpb linguist-language=PLSQL +*.tps linguist-language=PLSQL +*.sh text eol=lf diff --git a/.github/DISCUSSION_TEMPLATE/bug-triage.yml b/.github/DISCUSSION_TEMPLATE/bug-triage.yml new file mode 100644 index 000000000..7a5da8d73 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/bug-triage.yml @@ -0,0 +1,69 @@ +title: "[Bug?] " +labels: ["bug-triage"] +body: + - type: markdown + attributes: + value: | + Use this category if you think you have found a bug in the utPLSQL framework and want to discuss it before a formal issue is opened. + + Once a maintainer confirms the bug, they will open an issue and link it back here. You do not need to open an issue yourself. + + If you are certain it is a bug and can provide a reliable reproduction, you may open an issue directly instead. + + - type: input + id: utplsql-version + attributes: + label: utPLSQL version + placeholder: "e.g. 3.1.13" + validations: + required: true + + - type: input + id: oracle-version + attributes: + label: Oracle Database version + placeholder: "e.g. 19c, 21c" + validations: + required: true + + - type: input + id: os + attributes: + label: Operating system + placeholder: "e.g. Linux, Windows Server 2019" + validations: + required: false + + - type: textarea + id: description + attributes: + label: What did you observe? + description: Describe the unexpected behaviour. Include any error messages or stack traces. + render: text + validations: + required: true + + - type: textarea + id: expected + attributes: + label: What did you expect? + description: Describe what you expected to happen instead. + validations: + required: true + + - type: textarea + id: reproduction + attributes: + label: Reproduction case + description: Paste the minimal PL/SQL needed to reproduce the problem. The simpler, the better. + render: sql + validations: + required: false + + - type: textarea + id: investigation + attributes: + label: What have you investigated so far? + description: Any findings from your own debugging that might help narrow this down. + validations: + required: false diff --git a/.github/DISCUSSION_TEMPLATE/contributing.yml b/.github/DISCUSSION_TEMPLATE/contributing.yml new file mode 100644 index 000000000..31a213cbb --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/contributing.yml @@ -0,0 +1,43 @@ +title: "" +labels: ["contributing"] +body: + - type: markdown + attributes: + value: | + Use this category if you are working on or considering a contribution to the utPLSQL framework codebase and have questions about the internals, development setup, testing approach, or contribution process. + + Before posting, it is worth checking: + - [CONTRIBUTING.md](https://github.com/utPLSQL/utPLSQL/blob/develop/CONTRIBUTING.md) + - [Development setup guide](https://github.com/utPLSQL/utPLSQL/blob/develop/development/README.md) + + - type: dropdown + id: topic + attributes: + label: Topic + options: + - Development environment setup + - Understanding the codebase + - Test writing and running locally + - CI / build pipeline + - Pull request process + - Architectural question + - Other + validations: + required: true + + - type: textarea + id: question + attributes: + label: Question or topic + description: Describe what you are working on and what you need help with. + validations: + required: true + + - type: textarea + id: context + attributes: + label: Relevant code or context + description: Paste any relevant code, configuration, or error output here. + render: sql + validations: + required: false diff --git a/.github/DISCUSSION_TEMPLATE/feature-requests.yml b/.github/DISCUSSION_TEMPLATE/feature-requests.yml new file mode 100644 index 000000000..b07a043b5 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/feature-requests.yml @@ -0,0 +1,61 @@ +title: "[Feature] " +labels: ["feature-request"] +body: + - type: markdown + attributes: + value: | + Use this category for feature ideas specific to the utPLSQL framework: new matchers, annotation behaviour, reporter output, suite control, coverage, or installation. + + > For ideas that affect multiple components or the project direction overall, use [org-level Feature Requests](https://github.com/orgs/utPLSQL/discussions/categories/feature-requests) instead. + + A maintainer will mark this discussion as answered once the proposal is accepted or declined. + If accepted, a maintainer will convert it to an issue for implementation tracking -- you do not need to open an issue yourself. + + - type: textarea + id: problem + attributes: + label: Problem or motivation + description: What problem does this feature solve? What is the current limitation or pain point? + validations: + required: true + + - type: textarea + id: proposal + attributes: + label: Proposed solution + description: Describe the feature you have in mind. Include examples of how it would be used, ideally with PL/SQL annotation or API examples. + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternatives or workarounds considered + description: Have you found any alternative approaches or partial workarounds? + validations: + required: false + + - type: dropdown + id: area + attributes: + label: Framework area + options: + - Annotations + - Matchers + - Reporters + - Suite / test control + - Coverage + - Transaction control + - Installation / upgrade + - Performance + - Other + validations: + required: true + + - type: input + id: utplsql-version + attributes: + label: utPLSQL version you are using + placeholder: "e.g. 3.1.13" + validations: + required: false diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml new file mode 100644 index 000000000..30b372760 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -0,0 +1,61 @@ +title: "[Q&A] " +labels: ["question"] +body: + - type: markdown + attributes: + value: | + ## Question & Answer + Ask anything about **using** utPLSQL — installation, writing tests, CI integration, + reporters, annotations, code coverage, etc. + + **Tips for a fast answer:** + - Include your utPLSQL version and Oracle version. + - Paste a minimal reproducer (test package + expected vs actual output). + - Check the [documentation](https://utplsql.github.io/utPLSQL/) and + [closed Q&A discussions](../../discussions/categories/q-a?discussions_q=is%3Aclosed) first. + + > If this turns out to be a **bug**, a maintainer will convert this discussion into an Issue. + + - type: input + id: utplsql-version + attributes: + label: utPLSQL version + placeholder: "e.g. 3.1.13" + validations: + required: true + + - type: input + id: oracle-version + attributes: + label: Oracle Database version + placeholder: "e.g. 19c, 21c" + validations: + required: true + + - type: textarea + id: question + attributes: + label: Question + description: Describe what you are trying to do and what you have already tried. + validations: + required: true + + - type: textarea + id: reproducer + attributes: + label: Minimal reproducer + description: | + Paste a minimal test package and/or the relevant ut_runner call. + Include the full error message or unexpected output if applicable. + render: sql + validations: + required: false + + - type: textarea + id: output + attributes: + label: Actual output or error + description: Paste any error messages or unexpected output here. + render: text + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b3e52a19a..77cbe1c25 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -13,20 +13,21 @@ A clear and concise description of what the bug is. **Provide version info** Information about utPLSQL and Database version, ```sql -set serveroutput on -declare - l_version varchar2(255); - l_compatibility varchar2(255); -begin - dbms_utility.db_version( l_version, l_compatibility ); - dbms_output.put_line( l_version ); - dbms_output.put_line( l_compatibility ); -end; -/ -select substr(ut.version(),1,60) as ut_version from dual; -select * from v$version; +with + function version_compatibility return varchar2 as + l_ver varchar2(100); + l_comp varchar2(100); + begin + dbms_utility.db_version(l_ver, l_comp); + return l_comp; + end; +select product, version, version_full, version_compatibility, + sys_context('userenv', 'current_edition_name') active_edition, + substr(dbms_utility.port_string,1,60) as cpu_type_and_os + from product_component_version; + select * from nls_session_parameters; -select substr(dbms_utility.port_string,1,60) as port_string from dual; + ``` **Information about client software** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index c54bff550..f0335781e 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -23,4 +23,4 @@ Add any other context or screenshots about the feature request here. > Please do not create issues for generic SQL or PL/SQL questions. There are other forums and communities to help you with those. See [ASKTom](https://asktom.oracle.com) for example. **Want to discuss** -If you want to discuss your issue, join [our SLACK chat](http://utplsql-slack-invite.herokuapp.com/). +If you want to discuss a problem, please go to [utPLSQL discussions](https://github.com/utPLSQL/utPLSQL/discussions) diff --git a/.github/scripts/create_test_grants.sh b/.github/scripts/create_test_grants.sh new file mode 100755 index 000000000..d92c02d99 --- /dev/null +++ b/.github/scripts/create_test_grants.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -ev + +# Grants on $UT3_DEVELOP_SCHEMA needed for testing. Must be re-applied whenever $UT3_DEVELOP_SCHEMA is reinstalled. +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +whenever sqlerror exit failure rollback + +-------------------------------------------------------------------------------- +PROMPT Adding back create-trigger privilege to $UT3_DEVELOP_SCHEMA for testing +grant administer database trigger to $UT3_DEVELOP_SCHEMA; + +-------------------------------------------------------------------------------- +PROMPT Granting $UT3_DEVELOP_SCHEMA code to UT3_TESTER + +begin + for i in ( + select object_name from all_objects t + where t.object_type in ('PACKAGE','TYPE') + and owner = '$UT3_DEVELOP_SCHEMA' + and generated = 'N' + and object_name not like 'SYS%') + loop + execute immediate 'grant execute on $UT3_DEVELOP_SCHEMA."'||i.object_name||'" to UT3_TESTER'; + end loop; +end; +/ + +PROMPT Granting $UT3_DEVELOP_SCHEMA tables to UT3_TESTER + +begin + for i in ( select table_name from all_tables t where owner = '$UT3_DEVELOP_SCHEMA' and nested = 'NO' and iot_name is null) + loop + execute immediate 'grant select on $UT3_DEVELOP_SCHEMA.'||i.table_name||' to UT3_TESTER'; + end loop; +end; +/ +exit +SQL diff --git a/.github/scripts/create_test_users.sh b/.github/scripts/create_test_users.sh new file mode 100755 index 000000000..41051e33d --- /dev/null +++ b/.github/scripts/create_test_users.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +set -ev +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd ${SCRIPT_DIR}/../../source + +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +whenever sqlerror exit failure rollback + +-------------------------------------------------------------------------------- +PROMPT Creating UT3_TESTER - Power-user for testing internal framework code + +create user UT3_TESTER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; +grant create session, create procedure, create type, create table to UT3_TESTER; + +# Editioning is enable on test users to validate that utPLSQL works well with editioned schema +alter user UT3_TESTER enable editions; + +grant execute on dbms_lock to UT3_TESTER; + + +-------------------------------------------------------------------------------- +PROMPT Creating UT3_USER - minimal privileges user for API testing + +create user UT3_USER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; +grant create session, create procedure, create type, create table to UT3_USER; + +# Editioning is enable on test users to validate that utPLSQL works well with editioned schema +alter user UT3_USER enable editions; + +PROMPT Grants for starting a debugging session from UT3_USER +grant debug connect session to UT3_USER; +grant debug any procedure to UT3_USER; +begin + dbms_network_acl_admin.append_host_ace ( + host =>'*', + ace => sys.xs\$ace_type( + privilege_list => sys.xs\$name_list('JDWP') , + principal_name => 'UT3_USER', + principal_type => sys.xs_acl.ptype_db + ) + ); +end; +/ + +-------------------------------------------------------------------------------- +PROMPT Creating UT3_TESTER_HELPER - provides functions to allow min grant test user setup tests. + +create user UT3_TESTER_HELPER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; +grant create session, create procedure, create type, create table to UT3_TESTER_HELPER; + +PROMPT Grants for testing distributed transactions +grant create public database link to UT3_TESTER_HELPER; +grant drop public database link to UT3_TESTER_HELPER; + +PROMPT Grants for testing coverage outside of main $UT3_DEVELOP_SCHEMA schema. +grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, + select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table, + select any dictionary, create any synonym, drop any synonym, + grant any object privilege, grant any privilege, create public synonym, drop public synonym, create any trigger, drop any trigger + to UT3_TESTER_HELPER; + +grant create job to UT3_TESTER_HELPER; + +PROMPT Additional grants for disabling DDL trigger and testing parser without trigger enabled/present + +grant alter any trigger to UT3_TESTER_HELPER; +grant administer database trigger to UT3_TESTER_HELPER; +grant execute on dbms_lock to UT3_TESTER_HELPER; + +create user ut3_cache_test_owner identified by ut3; +grant create session, create procedure to ut3_cache_test_owner; + +create user ut3_no_extra_priv_user identified by ut3; +grant create session, create procedure to ut3_no_extra_priv_user; + +create user ut3_select_catalog_user identified by ut3; +grant create session, create procedure, select_catalog_role to ut3_select_catalog_user; + +create user ut3_select_any_table_user identified by ut3; +grant create session, create procedure, select any table to ut3_select_any_table_user; + +create user ut3_execute_any_proc_user identified by ut3; +grant create session, create procedure, execute any procedure to ut3_execute_any_proc_user; +exit +SQL + +"${SCRIPT_DIR}/create_test_grants.sh" diff --git a/.github/scripts/detect_changes_since_last_publish.sh b/.github/scripts/detect_changes_since_last_publish.sh new file mode 100755 index 000000000..818ff89dc --- /dev/null +++ b/.github/scripts/detect_changes_since_last_publish.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Detects what has changed since the last publish, so that builds of unchanged code +# (e.g. scheduled builds) do not produce new commits on develop and gh-pages branches. +# +# Outputs (written to $GITHUB_OUTPUT): +# project_changed - true when there are new commits since the last project version update commit +# docs_changed - true when documentation sources changed since the last deployment of documentation to gh-pages + +VERSION_COMMIT_MESSAGE='Updated project version after build [skip ci]' +DOCS_PATHS="docs mkdocs.yml" +DOCS_VERSION="develop" + +if [[ "$(git log -1 --format=%s HEAD)" == "${VERSION_COMMIT_MESSAGE}" ]]; then + echo "No new commits since last project version update." + project_changed=false +else + echo "New commits found since last project version update." + project_changed=true +fi + +# mike commits to gh-pages with message: "Deployed to with MkDocs and mike " +git fetch --quiet origin gh-pages +last_deployed_sha=$(git log -1 --format=%s --grep="^Deployed [0-9a-f]* to ${DOCS_VERSION} with MkDocs" origin/gh-pages | sed -nE "s/^Deployed ([0-9a-f]+) to .*/\1/p") + +if [[ -z "${last_deployed_sha}" ]] || ! git cat-file -e "${last_deployed_sha}^{commit}" 2>/dev/null; then + echo "Commit of last '${DOCS_VERSION}' documentation deployment not found." + docs_changed=true +elif git diff --quiet "${last_deployed_sha}" HEAD -- ${DOCS_PATHS}; then + echo "No documentation changes since last '${DOCS_VERSION}' documentation deployment from commit ${last_deployed_sha}." + docs_changed=false +else + echo "Documentation changed since last '${DOCS_VERSION}' documentation deployment from commit ${last_deployed_sha}." + docs_changed=true +fi + +echo "project_changed=${project_changed}" >> $GITHUB_OUTPUT +echo "docs_changed=${docs_changed}" >> $GITHUB_OUTPUT diff --git a/.github/scripts/get_project_version.sh b/.github/scripts/get_project_version.sh new file mode 100755 index 000000000..54a30a562 --- /dev/null +++ b/.github/scripts/get_project_version.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +version=`cat VERSION` +#When on develop branch, add "-develop" to the version text +if [[ "${CI_ACTION_REF_NAME}" == "develop" ]]; then + version=`sed -E "s/(v?[0-9]+\.[0-9]+\.[0-9]+).*/\1-develop/" <<< "${version}"` +fi +echo ${version} diff --git a/.github/scripts/get_published_docs_version.sh b/.github/scripts/get_published_docs_version.sh new file mode 100755 index 000000000..f0a78dcbc --- /dev/null +++ b/.github/scripts/get_published_docs_version.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Returns the version shown on the badge of documentation, as originally published for a release. +# Used when rebuilding documentation of older releases, so that the rebuild does not alter version badges. +# Usage: .github/scripts/get_published_docs_version.sh +# +# Version is taken from the first deployment of the release documentation to gh-pages. +# If not found, it is derived from the release tag and BUILD_NO file, the same way as done by release process. +# Returns nothing if version cannot be determined. + +version=$1 +[[ -n "${version}" ]] || { echo "Release tag not provided" >&2; exit 1; } + +# mike commits to gh-pages with message: "Deployed to with MkDocs and mike " +first_deployment=$(git log origin/gh-pages --format=%H -F --grep=" to ${version} with MkDocs" | tail -1) +if [[ -n "${first_deployment}" ]]; then + docs_version=$(git show "${first_deployment}:${version}/index.html" 2>/dev/null | sed -nE 's/.*img\.shields\.io\/badge\/version-([^"]*)-blue\.svg.*/\1/p' | head -1) + # "-" is escaped as "--" in shields.io badge + docs_version=${docs_version//--/-} +fi + +if [[ -z "${docs_version}" ]]; then + build_no=$(git show "tags/${version}:BUILD_NO" 2>/dev/null | tr -d '[:space:]') + if [[ -n "${build_no}" ]]; then + docs_version=$(echo ${version} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${build_no}\4/") + fi +fi + +echo ${docs_version} diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh new file mode 100755 index 000000000..5f034951c --- /dev/null +++ b/.github/scripts/install.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -ev +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd ${SCRIPT_DIR}/../../source + +INSTALL_FILE="install_headless_with_trigger.sql" +if [[ ! -f "${INSTALL_FILE}" ]]; then + INSTALL_FILE="install_headless.sql" +fi + +#install core of utplsql +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +whenever sqlerror exit failure rollback +set feedback off +set verify off + +--alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6003,6009,6010,7206)'; +alter session set plsql_optimize_level=0; +@${INSTALL_FILE} $UT3_DEVELOP_SCHEMA $UT3_DEVELOP_SCHEMA_PASSWORD +SQL + +#Enable editioning on the UT3_DEVELOP schema +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +whenever sqlerror exit failure rollback +set feedback off +set verify off + +alter user $UT3_DEVELOP_SCHEMA enable editions; +exit +SQL diff --git a/.travis/install_utplsql_release.sh b/.github/scripts/install_utplsql_release.sh similarity index 75% rename from .travis/install_utplsql_release.sh rename to .github/scripts/install_utplsql_release.sh index 3e608b08f..b9e23d214 100755 --- a/.travis/install_utplsql_release.sh +++ b/.github/scripts/install_utplsql_release.sh @@ -1,8 +1,8 @@ #!/bin/bash set -ev - -cd $UTPLSQL_DIR/source +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd ${SCRIPT_DIR}/../../${UTPLSQL_DIR}/source "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <>index.md + echo "layout: default" >>index.md + echo "---" >>index.md + echo "" >>index.md + echo "# Documentation versions" >>index.md + echo "" >>index.md + echo "" >>index.md #- 7th line - placeholder for latest release doc + echo "" >>index.md #- 8th line - placeholder for develop branch doc + echo "" >>index.md + echo "## Released Version Doc History" >>index.md + echo "" >>index.md +fi +#If build running on a TAG - it's a new release - need to add it to documentation +if [ "${GITHUB_REF_TYPE}" == "tag" ]; then + sed -i '7s@.*@'" - [Latest ${CI_ACTION_REF_NAME} documentation](latest/) - Created $now"'@' index.md + #add entry to the top of version history (line end of file - ## Released Version Doc History + sed -i '12i'" - [${CI_ACTION_REF_NAME} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md +fi +#replace 4th line in log +sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md +#Add and Commit the changes back to pages repo. +git add . +git commit -m "Deploy to gh-pages branch: base commit ${SHA}" +# Now that we're all set up, we can push. +git push --quiet origin HEAD:${GITHUB_IO_BRANCH} + diff --git a/.github/scripts/run_examples.sh b/.github/scripts/run_examples.sh new file mode 100755 index 000000000..bfa4f7e1a --- /dev/null +++ b/.github/scripts/run_examples.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -ev +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd ${SCRIPT_DIR}/../../examples + +"$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR <> $GITHUB_ENV +echo "UTPLSQL_VERSION=${version}" >> $GITHUB_ENV +echo "UTPLSQL_BUILD_VERSION=${build_version}" >> $GITHUB_ENV +# Documentation of released versions includes build number +echo "UTPLSQL_DOCS_VERSION=${build_version}" >> $GITHUB_ENV diff --git a/.github/scripts/set_version_numbers_env.sh b/.github/scripts/set_version_numbers_env.sh new file mode 100755 index 000000000..8fc31279d --- /dev/null +++ b/.github/scripts/set_version_numbers_env.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +build_no=$( expr ${GITHUB_RUN_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} ) +version=$(.github/scripts/get_project_version.sh) + +echo "UTPLSQL_BUILD_NO=${build_no}" >> $GITHUB_ENV +echo "UTPLSQL_VERSION=${version}" >> $GITHUB_ENV +echo UTPLSQL_BUILD_VERSION=$(echo ${version} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${build_no}\4/") >> $GITHUB_ENV +# Documentation of development versions does not include build number, so that it only changes when version changes +echo "UTPLSQL_DOCS_VERSION=${version}" >> $GITHUB_ENV diff --git a/.github/scripts/uninstall_validate_utplsql.sh b/.github/scripts/uninstall_validate_utplsql.sh new file mode 100755 index 000000000..d0a2070a8 --- /dev/null +++ b/.github/scripts/uninstall_validate_utplsql.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -ev +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd ${SCRIPT_DIR}/../../source + +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL + set feedback off + set verify off + whenever sqlerror exit failure rollback + + @uninstall_all.sql $UT3_DEVELOP_SCHEMA +SQL +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL + set feedback off + set verify off + whenever sqlerror exit failure rollback + set serverout on + begin + for i in ( + select o.object_type||' '||o.owner||'.'||o.object_name as obj + from dba_objects o + where owner = '$UT3_DEVELOP_SCHEMA' + union all + select 'SYNONYM '||s.owner||'.'||s.synonym_name||' FOR '||s.table_owner||'.'||s.table_name as obj + from dba_synonyms s + where table_owner = '$UT3_DEVELOP_SCHEMA' + ) loop + dbms_output.put_line(i.obj); + end loop; + end; + / + declare + v_leftover_objects_count integer; + begin + select sum(cnt) + into v_leftover_objects_count + from ( + select count(1) cnt from dba_objects + where owner = '$UT3_DEVELOP_SCHEMA' + and object_name not like 'PLSQL_PROFILER%' and object_name not like 'DBMSPCC_%' + union all + select count(1) cnt from dba_synonyms + where table_owner = '$UT3_DEVELOP_SCHEMA' + and table_name not like 'PLSQL_PROFILER%' and table_name not like 'DBMSPCC_%' + ); + if v_leftover_objects_count > 0 then + raise_application_error(-20000, 'Not all objects were successfully uninstalled - leftover objects count='||v_leftover_objects_count); + end if; + end; + / + drop user $UT3_DEVELOP_SCHEMA; +SQL diff --git a/.github/scripts/update_changelog.sh b/.github/scripts/update_changelog.sh new file mode 100755 index 000000000..011c08819 --- /dev/null +++ b/.github/scripts/update_changelog.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Updates CHANGELOG.md by prepending a new section for the release. +# +# Required environment variables: +# RELEASE_TAG - e.g. v3.2.3 +# RELEASE_BODY - markdown release notes +# RELEASE_DATE - ISO-8601 date string (only the first 10 chars are used) +# TARGET_BRANCH - branch to push the updated changelog to + +set -euo pipefail + +python3 - <<'PYEOF' +import os + +tag = os.environ['RELEASE_TAG'] +body = os.environ['RELEASE_BODY'].strip() +date = os.environ['RELEASE_DATE'][:10] + +new_section = f"## [{tag}] - {date}\n\n{body}\n\n---\n\n" + +with open('CHANGELOG.md', 'r') as f: + content = f.read() + +marker = '\n---\n' +pos = content.index(marker) + len(marker) +updated = content[:pos] + '\n' + new_section + content[pos:] + +with open('CHANGELOG.md', 'w') as f: + f.write(updated) + +print(f"Added {tag} to CHANGELOG.md") +PYEOF + +git add CHANGELOG.md +git commit -m "Add release notes for ${RELEASE_TAG} to CHANGELOG.md [skip ci]" +git push origin HEAD:"${TARGET_BRANCH}" diff --git a/.github/scripts/update_docs_version.sh b/.github/scripts/update_docs_version.sh new file mode 100755 index 000000000..fa2e2c27a --- /dev/null +++ b/.github/scripts/update_docs_version.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Updates version badge in documentation files. +# Usage: .github/scripts/update_docs_version.sh +# e.g. .github/scripts/update_docs_version.sh v3.2.4.4600 + +docs_version=$1 +[[ -n "${docs_version}" ]] || { echo "Documentation version not provided"; exit 1; } + +# "-" needs to be escaped as "--" in shields.io badge +find docs -type f -name '*.md' -exec sed -i -r "s/(badge\/version-).*(-blue\.svg)/\1${docs_version//-/--}\2/" {} \; +echo Documentation files updated with version: ${docs_version} diff --git a/.travis/update_project_version.sh b/.github/scripts/update_project_version.sh similarity index 55% rename from .travis/update_project_version.sh rename to .github/scripts/update_project_version.sh index 3f162fb78..bb59528cb 100755 --- a/.travis/update_project_version.sh +++ b/.github/scripts/update_project_version.sh @@ -1,17 +1,20 @@ #!/usr/bin/env bash -echo Current branch is "${CURRENT_BRANCH}" +UTPLSQL_VERSION_PATTERN="v?([0-9]+\.){3}[0-9]+[^']*" + +echo Current branch is "${CI_ACTION_REF_NAME}" echo Update version in project source files -find ${UTPLSQL_SOURCES_DIR} -type f -name '*' -exec sed -i -r "s/${UTPLSQL_VERSION_PATTERN}/${UTPLSQL_BUILD_VERSION}/" {} \; +find source -type f -name '*' -exec sed -i -r "s/${UTPLSQL_VERSION_PATTERN}/${UTPLSQL_BUILD_VERSION}/" {} \; echo Source files updated with version tag: ${UTPLSQL_BUILD_VERSION} echo Update version in documentation files -find docs -type f -name '*.md' -exec sed -i -r "s/(badge\/version-).*(-blue\.svg)/\1${UTPLSQL_BUILD_VERSION/-/--}\2/" {} \; +.github/scripts/update_docs_version.sh "${UTPLSQL_DOCS_VERSION}" echo Update of sonar-project.properties sonar.projectVersion sed -i -r "s/(sonar\.projectVersion=).*?/\1${UTPLSQL_VERSION}/" sonar-project.properties echo Update VERSION file echo ${UTPLSQL_VERSION} > VERSION +echo ${UTPLSQL_BUILD_NO} > BUILD_NO diff --git a/.travis/validate_report_files.sh b/.github/scripts/validate_report_files.sh similarity index 90% rename from .travis/validate_report_files.sh rename to .github/scripts/validate_report_files.sh index 621297a0b..722a9220a 100755 --- a/.travis/validate_report_files.sh +++ b/.github/scripts/validate_report_files.sh @@ -1,11 +1,13 @@ #!/usr/bin/env bash +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + GL_VALID=1 -XSD_DIR="$TRAVIS_BUILD_DIR/.travis/xsd" -XML_JAR_DIR="$TRAVIS_BUILD_DIR/.travis/lib" +XSD_DIR="${SCRIPT_DIR}/xsd" +XML_JAR_DIR="${SCRIPT_DIR}/lib" #XML Validator XML_VALIDATOR="$XML_JAR_DIR/xml_validator.jar" -HTML_VALIDATOR_URL="https://validator.w3.org/nu/" +HTML_VALIDATOR_URL="http://localhost:8888/" HTML_FILENAME="coverage.html" declare -A XML_FILES diff --git a/.travis/xsd/junit4.xsd b/.github/scripts/xsd/junit4.xsd similarity index 100% rename from .travis/xsd/junit4.xsd rename to .github/scripts/xsd/junit4.xsd diff --git a/.travis/xsd/junit_windy.xsd b/.github/scripts/xsd/junit_windy.xsd similarity index 88% rename from .travis/xsd/junit_windy.xsd rename to .github/scripts/xsd/junit_windy.xsd index fe134662a..320779edd 100644 --- a/.travis/xsd/junit_windy.xsd +++ b/.github/scripts/xsd/junit_windy.xsd @@ -1,6 +1,6 @@ - - @@ -71,10 +71,11 @@ Permission to waive conditions of this license may be requested from Windy Road - - - Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace - + + + + Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace + @@ -93,9 +94,9 @@ Permission to waive conditions of this license may be requested from Windy Road - - Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace - + + Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace + @@ -192,6 +193,11 @@ Permission to waive conditions of this license may be requested from Windy Road The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. + + + The total number of ignored or skipped tests in the suite. + + Time taken (in seconds) to execute the tests in the suite @@ -203,4 +209,4 @@ Permission to waive conditions of this license may be requested from Windy Road - + \ No newline at end of file diff --git a/.github/variables/.env b/.github/variables/.env new file mode 100644 index 000000000..7bb5003e8 --- /dev/null +++ b/.github/variables/.env @@ -0,0 +1,27 @@ +#utPLSQL install env +UT3_DEVELOP_SCHEMA=UT3_DEVELOP +UT3_DEVELOP_SCHEMA_PASSWORD=ut3 +UT3_RELEASE_VERSION_SCHEMA=UT3 +UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3 +UT3_TABLESPACE=users + +# Database Env +SQLCLI="sqlplus" +OJDBC_HOME=ojdbc +OJDBC_URL="https://download.oracle.com/otn-pub/otn_software/jdbc/213" +ORACLE_PWD="oracle" +TZ="Europe/London" + +#Build env +UTPLSQL_CLI_VERSION="3.1.8" +UTPLSQL_DIR="utPLSQL_latest_release" +UTPLSQL_BUILD_NO_OFFSET=3563 + +#Git configuration +GIT_AUTHOR_NAME="github-actions[bot]" +GIT_AUTHOR_EMAIL="github-actions[bot]@users.noreply.github.com" +GIT_COMMITTER_NAME="github-actions[bot]" +GIT_COMMITTER_EMAIL="github-actions[bot]@users.noreply.github.com" + +#Docker environment for running utPLSQL install commands +DOCKER_ENV="-e SQLCLI=sqlplus -e UT3_DEVELOP_SCHEMA -e UT3_DEVELOP_SCHEMA_PASSWORD -e UT3_RELEASE_VERSION_SCHEMA -e UT3_RELEASE_VERSION_SCHEMA_PASSWORD -e UT3_TABLESPACE -e ORACLE_PWD -e CONNECTION_STR -e UTPLSQL_DIR" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..f97880a48 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,317 @@ +name: Build, test, deploy documentation +on: + push: + branches-ignore: [ main ] + pull_request: + branches: [ develop ] + schedule: + - cron: '0 8 * * 5' # run scheduled at 8:00 AM every Friday + timezone: "Europe/Nicosia" + + workflow_dispatch: + inputs: + force_docs_publish: + description: 'Publish develop documentation even if no documentation changes were detected' + type: boolean + default: false + +concurrency: ${{github.ref}} +defaults: + run: + shell: bash + +jobs: + + build: + name: Build and test on ${{matrix.db.db_version_name}} DB + runs-on: ubuntu-latest + timeout-minutes: 90 + env: + ORACLE_VERSION: ${{matrix.db.oracle-version}} + ORACLE_SID: ${{matrix.db.oracle-sid}} + CONNECTION_STR: ${{ format( '127.0.0.1:1521/{0}', matrix.db.oracle-sid ) }} + ORACLE_PASSWORD: oracle + DOCKER_VOLUME: ${{matrix.db.docker-volume}} + HAS_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN != '' }} + strategy: + fail-fast: false + matrix: + # The DB versions are values of a matrix key, not `include` entries, because `exclude` can't remove `include` entries. + db: + - id: 1 + db_version_name: '19.20-ee' + oracle-sid: 'UTPLSQL' + oracle-version: "utplsqlv3/oracledb:19.20-utplsql" + run-sonar-scanner: true + - id: 2 + db_version_name: '21XE' + oracle-sid: 'XE' + oracle-version: "gvenzl/oracle-xe:21-slim-faststart" + - id: 3 + db_version_name: '23-free' + oracle-sid: 'FREEPDB1' + oracle-version: "gvenzl/oracle-free:23-slim-faststart" + fips-enabled: true + check-coding-style: true + validate-utplsql-uninstall: true + exclude: + # Pull requests from forks can't access secrets, so they can't pull the private utplsqlv3 19.20-ee image. + - db: + id: ${{ github.event.pull_request.head.repo.fork == true && 1 || 0 }} + services: + html_checker: + image: ghcr.io/validator/validator:latest + options: >- + -p 8888:8888 + oracle: + image: ${{matrix.db.oracle-version}} + env: + ORACLE_PASSWORD: oracle + credentials: ${{ secrets.DOCKER_USER && fromJSON( format( '{{"username":"{0}","password":"{1}"}}', secrets.DOCKER_USER, secrets.DOCKER_PASSWORD ) ) || fromJSON( '{}' ) }} + volumes: + - ${{github.workspace}}:/utPLSQL + ports: + - 1521:1521 + options: >- + --health-interval 10s + --health-timeout 5s + --health-retries 10 + --name oracle + --health-cmd healthcheck.sh + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: c-py/action-dotenv-to-setenv@v5 + with: + env-file: .github/variables/.env + - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action + + - name: Set build version number env variables + id: set-build-version-number-vars + run: .github/scripts/set_version_numbers_env.sh + + - name: Update project version & build number to verify that code is deployable after the update + id: update-project-version + run: .github/scripts/update_project_version.sh + + - name: Download utPLSQL release for testing +# For PR build - test using target branch as framework, for branch build use self as testing framework + run: git clone --depth=1 --branch=${CI_BASE_REF:-$CI_REF_NAME} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR + + - name: Enable FIPS 140 on Oracle DB + id: enable-fips + if: ${{ matrix.db.fips-enabled == true }} + run: | + docker exec oracle bash -c " + echo \"ALTER SYSTEM SET DBFIPS_140=TRUE SCOPE=SPFILE; + SHUTDOWN IMMEDIATE; + STARTUP; + PROMPT Should show true for DBFIPS_140 + SELECT name, value FROM v$parameter WHERE name = 'DBFIPS_140'; + EXIT;\" | sqlplus -s / as sysdba + " + docker exec oracle bash -c "until healthcheck.sh; do echo 'Waiting for DB restart...'; sleep 1; done" + - name: Update privileges on sources + run: chmod -R go+w ./{source,test,examples,${UTPLSQL_DIR}/source} + + - name: Cache OJDBC jars + id: cache-ojdbc + uses: actions/cache@v4 + with: + path: ${{ env.OJDBC_HOME }} + key: ${{ runner.os }}-ojdbc-${{ env.OJDBC_URL }}-v1 + + - name: Add OJDBC home + if: steps.cache-ojdbc.outputs.cache-hit != 'true' + id: get-ojdbc + run: mkdir -p ${OJDBC_HOME} && curl -Lk -o ${OJDBC_HOME}/ojdbc8.jar ${OJDBC_URL}/ojdbc8.jar && curl -Lk -o ${OJDBC_HOME}/orai18n.jar ${OJDBC_URL}/orai18n.jar + + - name: Cache utPLSQL-cli + id: cache-utplsql-cli + uses: actions/cache@v4 + with: + path: utPLSQL-cli + key: ${{ runner.os }}-utplsql-cli-v3.1.8 + + - name: Install utPLSQL-cli + if: steps.cache-utplsql-cli.outputs.cache-hit != 'true' + id: install-utplsql-cli + run: curl -Lk -o utPLSQL-cli.zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/3.1.9/utPLSQL-cli.zip" && unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli + + - name: Install utPLSQL + id: install-utplsql + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh + + - name: Check code style + if: ${{ matrix.db.check-coding-style == true }} + id: check-coding-style + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle "$SQLCLI" ${UT3_DEVELOP_SCHEMA}/${UT3_DEVELOP_SCHEMA_PASSWORD}@//${CONNECTION_STR} @/utPLSQL/development/utplsql_style_check.sql + + - name: Validate utPLSQL uninstall + if: ${{ matrix.db.validate-utplsql-uninstall == true }} + id: validate-uninstall + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/uninstall_validate_utplsql.sh + + - name: Reinstall utPLSQL + if: ${{ matrix.db.validate-utplsql-uninstall == true }} + id: reinstall-utplsql + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh + + - name: Create test users + id: create-test-users + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/create_test_users.sh + + - name: Install utPLSQL release + id: install-utplsql-release + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install_utplsql_release.sh + + - name: Run Examples + id: run-examples + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/run_examples.sh + + - name: Install tests + id: install-tests + run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle test/install_tests.sh + + - name: Run Tests + id: run-tests + run: test/run_tests.sh + +#Start Needed to diagnose occasional failures of DB on test runs + - name: Prepare diagnostic directory + id: preapre-oracle-diag-dir + if: ${{ always() && steps.run-tests.outcome == 'failure' }} + run: | + mkdir database-diag + chmod +777 database-diag + - name: Get ORACLE_BASE/diag data + id: get-oracle-diag-data + if: ${{ always() && steps.run-tests.outcome == 'failure' }} + run: docker exec oracle bash -c "chmod -R +777 ./diag && cp -r ./diag /utPLSQL/database-diag" + - name: Upload ORACLE_BASE/diag data Artifact + id: upload + if: ${{ always() && steps.run-tests.outcome == 'failure' }} + uses: actions/upload-artifact@v4 + with: + name: my-artifact$-${{matrix.db.db_version_name}} + path: ${{github.workspace}}/database-diag +#End Needed to diagnose occasional failures of DB on test runs + + - name: Validate utPLSQL reports format + id: validate-reports-format + run: bash .github/scripts/validate_report_files.sh + + - name: Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + files: ./cobertura.xml + flags: ${{matrix.db.db_version_name}} + fail_ci_if_error: true # optional (default = false) + + - name: Publish unit test results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: junit_test_results.xml + + - name: SonarCloud Scan + id: sonar + if: ${{ always() && matrix.db.run-sonar-scanner == true && env.HAS_SONAR_TOKEN == 'true' }} + uses: SonarSource/sonarqube-scan-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.buildString=${{ format( '{0}.{1}', env.UTPLSQL_BUILD_VERSION, matrix.db.id ) }} + -Dsonar.plsql.jdbc.url=${{ format( 'jdbc:oracle:thin:@//localhost:1521/{0}', env.ORACLE_SID ) }} + -Dsonar.plsql.jdbc.driver.path=${{ format( '{0}/ojdbc8.jar', env.OJDBC_HOME ) }} + + publish: + name: Deploy documentation + needs: [ build ] + concurrency: publish + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + if: | + github.repository == 'utPLSQL/utPLSQL' && + github.base_ref == null && github.ref == 'refs/heads/develop' + steps: + - name: 🔍 API_TOKEN_GITHUB + if: env.API_TOKEN_GITHUB == '' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: echo "API_TOKEN_GITHUB=${GITHUB_TOKEN}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ env.API_TOKEN_GITHUB }} + - uses: c-py/action-dotenv-to-setenv@v5 + with: + env-file: .github/variables/.env + - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action + + - name: Detect changes since last publish + id: detect-changes + run: .github/scripts/detect_changes_since_last_publish.sh + + - name: Set build version number env variables + id: set-build-version-number-vars + if: steps.detect-changes.outputs.project_changed == 'true' + run: .github/scripts/set_version_numbers_env.sh + + - name: Update project version & build number in source code and documentation + id: update-project-version + if: steps.detect-changes.outputs.project_changed == 'true' + run: .github/scripts/update_project_version.sh + + - name: Push version update to repository + id: push-version-number-update + if: steps.detect-changes.outputs.project_changed == 'true' + run: | + git add sonar-project.properties VERSION BUILD_NO source/* docs/* + git commit -m 'Updated project version after build [skip ci]' + git push --quiet origin HEAD:${CI_ACTION_REF_NAME} + + - name: Setup git config + if: steps.detect-changes.outputs.docs_changed == 'true' || inputs.force_docs_publish + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + - name: Build and publish documentation + if: steps.detect-changes.outputs.docs_changed == 'true' || inputs.force_docs_publish + run: | + pip install mkdocs + pip install mkdocs-git-revision-date-localized-plugin + pip install mkdocs-material + pip install git+https://github.com/jimporter/mike.git + pip install mkdocs-git-committers-plugin-2 + mike deploy -p develop + + dispatch: + name: Dispatch downstream builds + concurrency: trigger + needs: [ build, publish ] + runs-on: ubuntu-latest + timeout-minutes: 15 + if: | + github.repository == 'utPLSQL/utPLSQL' && github.base_ref == null && + ( startsWith( github.ref, 'refs/heads/release/v' ) || github.ref == 'refs/heads/develop' ) + strategy: + matrix: + repo: [ 'utPLSQL/utPLSQL-demo-project', 'utPLSQL/utPLSQL-java-api' ] +# repo: [ 'utPLSQL/utPLSQL-v2-v3-migration' ] + steps: + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@v4 + with: + token: ${{ secrets.API_TOKEN_GITHUB }} + repository: ${{ matrix.repo }} + event-type: utPLSQL-build + diff --git a/.github/workflows/rebuild_docs.yml b/.github/workflows/rebuild_docs.yml new file mode 100644 index 000000000..835ae5947 --- /dev/null +++ b/.github/workflows/rebuild_docs.yml @@ -0,0 +1,67 @@ +name: Rebuild older docs versions +on: + workflow_dispatch: + inputs: + versions: + description: 'Space-separated list of versions to rebuild (e.g. "v3.1.14 v3.1.13")' + required: true + default: 'v.3.2.3 v3.2.2 v3.2.01 v3.1.14 v3.1.13 v3.1.12 v3.1.11 v3.1.10 v3.1.9 v3.1.8 v3.1.6 v3.1.5 v3.1.4 v3.1.3 v3.1.2 v3.1.1 v3.1.0 v3.0.4 v3.0.3 v3.0.2 v3.0.1 v3.0.0 v3.0.0-beta' + +defaults: + run: + shell: bash + +jobs: + rebuild: + name: Rebuild documentation for older versions + concurrency: publish + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + + steps: + - name: 🔍 API_TOKEN_GITHUB + if: env.API_TOKEN_GITHUB == '' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: echo "API_TOKEN_GITHUB=${GITHUB_TOKEN}" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ env.API_TOKEN_GITHUB }} + + - uses: c-py/action-dotenv-to-setenv@v5 + with: + env-file: .github/variables/.env + + - uses: FranzDiebold/github-env-vars-action@v2.8.0 + + - name: Install mkdocs stack + run: | + pip install mkdocs + pip install mkdocs-git-revision-date-localized-plugin + pip install mkdocs-material + pip install git+https://github.com/jimporter/mike.git + pip install mkdocs-git-committers-plugin-2 + + - name: Rebuild specified versions + run: | + git fetch --quiet origin gh-pages + for VERSION in ${{ inputs.versions }}; do + echo "=== Rebuilding $VERSION ===" + git checkout "tags/${VERSION}" -- docs/ + # Use the current look and feel (colors, footer, top bar) for every version; + # tags released since the restyling carry their own, older copies of these files + git checkout HEAD -- docs/stylesheets docs/overrides + # Keep the version badge as originally published with the release + DOCS_VERSION=$(.github/scripts/get_published_docs_version.sh "${VERSION}") + if [[ -n "${DOCS_VERSION}" ]]; then + .github/scripts/update_docs_version.sh "${DOCS_VERSION}" + else + echo "Published documentation version for ${VERSION} not found, version badge left unchanged" + fi + mike deploy -p "${VERSION}" + git checkout HEAD -- docs/ mkdocs.yml + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..7b28424a0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,83 @@ +name: Create and publish release artifacts +on: + release: + types: [ released ] +#See: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-using-multiple-events-with-activity-types-or-configuration + +defaults: + run: + shell: bash + +jobs: + + upload_artifacts: + name: Upload archives + concurrency: upload + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_BODY: ${{ github.event.release.body }} + RELEASE_DATE: ${{ github.event.release.published_at }} + RELEASE_URL: ${{ github.event.release.html_url }} + TARGET_BRANCH: ${{ github.event.release.target_commitish }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ env.API_TOKEN_GITHUB }} + - uses: c-py/action-dotenv-to-setenv@v5 + with: + env-file: .github/variables/.env + - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action + + - name: Update CHANGELOG.md with release notes + run: .github/scripts/update_changelog.sh + + - name: Set build version number env variables + run: .github/scripts/set_release_version_numbers_env.sh + + - name: Update project version & build number in source code and documentation + run: .github/scripts/update_project_version.sh + + - name: Build and publish documentation + run: | + pip install mkdocs + pip install mkdocs-git-revision-date-localized-plugin + pip install mkdocs-material + pip install git+https://github.com/jimporter/mike.git + pip install mkdocs-git-committers-plugin-2 + mike deploy -p -u ${UTPLSQL_VERSION} latest + mkdocs build --clean -f mkdocs_offline.yml + rm -rf docs/* + cp -r -v site/* docs + git add . + git commit -m "tmp commit of HTML documentation for building a release archive" + + - name: Build release archives + run: | + git archive --prefix=utPLSQL/ -o utPLSQL.zip --format=zip HEAD + git archive --prefix=utPLSQL/ -o utPLSQL.tar.gz --format=tar.gz HEAD + sha256sum utPLSQL.zip --tag > utPLSQL.zip.sha256 + sha256sum utPLSQL.tar.gz --tag > utPLSQL.tar.gz.sha256 + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + utPLSQL.zip + utPLSQL.zip.sha256 + utPLSQL.tar.gz + utPLSQL.tar.gz.sha256 + + - name: Announce release in org discussions and on utplsql.github.io + uses: utPLSQL/.github/actions/announce-release@v1 + with: + project-name: utPLSQL + tag: ${{ github.event.release.tag_name }} + discussion-token: ${{ secrets.API_TOKEN_GITHUB }} + site-token: ${{ secrets.API_TOKEN_GITHUB }} + site-category: utplsql-core + diff --git a/.github/workflows/test_publishing.yml b/.github/workflows/test_publishing.yml new file mode 100644 index 000000000..4c86d2da8 --- /dev/null +++ b/.github/workflows/test_publishing.yml @@ -0,0 +1,55 @@ +name: Test publishing +on: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + + upload_artifacts: + name: Upload archives + concurrency: upload + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + RELEASE_TAG: "v3.2.3" + RELEASE_BODY: | + ## What's Changed + * Fix issue with `UT_TAP_REPORTER` on Oracle 23.26 by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1359 + * Fixed support for camelCase in context `--%name` annotation. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1361 + * utPLSQL can be installed in editioned schema. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1362 + * Removed coveralls reporter by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1363 + * Clarify behavior of before/after procedures in suitepath by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1364 + * `throws` can reference exception without schema or package name by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1365 + * `throws` works with uninitialized exception variables by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1366 + + + **Full Changelog**: https://github.com/utPLSQL/utPLSQL/compare/v3.2.2...v.3.2.3 + RELEASE_DATE: "2026-07-10 08:30:22" + RELEASE_URL: "https://github.com/utPLSQL/utPLSQL/releases/tag/v3.2.3" + TARGET_BRANCH: "develop" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ env.API_TOKEN_GITHUB }} + - uses: c-py/action-dotenv-to-setenv@v5 + with: + env-file: .github/variables/.env + - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action + +# - name: Update CHANGELOG.md with release notes +# run: .github/scripts/update_changelog.sh + + - name: Publish release post to utplsql.github.io + uses: utPLSQL/.github/actions/announce-release@v1 + with: + project-name: utPLSQL + tag: ${{ env.RELEASE_TAG }} + site-token: ${{ secrets.API_TOKEN_GITHUB }} + site-category: utplsql-core + diff --git a/.gitignore b/.gitignore index be442d164..be0e26a77 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ development/*.jar *.log # exclusions based on artifacts created via actions documented in CONTRIBUTING.md -test/dummy.sql coverage.html_assets/ coverage.html coverage.json diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7e9d94ccf..000000000 --- a/.travis.yml +++ /dev/null @@ -1,143 +0,0 @@ -sudo: required -language: python - -addons: - apt: - packages: - - unzip - # Java9 Required for Sonar and SQLCL - - oracle-java9-installer - - oracle-java9-set-default - sonarcloud: - organization: utplsql - token: - secure: ${SONAR_TOKEN} - -services: - - docker - -env: - global: - - UT3_OWNER=ut3 - - UT3_OWNER_PASSWORD=ut3 - - UT3_RELEASE_VERSION_SCHEMA=UT3_LATEST_RELEASE - - UT3_USER="UT3\$USER#" - - UT3_USER_PASSWORD=ut3 - - UT3_TESTER=ut3_tester - - UT3_TESTER_PASSWORD=ut3 - - UT3_TESTER_HELPER=ut3_tester_helper - - UT3_TESTER_HELPER_PASSWORD=ut3 - - UT3_TABLESPACE=users - # Environment for building a release - - CURRENT_BRANCH=${TRAVIS_BRANCH} - - UTPLSQL_REPO="utPLSQL/utPLSQL" - - UTPLSQL_BUILD_NO="${TRAVIS_BUILD_NUMBER:-0}" - - UTPLSQL_VERSION_PATTERN="v?([0-9]+\.){3}[0-9]+[^']*" - - UTPLSQL_VERSION=$(. .travis/get_project_version.sh) - - UTPLSQL_BUILD_VERSION=$(. .travis/get_project_build_version.sh) - - UTPLSQL_SOURCES_DIR='source' - - UTPLSQL_BUILD_USER_NAME="Travis CI" - - CACHE_DIR=$HOME/.cache - # Database Env - - SQLCLI="$HOME/sqlcl/bin/sql" - - OJDBC_HOME="$HOME/sqlcl/lib" - - ORACLE_PWD="oracle" - - UT3_DOCKER_REPO="utplsqlv3/oracledb" - - DOCKHER_HUB_REPO="${DOCKER_BASE_TAG:-$UT3_DOCKER_REPO}" - #utPLSQL released version directory - - UTPLSQL_DIR="utPLSQL_latest_release" - - SELFTESTING_BRANCH=${TRAVIS_BRANCH} - - UTPLSQL_CLI_VERSION="3.1.6" - # Maven - - MAVEN_HOME=/usr/local/maven - - MAVEN_CFG=$HOME/.m2 - matrix: - - ORACLE_VERSION="${DOCKER_TAG_11G:-11g-r2-xe}" CONNECTION_STR='127.0.0.1:1521/XE' DOCKER_OPTIONS='--shm-size=1g' - - ORACLE_VERSION="${DOCKER_TAG_12C:-12c-r1-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" - - ORACLE_VERSION="${DOCKER_TAG_12C2:-12c-r2-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" - - ORACLE_VERSION="${DOCKER_TAG_18:-18c-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" - - ORACLE_VERSION="${DOCKER_TAG_19:-19c-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" - -cache: - pip: true - directories: - - $CACHE_DIR - - /home/travis/.sonar/cache - - node_modules - - $MAVEN_CFG - -before_install: - #cache to be used between stages. Based on https://github.com/travis-ci/docs-travis-ci-com/issues/1329 - #delete all files in cache that are older than 5 days - - mkdir -p $CACHE_DIR/stages_cache; find $CACHE_DIR/stages_cache/ -mtime +5 -exec rm {} \; - #The update_project_version.sh is done before deployment to validate that the change of project files does not break installation - - bash .travis/update_project_version.sh - #Allow for sonar to blame issues - - git fetch --unshallow - # download latest utPLSQL release - #- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - - git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR - # download latest utPLSQL-cli release - - curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/v${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip - -install: - #- unzip utPLSQL.zip - - unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli - # Get ojdbc via maven - - bash .travis/maven_cfg.sh - - bash .travis/install_sqlcl.sh - - sudo mkdir -p /dev/pdbs - - sudo chmod -R 777 /dev/pdbs - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/start_db.sh; fi - -before_script: - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/install.sh; fi - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/install_utplsql_release.sh; fi - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/run_examples.sh; fi - -script: - - if [[ ! $TRAVIS_TAG ]]; then bash test/install_and_run_tests.sh; fi - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh; fi - - if [[ ! $TRAVIS_TAG ]] && [[ ("${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" && "${TRAVIS_PULL_REQUEST}" == false) || ("${TRAVIS_PULL_REQUEST_SLUG}" = "${UTPLSQL_REPO}") ]]; then bash .travis/run_sonar_scanner.sh; fi - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi - -notifications: - slack: - rooms: - - secure: "nemt9n2y5sVCAKqa/s7JDQ8AcM59Xu/XbH/RkMOXvPgc+KtR8lBtVD1LkvJ5BaQhqgjuDT7DNt/uisQJ7k6a2OsrVFbnkypZ1hCvntOBpJyoSpD/YL1X8a9GbGojuJcph0BX76KN21LaOVdyOfY0TSlw53XiYWS8iL5HtjpWCbIwHL1SJ8JT8mhdT4hDoUWZjcZ4s4bLH6BQm4un/bMQOmB4sDoCeg4CllJwxgkswVF7OHpOFjgPetvUp7ps8b/Rj8en6zCj9drb0SVbXFgumo2Wd1bC3HHZB8MAZU0kuEV5VgUdum6EelUL5yfB72hssNQA0+CaT3HjBFkTlqWYJmjC4/xyGN3sseiW82T9FDY0g0GAGayNRW+QSiTQ1hbJEcAnNe0GrBUdRsgXdI6COd76YP5VxzRSF6H7niLfgCZdKbIivKUd1o+wBhuyJmqCFIkRWmT38tMGJqJAzbY1jq5gQXbb6E7gt+KdTjlSjcnJYf7XI7zqm+BRr+fbA0ixfXHvfqOBgZN6g08y9nPlDnIjtSF2NSdrj2zqYQAtKuWSOD1bnTyfDJyrtK7OLffZcMYD5Bcss4c8op8tP7MGTjt1S046SJocboh6H4c/nTokpoMRsWs6MKRdebl8C2RObGf5FebSOJg+oh2ZYS5Z/G9GshiY2BD/81+Hc4Miacc=" - on_success: change - on_failure: always - -jobs: - include: - - stage: deploy - env: ORACLE_VERSION="none" - before_install: skip - install: - - pip install mkdocs - before_script: skip - script: - - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN; fi - - #The update_project_version.sh needs to be done before pushing changes to develop branch - - bash .travis/update_project_version.sh - - git config --global user.email "builds@travis-ci.com" - - git config --global user.name "${UTPLSQL_BUILD_USER_NAME}" - - git remote rm origin - - git remote add origin https://${github_api_token}@github.com/${UTPLSQL_REPO} - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - - bash .travis/build_docs.sh - - bash .travis/push_docs_to_gh_pages.sh - before_deploy: - - bash .travis/build_release_archive.sh - deploy: - provider: releases - api_key: $github_api_token - file: - - utPLSQL.zip - - utPLSQL.tar.gz - - utPLSQL.zip.md5 - - utPLSQL.tar.gz.md5 - skip_cleanup: true - on: - repo: ${UTPLSQL_REPO} - tags: true diff --git a/.travis/build_docs.sh b/.travis/build_docs.sh deleted file mode 100755 index db43d7ca9..000000000 --- a/.travis/build_docs.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Change working directory to script directory -cd "${0%/*}" -# Change back to root -cd .. -mkdocs build --clean --strict diff --git a/.travis/build_release_archive.sh b/.travis/build_release_archive.sh deleted file mode 100755 index 9667cba7e..000000000 --- a/.travis/build_release_archive.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# remove markdown documentation -rm -rf docs/* -# and replace it with generated html documentation from the ignored site folder -cp -r -v site/* docs - -git add . -git commit -m "tmp commit for building a release archive" - -# git archive --prefix="utPLSQL${UTPLSQL_BUILD_VERSION}"/ -o "utPLSQL${UTPLSQL_BUILD_VERSION}".zip --format=zip HEAD -# git archive --prefix="utPLSQL${UTPLSQL_BUILD_VERSION}"/ -o "utPLSQL${UTPLSQL_BUILD_VERSION}".tar.gz --format=tar.gz HEAD - -git archive --prefix=utPLSQL/ -o utPLSQL.zip --format=zip HEAD -git archive --prefix=utPLSQL/ -o utPLSQL.tar.gz --format=tar.gz HEAD -md5sum utPLSQL.zip --tag > utPLSQL.zip.md5 -md5sum utPLSQL.tar.gz --tag > utPLSQL.tar.gz.md5 - diff --git a/.travis/coveralls_uploader.js b/.travis/coveralls_uploader.js deleted file mode 100644 index ad6eeee74..000000000 --- a/.travis/coveralls_uploader.js +++ /dev/null @@ -1,31 +0,0 @@ -var fs = require('fs'); -var request = require('request'); -const md5File = require('md5-file'); - -var url -if (process.env.COVERALLS_URL_BASE) { - url = process.env.COVERALLS_URL_BASE+'/api/v1/jobs'; -} else { - url = 'https://coveralls.io/api/v1/jobs'; -} - -fs.readFile('../coverage.json',function (err,data) { - if (err) { - return console.log(err); - } - req = JSON.parse(data); - req.service_job_id = process.env.TRAVIS_JOB_ID; - req.service_name = 'travis-ci'; - if (process.env.COVERALLS_REPO_TOKEN) { - req.repo_token = process.env.COVERALLS_REPO_TOKEN; - } - - for (var i in req.source_files) { - req.source_files[i].source_digest = md5File.sync("../" + req.source_files[i].name); - } - - var requestStr = JSON.stringify(req); - - request.post({url : url, form : { json:requestStr}}, function(err, response, body){process.stdout.write(body);}); - -}); diff --git a/.travis/coveralls_uploader.sh b/.travis/coveralls_uploader.sh deleted file mode 100755 index 8fcbad58d..000000000 --- a/.travis/coveralls_uploader.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -e -echo "coveralls_uploader" -npm install request --save -npm install --save md5-file -cd "$(dirname "$(readlink -f "$0")")" -exec node coveralls_uploader.js diff --git a/.travis/download.js b/.travis/download.js deleted file mode 100644 index 339001c57..000000000 --- a/.travis/download.js +++ /dev/null @@ -1,56 +0,0 @@ - -var casper = require("casper").create({ - // verbose: true, - // logLevel: "debug", - pageSettings: { - loadImages: false, - loadPlugins: false - } -}); - -if (casper.cli.args.length < 4) { - casper.echo("Missing parameters: username password agreementUrl downloadUrl").exit(1); -} - -// Script parameters. -var paramUsername = casper.cli.get(0); -var paramPassword = casper.cli.get(1); -var agreementUrl = casper.cli.get(2); -var downloadUrl = casper.cli.get(3); -var downloaded = false; - -casper.start(); -// TODO: Error handling. - -// Accept the license agreement. -casper.thenOpen(agreementUrl, function () { - // this.echo("Accepting License"); - this.evaluate(function () { - acceptAgreement(window.self); - }); -}); - -// Try to access the download page, wait for redirection and submit the login form. -casper.thenOpen(downloadUrl).waitForUrl(/signon\.jsp$/, function (re) { - // this.echo("Injecting Login Info"); - this.evaluate(function (username, password) { - document.getElementById("sso_username").value = username; - document.getElementById("ssopassword").value = password; - doLogin(document.LoginForm); - }, paramUsername, paramPassword); - // this.capture("Screenshot.png"); -}); - -casper.on("resource.received", function (resource) { - if (resource.url.indexOf("AuthParam") !== -1 && !downloaded) { - // this.echo("DownloadUrl:"); - // Print the download url. - this.echo(resource.url); - downloaded = true; - // TODO: Try to download file from here. this.download is not working because of cross site request. - } -}); - -casper.run(function () { - this.exit(); -}); diff --git a/.travis/download.sh b/.travis/download.sh deleted file mode 100755 index fdbcdef7c..000000000 --- a/.travis/download.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -set -e - -if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then - echo "Error: Oracle OTN username/password not specified." - exit 1 -fi - -PRODUCT="" - -# Call the casperjs script to return the download url. -# Then download the file using curl. -downloadFile() { - downloadUrl=$(exec casperjs download.js $ORACLE_OTN_USER $ORACLE_OTN_PASSWORD $1 $2) - downloadUrl=${downloadUrl%$'\r'} - echo "DownloadURL: $downloadUrl" - curl -o $3 -L "$downloadUrl" -} - -############################# -########### START ########### -############################# - -while getopts "p:" OPTNAME; do - case "${OPTNAME}" in - "p") PRODUCT="${OPTARG}" ;; - esac -done - -if [ "$PRODUCT" == "se12c" ]; then - agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" - downloadUrl="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_se2_1of2.zip" - outputFile=linuxamd64_12102_database_se2_1of2.zip - downloadFile $agreementUrl $downloadUrl $outputFile - agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" - downloadUrl="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_se2_2of2.zip" - outputFile=linuxamd64_12102_database_se2_2of2.zip - downloadFile $agreementUrl $downloadUrl $outputFile - exit 0 -fi - -if [ "$PRODUCT" == "ee12c" ]; then - agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" - downloadUrl="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_1of2.zip" - outputFile=linuxamd64_12102_database_1of2.zip - downloadFile $agreementUrl $downloadUrl $outputFile - agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" - DOWNLOAD_URL="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_2of2.zip" - outputFile=linuxamd64_12102_database_2of2.zip - downloadFile $agreementUrl $downloadUrl $outputFile - exit 0 -fi - -if [ "$PRODUCT" == "xe11g" ]; then - agreementUrl="http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html" - downloadUrl="https://edelivery.oracle.com/akam/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip" - outputFile=oracle-xe-11.2.0-1.0.x86_64.rpm.zip - downloadFile $agreementUrl $downloadUrl $outputFile - exit 0 -fi - -if [ "$PRODUCT" == "sqlcl" ]; then - agreementUrl="http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html" - downloadUrl="https://download.oracle.com/otn/java/sqldeveloper/sqlcl-18.3.0.259.2029.zip" - outputFile=sqlcl-18.3.0.259.2029.zip - downloadFile $agreementUrl $downloadUrl $outputFile - exit 0 -fi - -echo "Error: invalid product: $PRODUCT" -exit 1 diff --git a/.travis/get_project_build_version.sh b/.travis/get_project_build_version.sh deleted file mode 100755 index 838523b05..000000000 --- a/.travis/get_project_build_version.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -echo `sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${UTPLSQL_BUILD_NO}\4/" <<< "${UTPLSQL_VERSION}"` diff --git a/.travis/get_project_version.sh b/.travis/get_project_version.sh deleted file mode 100755 index 20a658ed9..000000000 --- a/.travis/get_project_version.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -#When building a new version from a release branch, the version is taken from release branch name -if [[ "${CURRENT_BRANCH}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then - version=${CURRENT_BRANCH#release\/} -else - #Otherwise, version is taken from the VERSION file - version=`cat VERSION` - #When on develop branch, add "-develop" to the version text - if [[ "${CURRENT_BRANCH}" == "develop" ]]; then - version=`sed -E "s/(v?[0-9]+\.[0-9]+\.[0-9]+).*/\1-develop/" <<< "${version}"` - fi -fi -echo ${version} diff --git a/.travis/install.sh b/.travis/install.sh deleted file mode 100755 index 4806105b1..000000000 --- a/.travis/install.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash - -cd source -set -ev - -#install core of utplsql -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -whenever sqlerror exit failure rollback -set feedback off -set verify off - ---alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6003,6009,6010,7206)'; -alter session set plsql_optimize_level=0; -@install_headless_with_trigger.sql $UT3_OWNER $UT3_OWNER_PASSWORD -SQL - -#Run this step only on second child job (12.1 - at it's fastest) -if [[ "${TRAVIS_JOB_NUMBER}" =~ \.2$ ]]; then - - #check code-style for errors - time "$SQLCLI" $UT3_OWNER/$UT3_OWNER_PASSWORD@//$CONNECTION_STR @../development/utplsql_style_check.sql - - #test install/uninstall process - time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL - set feedback off - set verify off - whenever sqlerror exit failure rollback - - @uninstall_all.sql $UT3_OWNER - whenever sqlerror exit failure rollback - declare - v_leftover_objects_count integer; - begin - select sum(cnt) - into v_leftover_objects_count - from ( - select count(1) cnt from dba_objects where owner = '$UT3_OWNER' - where object_name not like 'PLSQL_PROFILER%' and object_name not like 'DBMSPCC_%' - union all - select count(1) cnt from dba_synonyms where table_owner = '$UT3_OWNER' - where table_name not like 'PLSQL_PROFILER%' and table_name not like 'DBMSPCC_%' - ); - if v_leftover_objects_count > 0 then - raise_application_error(-20000, 'Not all objects were successfully uninstalled - leftover objects count='||v_leftover_objects_count); - end if; - end; - / -SQL - - time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL - set feedback off - set verify off - - alter session set plsql_optimize_level=0; - @install.sql $UT3_OWNER - @install_ddl_trigger.sql $UT3_OWNER - @create_synonyms_and_grants_for_public.sql $UT3_OWNER -SQL - -fi - - -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -set feedback off -whenever sqlerror exit failure rollback - --------------------------------------------------------------------------------- -PROMPT Adding back create-trigger privilege to $UT3_OWNER for testing -grant administer database trigger to $UT3_OWNER; - --------------------------------------------------------------------------------- -PROMPT Creating $UT3_TESTER - Power-user for testing internal framework code - -create user $UT3_TESTER identified by "$UT3_TESTER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; -grant create session, create procedure, create type, create table to $UT3_TESTER; - -PROMPT Additional grants for disabling DDL trigger and testing parser without trigger enabled/present - -grant alter any trigger to $UT3_TESTER; -grant administer database trigger to $UT3_TESTER; -grant execute on dbms_lock to $UT3_TESTER; - -PROMPT Granting $UT3_OWNER code to $UT3_TESTER - -begin - for i in ( - select object_name from all_objects t - where t.object_type in ('PACKAGE','TYPE') - and owner = 'UT3' - and generated = 'N' - and object_name not like 'SYS%') - loop - execute immediate 'grant execute on ut3."'||i.object_name||'" to UT3_TESTER'; - end loop; -end; -/ - -PROMPT Granting $UT3_OWNER tables to $UT3_TESTER - -begin - for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_NAME is NULL) - loop - execute immediate 'grant select on UT3.'||i.table_name||' to UT3_TESTER'; - end loop; -end; -/ - - --------------------------------------------------------------------------------- -PROMPT Creating $UT3_USER - minimal privileges user for API testing - -create user $UT3_USER identified by "$UT3_USER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; -grant create session, create procedure, create type, create table to $UT3_USER; - - --------------------------------------------------------------------------------- -PROMPT Creating $UT3_TESTER_HELPER - provides functions to allow min grant test user setup tests. - -create user $UT3_TESTER_HELPER identified by "$UT3_TESTER_HELPER_PASSWORD" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; -grant create session, create procedure, create type, create table to $UT3_TESTER_HELPER; - -PROMPT Grants for testing distributed transactions -grant create public database link to $UT3_TESTER_HELPER; -grant drop public database link to $UT3_TESTER_HELPER; - -PROMPT Grants for testing coverage outside of main UT3 schema. -grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table, select any dictionary, create any synonym, drop any synonym to $UT3_TESTER_HELPER; -grant create job to $UT3_TESTER_HELPER; - -exit -SQL diff --git a/.travis/install_sqlcl.sh b/.travis/install_sqlcl.sh deleted file mode 100755 index 9743ddac2..000000000 --- a/.travis/install_sqlcl.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -e - -SQLCL_FILE=sqlcl-18.3.0.259.2029.zip -cd .travis - -# Download if not present on cache dir. -if [ ! -f $CACHE_DIR/$SQLCL_FILE ]; then - npm install -g phantomjs-prebuilt casperjs - bash download.sh -p sqlcl - mv $SQLCL_FILE $CACHE_DIR -else - echo "Installing sqlcl from cache..." -fi; - -# Install sqlcl. -unzip -q $CACHE_DIR/$SQLCL_FILE -d $HOME - -# Check if it is installed correctly. -$SQLCLI -v diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh deleted file mode 100755 index ef2348099..000000000 --- a/.travis/maven_cfg.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -ev -cp .travis/settings.xml $MAVEN_CFG/settings.xml - -cd $(dirname $(readlink -f $0)) - -# Download wagon-http recommended by Oracle. -# On maven latest version this is not needed, but travis doesn't have it. -if [ ! -f $CACHE_DIR/wagon-http-2.8-shaded.jar ]; then - curl -L -O "http://central.maven.org/maven2/org/apache/maven/wagon/wagon-http/2.8/wagon-http-2.8-shaded.jar" - mv wagon-http-2.8-shaded.jar $CACHE_DIR/ - sudo cp $CACHE_DIR/wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/ -else - echo "Using cached wagon-http..." - sudo cp $CACHE_DIR/wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/ -fi - -mvn dependency:copy-dependencies -DoutputDirectory=../utPLSQL-cli/lib \ No newline at end of file diff --git a/.travis/pom.xml b/.travis/pom.xml deleted file mode 100644 index 706bd79bb..000000000 --- a/.travis/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - org.utplsql - utplsql - 3.0.4-SNAPSHOT - jar - - utPLSQL - https://github.com/utPLSQL/utPLSQL - - - UTF-8 - - - - - com.oracle.jdbc - ojdbc8 - 12.2.0.1 - compile - - - com.oracle.jdbc - orai18n - 12.2.0.1 - compile - - - - - - maven.oracle.com - - true - - - false - - https://maven.oracle.com - default - - - - - - maven.oracle.com - https://maven.oracle.com - - - - - - - io.packagecloud.maven.wagon - maven-packagecloud-wagon - 0.0.6 - - - - diff --git a/.travis/push_docs_to_gh_pages.sh b/.travis/push_docs_to_gh_pages.sh deleted file mode 100755 index d2c5a685c..000000000 --- a/.travis/push_docs_to_gh_pages.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -# Many aspects of this came from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd -# Significant alterations -# - Support for multiple copies of documentation, -# - only clearing out develop -# - index.md logging doc history - -# How to run: -# - From repository root .travis/push_docs_to_gh_pages.sh - -# Required files / directories (relative from repo root) -# - File: "docs/index.md" with that contains develop docs - -# Required ENV Variables -PAGES_TARGET_BRANCH="gh-pages" -LATEST_DOCS_BRANCH="develop" -# TRAVIS_* variables are set by travis directly and only need to be if testing externally - -# We don't want a pull request automatically updating the repository -if [ "$TRAVIS_PULL_REQUEST" == "false" ] && { [ "${CURRENT_BRANCH}" == "${LATEST_DOCS_BRANCH}" ] || [ -n "${TRAVIS_TAG}" ]; }; then - - # ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message. - # Anyone one of them not set can be used to turn off this functionality. - - # If a version of the project is not defined - [[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 0; } - # Fail if the markdown documentation is not present. - [[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; } - - # Save some useful information - SHA=`git rev-parse --verify HEAD` - - # clone the repository and switch to PAGES_TARGET_BRANCH branch - mkdir pages - cd pages - git clone https://${github_api_token}@github.com/${UTPLSQL_REPO} . - - PAGES_BRANCH_EXISTS=$(git ls-remote --heads origin ${PAGES_TARGET_BRANCH}) - - if [ -n "$PAGES_BRANCH_EXISTS" ] ; then - echo "Pages Branch Found" - git checkout ${PAGES_TARGET_BRANCH} - else - echo "Creating Pages Branch" - git checkout --orphan ${PAGES_TARGET_BRANCH} - git rm -rf . - fi - #clear out develop documentation directory and copy docs contents to it. - echo "updating 'develop' directory" - mkdir -p develop - rm -rf develop/**./* || exit 0 - cp -a ../docs/. ./develop - # If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory - if [ -n "$TRAVIS_TAG" ]; then - echo "Creating ${UTPLSQL_VERSION}" - mkdir -p ${UTPLSQL_VERSION} - rm -rf ${UTPLSQL_VERSION}/**./* || exit 0 - cp -a ../docs/. ${UTPLSQL_VERSION} - echo "Populating 'latest' directory" - mkdir -p latest - rm -rf latest/**./* || exit 0 - cp -a ../docs/. latest - fi - # Stage changes for commit - git add . - #Check if there are doc changes, if none exit the script - if [[ -z `git diff HEAD --exit-code` ]] && [ -n "${PAGES_BRANCH_EXISTS}" ] ; then - echo "No changes to docs detected." - exit 0 - fi - #Changes where detected, so we need to update the version log. - now=$(date +"%d %b %Y - %r") - if [ ! -f index.md ]; then - echo "---" >>index.md - echo "layout: default" >>index.md - echo "---" >>index.md - echo "" >>index.md - echo "# Documentation versions" >>index.md - echo "" >>index.md - echo "" >>index.md #- 7th line - placeholder for latest release doc - echo "" >>index.md #- 8th line - placeholder for develop branch doc - echo "" >>index.md - echo "## Released Version Doc History" >>index.md - echo "" >>index.md - fi - #If build running on a TAG - it's a new release - need to add it to documentation - if [ -n "${TRAVIS_TAG}" ]; then - sed -i '7s@.*@'" - [Latest ${TRAVIS_TAG} documentation](latest/) - Created $now"'@' index.md - #add entry to the top of version history (line end of file - ## Released Version Doc History - sed -i '12i'" - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md - fi - #replace 4th line in log - sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md - #Add and Commit the changes back to pages repo. - git add . - git commit -m "Deploy to gh-pages branch: base commit ${SHA}" - # Now that we're all set up, we can push. - git push --quiet origin HEAD:${PAGES_TARGET_BRANCH} -fi - diff --git a/.travis/push_release_version.sh b/.travis/push_release_version.sh deleted file mode 100755 index 082359af4..000000000 --- a/.travis/push_release_version.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -# We are updating version number only when: -# - not a pull request -# - branch name is = develop or branch name is like release/vX.X.X... -if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [[ "${CURRENT_BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|develop)$ ]]; then - echo Current branch is "${CURRENT_BRANCH}" - echo "Committing version & buildNo into branch (${CURRENT_BRANCH})" - git add sonar-project.properties - git add VERSION - git add source/* - git add docs/* - git commit -m 'Updated project version after build [skip ci]' - echo "Pushing to origin" - git push --quiet origin HEAD:${CURRENT_BRANCH} -else - echo "Publishing of version skipped for branch ${CURRENT_BRANCH}, pull request ${TRAVIS_PULL_REQUEST}" -fi diff --git a/.travis/run_examples.sh b/.travis/run_examples.sh deleted file mode 100755 index 967b621c7..000000000 --- a/.travis/run_examples.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -ev - -"$SQLCLI" $UT3_OWNER/$UT3_OWNER_PASSWORD@//$CONNECTION_STR <> sonar-project.properties -} - - -if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - BRANCH=$TRAVIS_BRANCH; - PR_BRANCH="" - echo "BRANCH=$BRANCH" -else - BRANCH=$TRAVIS_PULL_REQUEST_BRANCH - PR_BRANCH=$TRAVIS_BRANCH - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST, BRANCH=$BRANCH" - -fi - - -#Are we running on utPLSQL repo and not an external PR? -echo "Check if we running from develop or on branch" -if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then - - echo "" >> sonar-project.properties - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - echo "Updating sonar properties to include branch ${BRANCH}" - add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" - add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}" - elif [ "${TRAVIS_PULL_REQUEST_SLUG}" = "${TRAVIS_REPO_SLUG}" ]; then - echo "Updating sonar properties to include pull request ${BRANCH}" - add_sonar_property "${PR_SONAR_TOKEN_PROPERTY}" "${GITHUB_TRAVISCI_TOKEN}" - add_sonar_property "${PR_SONAR_BRANCH_PROPERTY}" "${BRANCH}" - add_sonar_property "${PR_KEY_PROPERTY}" "${PR}" - add_sonar_property "${PR_SONAR_BASE_PROPERTY}" "${PR_BRANCH}" - else - echo "PR from external source no changes to properties." - fi -else - echo "No need to update sonar we building on release or develop" -fi - -#Address issue : Could not find ref 'develop' in refs/heads or refs/remotes/origin -git fetch --no-tags https://github.com/utPLSQL/utPLSQL.git +refs/heads/develop:refs/remotes/origin/develop - -echo "Adding OJDBC Driver Path ${OJDBC_HOME}/ojdbc8.jar" -add_sonar_property "${DB_URL_SONAR_PROPERTY}" "jdbc:oracle:thin:@${CONNECTION_STR}" -add_sonar_property "${DB_DRIVER_PATH}" "${OJDBC_HOME}/ojdbc8.jar" - - -#Execute Sonar scanner -echo "Executing sonar scanner" -sonar-scanner diff --git a/.travis/settings.xml b/.travis/settings.xml deleted file mode 100644 index 731ef5298..000000000 --- a/.travis/settings.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - maven.oracle.com - ${env.ORACLE_OTN_USER} - ${env.ORACLE_OTN_PASSWORD} - - - ANY - ANY - OAM 11g - - - - - - http.protocol.allow-circular-redirects - %b,true - - - - - - - - - diff --git a/.travis/start_db.sh b/.travis/start_db.sh deleted file mode 100755 index e42656987..000000000 --- a/.travis/start_db.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -# Private Repo Login -if [ ! -f $CACHE_DIR/.docker/config.json ]; then - docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD" - mkdir -p $CACHE_DIR/.docker && cp $HOME/.docker/config.json $CACHE_DIR/.docker/ -else - echo "Using docker login from cache..." - mkdir -p $HOME/.docker && cp $CACHE_DIR/.docker/config.json $HOME/.docker/ -fi - -df -h -time docker pull $DOCKHER_HUB_REPO:$ORACLE_VERSION -df -h -docker run -d --name $ORACLE_VERSION $DOCKER_OPTIONS -p 1521:1521 $DOCKHER_HUB_REPO:$ORACLE_VERSION -time docker logs -f $ORACLE_VERSION | grep -m 1 "DATABASE IS READY TO USE!" --line-buffered -df -h diff --git a/.travis/trigger_travis.sh b/.travis/trigger_travis.sh deleted file mode 100755 index 039b00bbb..000000000 --- a/.travis/trigger_travis.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# Trigger a new Travis-CI job. -# Ordinarily, a new Travis job is triggered when a commit is pushed to a -# GitHub repository. The trigger-travis.sh script provides a programmatic -# way to trigger a new Travis job. - -# To use this script to trigger a dependent build in Travis, do two things: -# -# 1. Set an environment variable TRAVIS_ACCESS_TOKEN by navigating to -# https://travis-ci.org/MYGITHUBID/MYGITHUBPROJECT/settings -# The TRAVIS_ACCESS_TOKEN environment variable will be set when Travis runs -# the job, but won't be visible to anyone browsing https://travis-ci.org/. -# - -echoerr() { echo "$@" 1>&2; } - -TRAVIS_URL=travis-ci.org -BRANCH=develop -USER="utPLSQL" -RESULT=1 -declare -a REPO_MATRIX=("utPLSQL-java-api" "utPLSQL-v2-v3-migration" "utPLSQL-cli" "utPLSQL-maven-plugin" "utPLSQL-demo-project") - -TOKEN=$1 - -if [ -n "$TRAVIS_REPO_SLUG" ] ; then - MESSAGE=",\"message\": \"Triggered by upstream build of $TRAVIS_REPO_SLUG commit "`git rev-parse --short HEAD`"\"" -else - MESSAGE=",\"message\": \"Triggered manually from shell\"" -fi - -# For debugging: -#echo "MESSAGE=$MESSAGE" - -body="{ -\"request\": { - \"branch\":\"$BRANCH\" - $MESSAGE -}}" - -for DOWNSTREAM_BUILD in "${REPO_MATRIX[@]}"; do - - curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "Accept: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Authorization: token ${TOKEN}" \ - -d "$body" \ - https://api.${TRAVIS_URL}/repo/${USER}%2F${DOWNSTREAM_BUILD}/requests \ - | tee ${DOWNSTREAM_BUILD}-output.txt - - if grep -q '"@type": "error"' ${DOWNSTREAM_BUILD}-output.txt; then - RESULT=0 - echoerr "" - echoerr "ERROR: Failed to start ${DOWNSTREAM_BUILD}" - echoerr "" - fi - if grep -q 'access denied' ${DOWNSTREAM_BUILD}-output.txt; then - RESULT=0 - echoerr "" - echoerr "ERROR: Failed to start ${DOWNSTREAM_BUILD} - access denied" - echoerr "" - fi - -done - -if [[ RESULT -eq 0 ]]; then - exit 1 -fi diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..85f8cd5b1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,66 @@ +# Agent instructions + +## Project context + +This repository contains utPLSQL, a unit-testing framework for Oracle PL/SQL. +Preserve compatibility with the Oracle versions and public APIs supported by +the project. + +## Before making changes + +- Read `CONTRIBUTING.md` and follow its coding standards, engineering + principles, refactoring guidance, and testing requirements. +- Inspect the relevant package specification, package body, and tests before + editing. +- Keep changes focused on the requested behavior. +- Check whether the change touches CBAC, SQL macros, install order, or supported + Oracle versions. Follow the relevant guidance in `CONTRIBUTING.md`. + +## PL/SQL changes + +- Treat package specifications and documented behavior as public interfaces. +- Match the naming, formatting, and error-handling patterns in nearby code. +- Add or update tests for behavior changes, following existing test patterns. +- Do not introduce a new data representation or change public interfaces unless + the task calls for it. + +## Performance work + +- Compare results using the same Oracle version, environment, and workload. +- Report the measurements and conditions used. Do not present an unmeasured + performance improvement as established. + +## Security and quality + +- For security-sensitive changes, consider input validation, dynamic SQL, + schema and object name handling, and privilege boundaries. Follow the + existing security patterns in the relevant code. +- If you identify a possible security vulnerability, follow the repository's + private security-reporting process, if one is documented. Do not disclose it + in a public issue or pull request. +- If the project's CI runs SonarQube or SonarCloud, report its result when + available. Do not introduce new Sonar requirements or claim a scan passed + unless it was run. + +## Local environment and safety + +- Treat `development/env.sh` as local configuration. Do not commit it or expose + its credentials in output. +- Treat the directory configured by `UTPLSQL_DIR` as a read-only upstream + reference for self-testing. Do not make feature changes there; make them + under `source/` and `test/`. `development/refresh_sources.sh` deletes and + recreates the configured directory. +- Before running database tests, check that the local environment is configured + as described in `CONTRIBUTING.md`. +- Do not remove or recreate the local database container without explicit + authorization, because doing so deletes its contents. +- Do not edit generated version strings in `source/`, `VERSION`, or `BUILD_NO`. + +## Verification + +- Use commands documented in `CONTRIBUTING.md`; do not guess at project + commands. +- Run the narrowest relevant checks first. +- Report which relevant checks you ran and their results. If a check could not + be run, say which one and why. +- Do not claim a check passed unless it was actually run. diff --git a/BUILD_NO b/BUILD_NO new file mode 100644 index 000000000..ae6d06456 --- /dev/null +++ b/BUILD_NO @@ -0,0 +1 @@ +4670 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..faf1f504a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,630 @@ +# Changelog + +All notable changes to utPLSQL are documented here. +Releases are available on the [GitHub Releases page](https://github.com/utPLSQL/utPLSQL/releases). + +--- + +## [v.3.2.3] - 2026-07-10 + +## What's Changed +* Fix issue with `UT_TAP_REPORTER` on Oracle 23.26 by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1359 +* Fixed support for camelCase in context `--%name` annotation. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1361 +* utPLSQL can be installed in editioned schema. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1362 +* Removed coveralls reporter by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1363 +* Clarify behavior of before/after procedures in suitepath by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1364 +* `throws` can reference exception without schema or package name by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1365 +* `throws` works with uninitialized exception variables by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1366 + + +**Full Changelog**: https://github.com/utPLSQL/utPLSQL/compare/v3.2.2...v.3.2.3 + +--- + + +## [v3.2.2] - 2026-05-24 + +## What's Changed +* Filtering by tags fixed for schemas containing suite-paths and contexts by @jgebal in [1325](https://github.com/utPLSQL/utPLSQL/pull/1325) +* Fixed issue with reporter failing to initialize by @jgebal in [1354](https://github.com/utPLSQL/utPLSQL/pull/1354) +* Fixed issue with duplicate sources from dba_source by @jgebal in [1355](https://github.com/utPLSQL/utPLSQL/pull/1355) +* Allow HTML coverage on FIPS-enabled DB by @jgebal in [1356](https://github.com/utPLSQL/utPLSQL/pull/1356) + + +**Full Changelog**: https://github.com/utPLSQL/utPLSQL/compare/v3.2.01...v3.2.2 + +--- + +## [v3.2.01] - 2026-04-22 + +## Important + - Dropped support for Oracle Database versions older than 19c + +## New features + - Add TAP reporter by @WayneNani in [#1305](https://github.com/utPLSQL/utPLSQL/pull/1305) + +## Enhancements and bug fixes + - Added duplicate detection on cursor comparison using `join_by` by @lwasylow in [#1295](https://github.com/utPLSQL/utPLSQL/pull/1295) + - Fix code causing the object duration Oracle exception on oracle 23.26 by @lwasylow in [#1310](https://github.com/utPLSQL/utPLSQL/pull/1310) + - Packages with annotation-like comments are not test suites by @jgebal in [#1313](https://github.com/utPLSQL/utPLSQL/pull/1313) + - Performance improvements to annotation parsing by @lwasylow in [#1312](https://github.com/utPLSQL/utPLSQL/pull/1319) + - Updated documentation and copyright banners across source files @jgebal in [#1319](https://github.com/utPLSQL/utPLSQL/pull/1319) + +--- + +## [v3.1.14] - 2024-02-19 + +## New features + + - Added support for `and` and `or` operators when running tests by tags by @lwasylow in [#1250](https://github.com/utPLSQL/utPLSQL/pull/1250) + +## Enhancements + + - Allow for test runs over 4 hours by @jgebal in [#1243](https://github.com/utPLSQL/utPLSQL/pull/1243) + - Framework performance improvements by @jgebal in [#1249](https://github.com/utPLSQL/utPLSQL/pull/1249) + - Support multiple expectation failures with teamcity reporter by @jgebal in [#1251](https://github.com/utPLSQL/utPLSQL/pull/1251) + - Update TFS reporter to correct format by @lwasylow in [#1270](https://github.com/utPLSQL/utPLSQL/pull/1270) + +## Bug fixes + + - Address issue where the `not_to(contain)` did not run correctly by @lwasylow in [#1246](https://github.com/utPLSQL/utPLSQL/pull/1246) + - Fix regex to be NLS_SORT independent by @jgebal in [#1253](https://github.com/utPLSQL/utPLSQL/pull/1253) + - Fix output length error and output buffer. by @jgebal in [#1255](https://github.com/utPLSQL/utPLSQL/pull/1255) + - (docs): Update running-unit-tests.md - remove example by @gassenmj in [#1261](https://github.com/utPLSQL/utPLSQL/pull/1261) + - The line-rate is not recorded for packages and classes in cobertura coverage reporter by @lwasylow in [#1269](https://github.com/utPLSQL/utPLSQL/pull/1269) + - (docs): Fix nested list issue by @iamrachid in [#1274](https://github.com/utPLSQL/utPLSQL/pull/1274) + +--- + +## [v3.1.13] - 2022-12-11 + +## New features + + - Add ability to run tests by part of a name. Fixed in [#1203](https://github.com/utPLSQL/utPLSQL/pull/1203), resolves [#470](https://github.com/utPLSQL/utPLSQL/issues/470) + +## Enhancements + + - Added documentation section on creating a custom reporter. Fixed in [#1225](https://github.com/utPLSQL/utPLSQL/pull/1225), resolves [#710](https://github.com/utPLSQL/utPLSQL/issues/701) + - Add ability to specify code coverage objects include/exclude masks as regular expressions. Fixed in [#1186](https://github.com/utPLSQL/utPLSQL/issues/1186), resolves [#1053](https://github.com/utPLSQL/utPLSQL/issues/1053) + +## Bug fixes + + - Comparing collection that have long type names. Fixed in [#1238](https://github.com/utPLSQL/utPLSQL/issues/1238), resolves [#1235](https://github.com/utPLSQL/utPLSQL/issues/1235). + - Code coverage reporting on code with long lines. Fixed in [#1240](https://github.com/utPLSQL/utPLSQL/issues/1240), resolves [#1232](https://github.com/utPLSQL/utPLSQL/issues/1232), [#1087](https://github.com/utPLSQL/utPLSQL/issues/1087). + - Code coverage reporting does not exclude tests. Fixed in [#1226](https://github.com/utPLSQL/utPLSQL/issues/1226), resolves [#1222](https://github.com/utPLSQL/utPLSQL/issues/1222). + - Uninstall script buffer overflow. Fixed in [#1221](https://github.com/utPLSQL/utPLSQL/issues/1221), resolves [#1220](https://github.com/utPLSQL/utPLSQL/issues/1220). + +## Internal improvements + + - Improved process of generating utPLSQL documentation. Implemented in [689bbd0](https://github.com/utPLSQL/utPLSQL/commit/689bbd0e365ed919315c29727bc10fbfc0dadce8), resolves [#1237](https://github.com/utPLSQL/utPLSQL/issues/1237). + - Removed username env variables for internal development. Implemented in [#1201](https://github.com/utPLSQL/utPLSQL/issues/1221), resolves [#1200](https://github.com/utPLSQL/utPLSQL/issues/1200). + - Test execution data of utPLSQL project not showing on SonarCloud. Implemented in [#1199](https://github.com/utPLSQL/utPLSQL/issues/1199), resolves [#1198](https://github.com/utPLSQL/utPLSQL/issues/1198). + +--- + +## [v3.1.12] - 2022-02-25 + +## New features + - Added support for description in the `--%disabled` annotation. See [documentation](https://github.com/utPLSQL/utPLSQL/blob/4515e0b5a3b4b0de0c2198db3235ef8614bff4d8/docs/userguide/annotations.md#disabled). Implemented in: [#1183](https://github.com/utPLSQL/utPLSQL/pull/1183), resolves [#610](https://github.com/utPLSQL/utPLSQL/issues/610). + - Added support for native `JSON` datatype on Oracle `21c`. Implemented in [#1181](https://github.com/utPLSQL/utPLSQL/pull/1181), resolves [#1114](https://github.com/utPLSQL/utPLSQL/issues/1114). + - Added new mather `to_be_within( distance|pct ).of_(expoected)`. See [documentation](https://github.com/utPLSQL/utPLSQL/blob/fd7ef9c14111a48e03fff7851f990c7192539170/docs/userguide/expectations.md#to_be_within-of). Implemented in [#1076](https://github.com/utPLSQL/utPLSQL/pull/1076), resolves [#77](https://github.com/utPLSQL/utPLSQL/issues/77). + +## Enhancements + +- Improved performance of SQL used to retrieve Coverage sources. Implemented in [#1187](https://github.com/utPLSQL/utPLSQL/pull/1187), resolves [#1169](https://github.com/utPLSQL/utPLSQL/issues/1169). +- Added ability for utPLSQL to gather coverage on code invoking DBMS_STATS package. Implemented in [#1184](https://github.com/utPLSQL/utPLSQL/pull/1184), resolves [#1097](https://github.com/utPLSQL/utPLSQL/issues/1097), [#1094](https://github.com/utPLSQL/utPLSQL/issues/1094). +- Fixed typos and improved documentation. Implemented in [#1173](https://github.com/utPLSQL/utPLSQL/pull/1173), [#1171](https://github.com/utPLSQL/utPLSQL/pull/1171) + +## Bug fixes + +- Actual and Expected are now correctly reported when comparing `JSON` data. Implemented in [#1181](https://github.com/utPLSQL/utPLSQL/pull/1181), resolves [#1113](https://github.com/utPLSQL/utPLSQL/issues/1113). +- Packages with removed annotations are now correctly recognized as non-utPLSQL packages. Implemented in [#1180](https://github.com/utPLSQL/utPLSQL/pull/1180), resolves [#1177](https://github.com/utPLSQL/utPLSQL/issues/1177). +- Fixed issues with comparison of nested object structures. Implemented in [#1179](https://github.com/utPLSQL/utPLSQL/pull/1179), resolves [#1082](https://github.com/utPLSQL/utPLSQL/issues/1082), [#1083](https://github.com/utPLSQL/utPLSQL/issues/1083), [#1098](https://github.com/utPLSQL/utPLSQL/issues/1098). + +## Internal improvements + +- Moved build and test process for utPLSQL from Travis to GithubActions. Implemented in [#1175](https://github.com/utPLSQL/utPLSQL/pull/1175) + +--- + +## [v3.1.11] - 2021-11-17 + +## Enhancements + +- utPLSQL can now be used to generate coverage reports for external tools. See [documentation](https://github.com/utPLSQL/utPLSQL/blob/955de5c2dc527a98a6f5dc0dd8bd8d81a44c459f/docs/userguide/coverage.md#reporting-coverage-outside-of-utplsql) + Implemented in: [#1079](https://github.com/utPLSQL/utPLSQL/pull/1079), resolves [#1025](https://github.com/utPLSQL/utPLSQL/issues/1025) +- Enhanced UT_COVERAGE_COBERTURA_REPORTER to better support TFS and GitLab. Implemented in [#1137](https://github.com/utPLSQL/utPLSQL/pull/1137) and [#1140](https://github.com/utPLSQL/utPLSQL/pull/1140), resolves [#1107](https://github.com/utPLSQL/utPLSQL/issues/1107) +- Added support for installation on Oracle 21c - removed dependency on DBMS_OBFUSCATION_TOOLKIT. Implemented in [#1112](https://github.com/utPLSQL/utPLSQL/pull/1112), resolves [#1111](https://github.com/utPLSQL/utPLSQL/issues/1111) and [#1127](https://github.com/utPLSQL/utPLSQL/issues/1127) +- Added support for running utPLSQL framework in parallel-enabled database. Implemented in [#1160](https://github.com/utPLSQL/utPLSQL/pull/1160), resolves [#1134](https://github.com/utPLSQL/utPLSQL/issues/1134) + +## Bug fixes + +- Suite structure is built properly even with other than English TNS settings. Implemented in [#1061](https://github.com/utPLSQL/utPLSQL/pull/1061), resolves [#1060](https://github.com/utPLSQL/utPLSQL/issues/1060) +- Fixed XML content reporting (CDATA) in UT_REALTIME_REPORTER used by SQLDeveloper plugin. Implemented in [#1075](https://github.com/utPLSQL/utPLSQL/pull/1075), resolves [#1073](https://github.com/utPLSQL/utPLSQL/issues/1073) +- Fixed XML content reporting (CDATA) in JUnit reporter - regression. Implemented in [#1085](https://github.com/utPLSQL/utPLSQL/pull/1085), resolves [#1084](https://github.com/utPLSQL/utPLSQL/issues/1084) +- Fixed issue with utPLSQL failing to run coverage reporting when trigger has overlapping name with procedure/function/package/type. Implemented in [#1091](https://github.com/utPLSQL/utPLSQL/pull/1091), resolves [#1086](https://github.com/utPLSQL/utPLSQL/issues/1086) +- Fixed issue with parsing utPLSQL suites with DDL trigger when usign AUTHID clause. Implemented in [#1093](https://github.com/utPLSQL/utPLSQL/pull/1093), resolves [#1088](https://github.com/utPLSQL/utPLSQL/issues/1088) + +## Internal improvements + +- Improved how privilege checks are handled by framework installation. Implemented in [#1056](https://github.com/utPLSQL/utPLSQL/pull/1056), resolves [#1050](https://github.com/utPLSQL/utPLSQL/issues/1050) +- Restructured installation instructions to make it more readable. Implemented in [#1063](https://github.com/utPLSQL/utPLSQL/pull/1063), resolves [#1062](https://github.com/utPLSQL/utPLSQL/issues/1062) +- Updated database requirements in documentation. Implemented in [#1065](https://github.com/utPLSQL/utPLSQL/pull/1065), resolves [#1064](https://github.com/utPLSQL/utPLSQL/issues/1064) +- Removed duplicated call to install profiler tables. Implemented in [#1164](https://github.com/utPLSQL/utPLSQL/pull/1164), resolves [#1149](https://github.com/utPLSQL/utPLSQL/issues/1149) +- Fixed failing internal framework tests on Oracle 21c. Implemented in [#1158](https://github.com/utPLSQL/utPLSQL/pull/1158), resolves [#1151](https://github.com/utPLSQL/utPLSQL/issues/1151) +- Fixed confusing typo in documentation. Resolves [#1154](https://github.com/utPLSQL/utPLSQL/issues/1154) +- Moved build process from travis-ci.org to travis-ci.com. Implemented in [#1152](https://github.com/utPLSQL/utPLSQL/pull/1152) +- Added an example of reporter reporting all expectations, not only the failing ones. Implemented in [#1092](https://github.com/utPLSQL/utPLSQL/pull/1092) + +--- + +## [v3.1.10] - 2020-02-23 + +## Enhancements + +- utPLSQL test runner is now validating arguments of `--%throws` annotations at runtime [#721](https://github.com/utPLSQL/utPLSQL/issues/721) [#1033](https://github.com/utPLSQL/utPLSQL/issues/1033) +- Documented limitations of insignificant spaces comparison in compound data [#880](https://github.com/utPLSQL/utPLSQL/issues/880) +- utPLSQL will now detect empty annotation cache for schema even with DLL trigger enabled [#975](https://github.com/utPLSQL/utPLSQL/issues/975) +- Order of procedures and annotation now determines default order of tests in suite [#1036](https://github.com/utPLSQL/utPLSQL/issues/1036) + +## Bug fixes + +- Nested contexts are now properly identified [#1034](https://github.com/utPLSQL/utPLSQL/issues/1034) +- TeamCity test reporter is now including error message [#1045](https://github.com/utPLSQL/utPLSQL/issues/1045) + +## Internal improvements + +- All self-tests for utPLSQL framework can now be executed using test-owner schema [#969](https://github.com/utPLSQL/utPLSQL/issues/969) +- Misleading rollback warning is no longer showing when running self-tests for utPLSQL [#982](https://github.com/utPLSQL/utPLSQL/issues/982) + +--- + +## [v3.1.9] - 2019-11-10 + +## New features + +- Added ability to define [nested contexts](https://github.com/utPLSQL/utPLSQL/blob/v3.1.9/docs/userguide/annotations.md#context) within test suite [#938](https://github.com/utPLSQL/utPLSQL/issues/938) +- Added ability to [exclude tests/suites by tags](https://github.com/utPLSQL/utPLSQL/blob/v3.1.9/docs/userguide/annotations.md#excluding-testssuites-by-tags) when invoking a test-run [#1007](https://github.com/utPLSQL/utPLSQL/issues/1007) [#983](https://github.com/utPLSQL/utPLSQL/issues/983) +- Added new annotation [`--%name`](https://github.com/utPLSQL/utPLSQL/blob/v3.1.9/docs/userguide/annotations.md#name) to allow for providing custom name for contexts [#1016](https://github.com/utPLSQL/utPLSQL/issues/1016) + +## Important changes + +The value of `--%context` annotation is no longer representing context `name`. +This value is now context description (displayname). +With this change, the `--%context` annotation is now aligned with `--%test` and `--%suite` annotation syntax. + +New annotation `--%name` was introduced to facilitate naming of contexts. + +## Enhancements + +- Improved documentation for running tests +- Improved documentation for tags [#1003](https://github.com/utPLSQL/utPLSQL/issues/1003) +- Improved documentation for annotations + +## Bug fixes + +- Fixed bug with bad stacktrace showing in failing/erroring test [#1000](https://github.com/utPLSQL/utPLSQL/issues/1000) +- Fixed issue with lack of validation for context name [#966](https://github.com/utPLSQL/utPLSQL/issues/966) +- Fixed problem with install script privilege check for installation with DDL trigger [#992](https://github.com/utPLSQL/utPLSQL/issues/992) +- Fixed issue with some common column names causing cursor comparison to fail [#997](https://github.com/utPLSQL/utPLSQL/issues/997) +- Fixed issue with invocation of standalone expectations on cursor [#998](https://github.com/utPLSQL/utPLSQL/issues/998) + +## Internal improvements + +- Fixed runability of utplsql self-tests [#968](https://github.com/utPLSQL/utPLSQL/issues/968) + +--- + +## [v3.1.8] - 2019-09-03 + +## New features + +- Added support for [session context](https://github.com/utPLSQL/utPLSQL/blob/v3.1.8/docs/userguide/annotations.md#sys_context) to provide test and suite information during test run [#963](https://github.com/utPLSQL/utPLSQL/issues/963) [#781](https://github.com/utPLSQL/utPLSQL/issues/781) +- Added ability to [invoke expectations without running framework](https://github.com/utPLSQL/utPLSQL/blob/v3.1.8/docs/userguide/expectations.md#running-expectations-outside-utplsql-framework) [#956](https://github.com/utPLSQL/utPLSQL/issues/956) [#963](https://github.com/utPLSQL/utPLSQL/issues/963) +- Failing expectations are now reported with call stack [#967](https://github.com/utPLSQL/utPLSQL/issues/967) [#963](https://github.com/utPLSQL/utPLSQL/issues/963) + +## Enhancements + +- Improved framework table private data protection [#922](https://github.com/utPLSQL/utPLSQL/issues/922) [#954](https://github.com/utPLSQL/utPLSQL/issues/954) +- Improved install process. It is now unified for installation with both public and private synonyms [#957](https://github.com/utPLSQL/utPLSQL/issues/957) [#954](https://github.com/utPLSQL/utPLSQL/issues/954) +- Improved reporting of warnings for integration with SQLDeveloper [#964](https://github.com/utPLSQL/utPLSQL/issues/964) +- Improved query to retrieve coverage sources [#981](https://github.com/utPLSQL/utPLSQL/issues/981) [#970](https://github.com/utPLSQL/utPLSQL/issues/970) +- Improved security around malicious utPLSQL owner name [#920](https://github.com/utPLSQL/utPLSQL/issues/920) + +## Bug fixes + +- Fixed cursor comparison on Oracle 11.2 [#947](https://github.com/utPLSQL/utPLSQL/issues/947) +- Fixed issue with retrieving suite data [#977](https://github.com/utPLSQL/utPLSQL/issues/977) [#974](https://github.com/utPLSQL/utPLSQL/issues/974) [#978](https://github.com/utPLSQL/utPLSQL/issues/978) +- Application context is now reset in session after test run [#951](https://github.com/utPLSQL/utPLSQL/issues/951) + +--- + +## [v3.1.7] - 2019-06-18 + +## New features + +- Added support for [comparing `json`](https://github.com/utPLSQL/utPLSQL/blob/v3.1.7/docs/userguide/expectations.md#comparing-json-objects) in Oracle 12.2 and above [#924](https://github.com/utPLSQL/utPLSQL/issues/924) +- Introduced [`tag` annotation](https://github.com/utPLSQL/utPLSQL/blob/v3.1.7/docs/userguide/annotations.md#tags) to enable tagging of tests and suites [#66](https://github.com/utPLSQL/utPLSQL/issues/66) +- Added support for [random order](https://github.com/utPLSQL/utPLSQL/blob/v3.1.7/docs/userguide/running-unit-tests.md#random-order) of test execution [#422](https://github.com/utPLSQL/utPLSQL/issues/422) + +## Enhancements + +- Added optional [install with DDL trigger](https://github.com/utPLSQL/utPLSQL/blob/v3.1.7/docs/userguide/install.md#installation-with-ddl-trigger) to speed up framework start [#901](https://github.com/utPLSQL/utPLSQL/issues/901) +- Removed dependency on `dbms_utility.name_resolve` [#569](https://github.com/utPLSQL/utPLSQL/issues/569) [#885](https://github.com/utPLSQL/utPLSQL/issues/885) +- New output buffer table structures improving performance and addressing timeout issues [#915](https://github.com/utPLSQL/utPLSQL/issues/915) + +## Bug fixes + +- Fixed `ut_realtime_reporter` missing warnings in test and suite output structures [#936](https://github.com/utPLSQL/utPLSQL/issues/936) +- Fixed output_buffer purging error [#934](https://github.com/utPLSQL/utPLSQL/issues/934) +- Fixed `join_by / exclude / include` invalid syntax on collection in anydata compare [#912](https://github.com/utPLSQL/utPLSQL/issues/912) +- Fixed `ut_junit_reporter` producing invalid output on failing tests with long failure message [#927](https://github.com/utPLSQL/utPLSQL/issues/927) +- Fixed `ut_sonar_test_reporter` producing invalid output on failing tests with long failure message [#925](https://github.com/utPLSQL/utPLSQL/issues/925) +- Fixed `ut_coverage_cobertura_reporter` producing wrong line breaks which breaks the xml validation against DTD [#917](https://github.com/utPLSQL/utPLSQL/issues/917) +- Fixed `exclude` option for ref cursor where column order was not resolved correctly [#911](https://github.com/utPLSQL/utPLSQL/issues/911) +- Fixed `unordered` option for ref cursor with null values [#914](https://github.com/utPLSQL/utPLSQL/issues/914) +- Fixed number precision when selecting from dual [#907](https://github.com/utPLSQL/utPLSQL/issues/907) +- Fixed ref cursor errors with generated column names [#902](https://github.com/utPLSQL/utPLSQL/issues/902) +- Fixed `ORA-00907` when comparing ref cursors with BINARY_ columns [#899](https://github.com/utPLSQL/utPLSQL/issues/899) +- Fixed wrong results when comparing CLOBs with `to_be_like` in Oracle Database 11.2.0.4 due to Oracle Bug 14402514 [#891](https://github.com/utPLSQL/utPLSQL/issues/891) +- Fixed performance issue with code coverage report on huge PL/SQL code base [#882](https://github.com/utPLSQL/utPLSQL/issues/882) + +## Documentation improvements + +- Added install instructions for DDL trigger [#874](https://github.com/utPLSQL/utPLSQL/issues/874) + +## Internal enhancements + +- Fixed SQL vulnerability on all input parameters used in dynamic SQL and PL/SQL [#921](https://github.com/utPLSQL/utPLSQL/issues/921) +- Fixed message id in output buffer [#916](https://github.com/utPLSQL/utPLSQL/issues/916) +- Included 19c database in self testing [#909](https://github.com/utPLSQL/utPLSQL/issues/909) +- Introduced testing with multiple schemas and different grants [#893](https://github.com/utPLSQL/utPLSQL/issues/893) +- Fixed installation script warnings [#879](https://github.com/utPLSQL/utPLSQL/issues/879) + +--- + +## [v3.1.6] - 2019-03-24 + +Bugfix release for `v3.1.5` + +## Bug fixes + +- Fixed a bug in release `3.1.5` where `to_equal` matcher was failing due to privileges when comparing non sql diffable types [#870](https://github.com/utPLSQL/utPLSQL/issues/870) + +## Improvements +- Reduced number of information displaying about user defined type. We will now display only type name instead of full structure [#866](https://github.com/utPLSQL/utPLSQL/issues/866) + +--- + +## [v3.1.5] - 2019-03-20 + +Bugfix release for `v3.1.4` + +## Bug fixes + +- Fixed a bug in release `3.1.4` where `to_be_empty` matcher was failing due to privileges [#864](https://github.com/utPLSQL/utPLSQL/issues/864) + +--- + +## [v3.1.4] - 2019-03-19 + +**This release contains a bug that is fixed by release 3.1.5** +Please use release 3.1.5 rather than this release. + +## New features + +- Added `to_contain` matcher for collections and cursors [#79](https://github.com/utPLSQL/utPLSQL/issues/79) +- Added `unordered_columns` (`uc`) option for cursor comparison to ignore the order of the columns [#779](https://github.com/utPLSQL/utPLSQL/issues/779) +- Added `ut_debug_reporter` for debug logging [#480](https://github.com/utPLSQL/utPLSQL/issues/480) +- Added `ut_realtime_reporter` for utPLSQL-SQLDeveloper extension [#795](https://github.com/utPLSQL/utPLSQL/issues/795) + +## Important Changes + +- Due to improvements of the cursor comparison, it is now necessary to use `ut.set_nls()` before creating the cursor and `ut.reset_nls()` after the __expectation__ when comparing dates. [More info in the docs](https://github.com/utPLSQL/utPLSQL/blob/v3.1.4/docs/userguide/expectations.md#comparing-cursor-data-containing-date-fields) + +## Enhancements + +- Improved performance of cursor comparison [#780](https://github.com/utPLSQL/utPLSQL/issues/780) +- Added support for installation on databases with block size < 8KB [#848](https://github.com/utPLSQL/utPLSQL/issues/848) +- Added initial timeout to `ut_output_buffer` [#840](https://github.com/utPLSQL/utPLSQL/issues/840) +- Enhanced performance of `get_reporters_list` function [#814](https://github.com/utPLSQL/utPLSQL/issues/814) +- Moved calls of `dbms_lock.sleep` to `dbms_session` for newer DB versions [#806](https://github.com/utPLSQL/utPLSQL/issues/806) +- utPLSQL coverage will now work without re-install after DB-upgrade from 12.1 to 12.2 [#803](https://github.com/utPLSQL/utPLSQL/issues/803) + +## Bug fixes + +- Fixed problem with REGEXP in annotation parsing with NLS CANADIAN FRENCH [#844](https://github.com/utPLSQL/utPLSQL/issues/844) +- Fixed issue with Rollback to savepoint failing on distributed transaction [#839](https://github.com/utPLSQL/utPLSQL/issues/839) +- Fixed reporting of differences when comparing collections scalar values [#835](https://github.com/utPLSQL/utPLSQL/issues/835) +- Fixed issue with test run failing due to too many transaction invalidators [#834](https://github.com/utPLSQL/utPLSQL/issues/834) +- Fixed randomly occurring error during cursor comparison [#827](https://github.com/utPLSQL/utPLSQL/issues/827) +- utPLSQL install script will now support special characters in passwords [#804](https://github.com/utPLSQL/utPLSQL/issues/804) + +## Documentation improvements + +- Fixed documentation examples for context annotation [#851](https://github.com/utPLSQL/utPLSQL/issues/851) +- Added description on how to check version of utPLSQL [#822](https://github.com/utPLSQL/utPLSQL/issues/822) + +## Internal enhancements + +- Implemented Sonar analysis on DBA Views [#850](https://github.com/utPLSQL/utPLSQL/issues/850) +- Finished migration from old-tests [#475](https://github.com/utPLSQL/utPLSQL/issues/475) +- Fixed shell scripts to support multiple unix dialects (especially for macOS) [#796](https://github.com/utPLSQL/utPLSQL/issues/796) +- Added info on project support from Redgate [#841](https://github.com/utPLSQL/utPLSQL/issues/841) +- Added `code_of_conduct` [#836](https://github.com/utPLSQL/utPLSQL/issues/836) +- Added issue templates [#842](https://github.com/utPLSQL/utPLSQL/issues/842) +- Added utPLSQL logo [#845](https://github.com/utPLSQL/utPLSQL/issues/845) + +--- + +## [v3.1.3] - 2018-11-20 + +## New features + +- added function `ut_runner.is_test` [#788](https://github.com/utPLSQL/utPLSQL/issues/788) +- added function `ut_runner.is_suite` [#787](https://github.com/utPLSQL/utPLSQL/issues/787) +- added function `ut_runner.has_suites` [#786](https://github.com/utPLSQL/utPLSQL/issues/786) +- added ability to disable automatic rollback for a test-run [#784](https://github.com/utPLSQL/utPLSQL/issues/784) +- when invoked with package name, utPLSQL will now run only tests from specified package even if package has child packages by suitepath [#776](https://github.com/utPLSQL/utPLSQL/issues/776) + +## Enhancements + +- Improved performance of schema-scanning and utPLSQL startup [#778](https://github.com/utPLSQL/utPLSQL/issues/778) +- Improved performance of output-buffer [#777](https://github.com/utPLSQL/utPLSQL/issues/777) +- Improved documentation to mention ability to pass client encoding for HTML & XML reports [#775](https://github.com/utPLSQL/utPLSQL/issues/775) +- Improved documentation for cursor comparison to mention challenges with TIMESTAMP bind variables + +## Bug-fixes + +- utPLSQL code coverage will now work properly with long object names [#716](https://github.com/utPLSQL/utPLSQL/issues/716) +- utPLSQL installation will now also work properly, when user performing the install has `ANY` grants [#737](https://github.com/utPLSQL/utPLSQL/issues/737) +- fixed documentation bug for `--%context` with `--%displayname` [#726](https://github.com/utPLSQL/utPLSQL/issues/726) +- fixed Teamcity reporter issues with missing escape for some characters and long messages [#747](https://github.com/utPLSQL/utPLSQL/issues/747) +- fixed issue with sonar test results reporter when contexts are used [#749](https://github.com/utPLSQL/utPLSQL/issues/749) +- fixed issue with ORA-07455 getting thrown on cursor comparison [#752](https://github.com/utPLSQL/utPLSQL/issues/752) +- fixed issue with wrong failure message for unordered data [#764](https://github.com/utPLSQL/utPLSQL/issues/764) +- fixed missing privilege issue for unordered/join-by cursor data comparison [#765](https://github.com/utPLSQL/utPLSQL/issues/765) [#770](https://github.com/utPLSQL/utPLSQL/issues/770) + +## Internal enhancements + +- added suite-level cache to allow for faster retrieval of suite contents and enable implementation of additional features [#783](https://github.com/utPLSQL/utPLSQL/issues/783) + +--- + +## [v3.1.2] - 2018-07-22 + +## New features + +- Added ability to join and compare cursor content by specific columns (PK/UK) [#453](https://github.com/utPLSQL/utPLSQL/issues/453) +- Added support for comma separated list of suite paths/packages when calling `ut.run` [#479](https://github.com/utPLSQL/utPLSQL/issues/479) +- Added ability to run a test package that got invalidated due to dependency invalidation [#489](https://github.com/utPLSQL/utPLSQL/issues/489) +- Added support for package level constants and predefined exceptions in `--%throws` annotation [#685](https://github.com/utPLSQL/utPLSQL/issues/685) +- Added support for standalone `--%beforeall`, `--%beforeeach`, `--%afterall`, `--%aftereach` annotations with list of procedures to execute [#649](https://github.com/utPLSQL/utPLSQL/issues/649) +- Added support for list of procedure names in before/after annotations [#649](https://github.com/utPLSQL/utPLSQL/issues/649) +- Added support for BLOB/CLOB in `is_empty()` matcher [#707](https://github.com/utPLSQL/utPLSQL/issues/707) + +## Enhancements + +- utPLSQL will now provide additional warnings, when unsupported annotations are found in a unit test suite package [#624](https://github.com/utPLSQL/utPLSQL/issues/624) +- utPLSQL will now produce valid XML in UT_JUNIT_REPORTER when dbms_output or test results contain `_cbac_modify_objects_role`, which [ut3_cbac_modify_objects_role_grants.sql](source/ut3_cbac_modify_objects_role_grants.sql) grants to those packages. +Users calling the framework get no privileges on the tables. The rules below were verified on Oracle 19.20, 21 XE and 23 Free. + +## Packages with the CBAC role + +- **Grants:** a package that needs the role gets a `grant ... to package` line in the grants script. The objects its SQL uses (tables, types, other packages) are granted to the role in the same script. +- **Qualify framework objects:** in the SQL of these packages, qualify framework objects with the SQL*Plus substitution variable `&&ut3_owner.`, which `install.sql` sets. The code runs as the invoking user, so unqualified names would resolve in that user's schema. When you compile such a body by hand, run `define ut3_owner=ut3_develop` first. +- **Install order:** `install.sql` installs the package specs, then runs the grants script, then installs the bodies. A body that expands a SQL macro needs the role when it compiles; in the other order it fails with `ORA-62565` / `PLS-00201`. +- **Recreating a spec drops the grant:** `create or replace package` removes the package's CBAC role grant, while `create or replace package body` keeps it. After changing such a spec by hand, rerun the grants script as SYS, or run `development/refresh_ut3.sh`. + +## SQL macros + +- **Table macros only.** utPLSQL is compatible with Oracle 19c (RU 19.20) or later, so table macros are available everywhere it runs. +- **Separate definer rights package:** a macro doesn't compile in an invoker rights package (`PLS-00782`). Macros live in their own `authid definer` packages, such as `ut_annotation_cache_macros` and `ut_suite_cache_macros`. +- **Two grants needed for macro package:** one to the CBAC role in the grants script, and one to the framework users in [create_grants.sql](source/create_grants.sql). +- **Qualify framework objects in the macro text** with `&&ut3_owner.`. The text is expanded into the caller's statement, which runs with invoker rights. +- **Don't use argument values in the macro body.** The body sees an argument's value only when the caller passes a literal; binds and PL/SQL variables arrive as NULL. So the body can't branch on an argument or build SQL from it. Put conditions into the returned text instead, for example `(a_value is null or col > a_value)`. +- **No macro inside a `WITH` clause** (`ORA-64630`). Call the macro from the main query or one of its subqueries. A CTE can be passed as a table argument. +- **No collection columns in a table argument** (`ORA-62558`). Pass a CTE that selects only scalar columns. +- **No `all_objects` in a CTE of a statement that calls a macro.** The statement compiles but fails at run time with `ORA-00942`. Use `all_objects` in the main query instead. +- **Recompile with `alter package ... compile body`.** `dbms_utility.compile_schema` can't recompile a body that expands a macro in static SQL (`ORA-62565`). +- **Test on 19c, 21 XE and 23 Free.** The privilege checks for macros differ between versions. # Configuring local environment Your local environment can be of any flavor (Unix/Linux/Windows/Mac). -At minimum you need to have Oracle database 11.2 XE accessible for the project and SYS account access to install and develop utPLSQL. +At minimum, you need to have Oracle database 19c (we use Release Update 19.20 or later) accessible for the project and SYS account access to install and develop utPLSQL. -We use four different database accounts (users) for development process. -* `ut3_latest_release` - holds latest released version of utPLSQL. This schema holds the testing framework used for self-testing of utPLSQL development. -* `ut3` - holds the version of utPLSQL of your current branch. This is the schema you will be working on. +We use five different database accounts (users) for development process. +* `ut3` - holds latest released version of utPLSQL. This schema holds the testing framework used for self-testing of utPLSQL development. +* `ut3_develop` - holds the version of utPLSQL of your current branch. This is the schema you will be working on. * `ut3_tester` - holds unit test packages for development of utPLSQL. -* `ut3$user#` - used for testing accessibility to schema names with special characters. +* `ut3_user` - used for testing accessibility to schema names with special characters. +* `ut3_tester_helper` - elevated privileges user, used for creating and dropping objects in other schemas during test run. +## Local database in a disposable Docker container +We use, and recommend, a disposable Docker container with Oracle Database Free, built from [gvenzl/oci-oracle-free](https://github.com/gvenzl/oci-oracle-free/tree/main), using image `gvenzl/oracle-free:slim-faststart`. +The container needs no setup and can be thrown away and recreated whenever you need a clean database. +`ORACLE_PASSWORD` sets the SYS password. Use the same value for `ORACLE_PWD` in `development/env.sh`, and connect to `127.0.0.1:1521/FREEPDB1`. + +Run the container in background: +```bash +docker run -d --name utplsql-db -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-free:slim-faststart +``` + +Stop the container: +```bash +docker stop utplsql-db +``` + +Restart the container (database content is kept): +```bash +docker restart utplsql-db +``` + +Recreate the container (database content is lost): +```bash +docker rm -f utplsql-db && docker run -d --name utplsql-db -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-free:slim-faststart +``` + +The database is ready to use once `docker logs utplsql-db` shows `DATABASE IS READY TO USE!`. ## Get started with development @@ -56,7 +138,7 @@ To get started with development, follow the below steps. _If you're using Windows, run the shell scripts using `GIT bash` - Windows-based bash command line._ -**Caution**: If you are using jetBrains DataGrip, don't use the ingegrated console to run the shell scripts (not even with GIT bash configured). It might disconnect from oracle randomly during script-run. +**Caution**: If you are using jetBrains DataGrip, don't use the integrated console to run the shell scripts (not even with GIT bash configured). It might disconnect from oracle randomly during script-run. ### Clone your fork of utPLSQL git repository @@ -85,38 +167,32 @@ You might have to adjust the following lines in `development/env.sh`: ```bash export SQLCLI=sql # For sqlcl client #export SQLCLI=sqlplus # For sqlplus client -export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string +export CONNECTION_STR=127.0.0.1:1521/FREEPDB1 # Adjust the connect string export ORACLE_PWD=oracle # Adjust your local SYS password ``` -### Download Oracle JDBC drivers - -Download `ojdbc8-xxx.jar` and `orai18n-xxx.jar` from [Oracle](https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html). -Place them in `development` directory of the project. - - ### Download utPLSQL release sources and utplsq-cli The below script is fetching latest release version from utPLSQL repository. Latest release version is used for self-testing. ```bash -development/refresh_sources.sh +./development/refresh_sources.sh ``` ### Setup local database for utPLSQL development ```bash -development/install.sh +./development/install.sh ``` ### That's it You now have the following: -- sources from `develop` branch of your fork of utPLSQL repository in `utPLSQL/ut3_latest_release` directory -- sources from `master` branch of utPLSQL/utPLSQL repository in `utPLSQL/ut3_latest_release` directory +- sources from your fork of utPLSQL repository in `utPLSQL` directory +- sources from utPLSQL/utPLSQL repository (branch set by `SELFTESTING_BRANCH` in `development/env.sh`) in `utPLSQL/utPLSQL_latest_release` directory - binaries of `utplsql-cli` in `utPLSQL/utPLSQL-cli` directory - database users created -- your current branch of utPLSQL deployed into `ut3` schema -- utPLSQL released version deployed to `ut3_latest_release` +- your current branch of utPLSQL deployed into `ut3_develop` schema +- utPLSQL released version deployed into `ut3` schema At any time, if you need to refresh your database, the below scripts might be helpful. @@ -126,7 +202,7 @@ At any time, if you need to refresh your database, the below scripts might be he development/cleanup.sh ``` -## Reinstalling utPLSQL development in `ut3` schema +## Reinstalling utPLSQL development in `ut3_develop` schema ```bash development/refresh_ut3.sh @@ -140,9 +216,9 @@ Whenever a new version of utPLSQL or a new version of utPLSQL-cli is available, utPLSQL v3 unit tests are located in the `test` directory -Before you push any changes and create a pull request to the utPLSQL project repository, make sure that all of the tests are executing successfully in your local environment. +Before you push any changes and create a pull request to the utPLSQL project repository, make sure that all the tests are executing successfully in your local environment. -Every new functionality needs to be documented by unit tests that cover both happy-path scenarios as well as edge-cases and exception paths. +Every new functionality needs to be documented by unit tests that cover happy-path scenarios as well as edge-cases and exception paths. > **Important notice:** > We do our best to keep utPLSQL covered with unit tests. @@ -150,8 +226,8 @@ Every new functionality needs to be documented by unit tests that cover both hap To run a full suite of unit tests execute: ```bash -development/env.sh -test/install_and_run_tests.sh +. ./development/env.sh +./test/install_and_run_tests.sh ``` You can review the results of tests as well as see information about code coverage in `./coverage.html` file. @@ -167,45 +243,20 @@ Dependencies to `ut_util` are not shown as most of modules are depending on it. ## Build Environment -We are using private docker images to test utPLSQL for our Travis CI builds. The following versions of Oracle Database are being used. - -* 11g XE R2 -* 12c SE R1 -* 12c SE R2 -* 18c SE +We are using a combination of private and publicly available docker images to test utPLSQL. The following versions of Oracle Database are used for testing: -These images are based on the slimmed versions [official dockerfiles released by Oracle](https://github.com/utPLSQL/docker-scripts), but due to licensing restrictions, we can't make the images public. -You can build your own and use it locally, or push to a private docker repository. - -The build steps are simple if you already have some experience using Docker. You can find detailed information about how to build your own image with a running database in: [example of creating an image with pre-built DB](https://github.com/oracle/docker-images/blob/master/OracleDatabase/samples/prebuiltdb/README.md) +* 19c-Standard Edition (private image) +* 21-free +* 23-free -> You can find more info about the official Oracle images on the [Oracle Database on Docker](https://github.com/oracle/docker-images/tree/master/OracleDatabase) GitHub page. +The Free varsions are publicly available and you can set up your local development environment to use one of from [here](https://github.com/gvenzl/oci-oracle-free) -> If you are new to Docker, you can start by reading the [Getting Started With Docker](https://docs.docker.com/engine/getstarted/) docs. +These [private image]((https://github.com/utPLSQL/docker-scripts) is a slimmed version of [the official Oracle database dockerfiles](https://github.com/oracle/docker-images/tree/master/OracleDatabase) . Due to licensing restrictions, the image cannot be public. -### Docker Build Notes - -* You need to comment out the VOLUME line. This step is required, because volumes are not saved when using `docker commit` command. -* When the build process is complete, you will run the container to install the database. Once everything is set up and you see the message "DATABASE IS READY!", you may change the password and stop the running container. After the container is stopped, you can safely commit the container. -* You can use the --squash experimental docker tag to reduce the image size. Example: -``` -docker build --force-rm --no-cache --squash -t oracle/db-prebuilt . -``` - -Travis will use your Docker Hub credentials to pull the private images, and the following secure environment variables must be defined. - -Variable | Description ----------|------------ -**DOCKER_USER**
**DOCKER_PASSWORD** | _Your Docker Hub website credentials. They will be used to pull the private database images._ - -### SQLCL - -Our build configuration uses SQLCL to run the scripts, and you need to configure a few additional secure environment variables. After the first build, the downloaded file will be cached. - -Variable | Description ----------|------------ -**ORACLE_OTN_USER
ORACLE_OTN_PASSWORD** | _Your Oracle website credentials. They will be used to download SQLCL._ +You can build your own and use it locally, or push to a private docker repository. +The build steps are simple if you already have some experience using Docker. You can find detailed information about how to build your own image with a running database in: [example of creating an image with pre-built DB](https://github.com/oracle/docker-images/blob/master/OracleDatabase/samples/prebuiltdb/README.md) +> If you are new to Docker, you can start by reading the [Getting Started With Docker](https://docs.docker.com/get-started/) docs. ## New to GIT diff --git a/LICENSE b/LICENSE index 640d46628..0cc83a7bb 100644 --- a/LICENSE +++ b/LICENSE @@ -187,9 +187,9 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..d60241743 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,31 @@ +# Security Policy + +## Supported versions + +Security fixes are considered for the latest supported release. See the +[utPLSQL releases](https://github.com/utPLSQL/utPLSQL/releases) for the latest +version. + +| Version | Supported | +| --- | --- | +| Latest release | Yes | +| Older releases | No; update to the latest release and check whether the issue persists. | + +## Reporting a vulnerability + +Please report suspected security vulnerabilities privately. **Do not** disclose +them in a public GitHub issue, discussion, or pull request. + +Use GitHub's [Report a vulnerability feature](https://github.com/utPLSQL/utPLSQL/security/advisories/new) +for the utPLSQL repository. + +Include, if possible: + +- The affected utPLSQL version and Oracle Database version. +- A description of the potential impact. +- Steps or a proof of concept to reproduce the issue. +- Any suggested mitigation. + +The maintainers will acknowledge the report and coordinate any investigation, +fix, and disclosure with the reporter. Please allow time to investigate before +making the issue public. diff --git a/SPONSORS.md b/SPONSORS.md new file mode 100644 index 000000000..ad75d347c --- /dev/null +++ b/SPONSORS.md @@ -0,0 +1,14 @@ +# Sponsors + +utPLSQL is free and open source under the Apache 2.0 license. Sponsorship funds its maintenance and development. +To become a sponsor, see [utplsql.org/sponsorship](https://www.utplsql.org/sponsorship.html). + +This file is the complete archive of current and past sponsors. The up-to-date recognition lists are on the [sponsors page](https://www.utplsql.org/sponsors.html). + +## Current sponsors + +None yet. + +## Past sponsors + +- [Redgate](https://www.red-gate.com/hub/events/open-source-projects) (2019) diff --git a/VERSION b/VERSION index ff96ff1c9..19db2fb66 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.1.8-develop +v3.2.4-develop diff --git a/development/cleanup.sh b/development/cleanup.sh index 313e382ca..54c23b408 100755 --- a/development/cleanup.sh +++ b/development/cleanup.sh @@ -1,16 +1,16 @@ -#!/usr/bin/env bash +#!/bin/bash #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" -. development/env.sh +. ./development/env.sh "${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL set echo on begin for x in ( select * from dba_objects - where owner in ( upper('${UT3_RELEASE_VERSION_SCHEMA}'), upper('${UT3_OWNER}') ) + where owner in ( upper('${UT3_RELEASE_VERSION_SCHEMA}'), upper('${UT3_DEVELOP_SCHEMA}') ) and object_name like 'SYS_PLSQL%') loop execute immediate 'drop type '||x.owner||'.'||x.object_name||' force'; @@ -18,17 +18,25 @@ begin end; / -drop user ${UT3_OWNER} cascade; +drop user ${UT3_DEVELOP_SCHEMA} cascade; drop user ${UT3_RELEASE_VERSION_SCHEMA} cascade; -drop user ${UT3_TESTER} cascade; -drop user ${UT3_TESTER_HELPER} cascade; -drop user ${UT3_USER} cascade; +drop user ut3_tester cascade; +drop user ut3_tester_helper cascade; +drop user ut3_user cascade; +drop user ut3_cache_test_owner cascade; +drop user ut3_no_extra_priv_user cascade; +drop user ut3_select_catalog_user cascade; +drop user ut3_select_any_table_user cascade; +drop user ut3_execute_any_proc_user cascade; +drop role ${UT3_DEVELOP_SCHEMA}_cbac_modify_objects_role; +set serveroutput on begin for i in ( select decode(owner,'PUBLIC','drop public synonym "','drop synonym "'||owner||'"."')|| synonym_name ||'"' drop_orphaned_synonym, owner||'.'||synonym_name syn from dba_synonyms a where not exists (select 1 from dba_objects b where (a.table_name=b.object_name and a.table_owner=b.owner or b.owner='SYS' and a.table_owner=b.object_name) ) - and a.table_owner not in ('SYS','SYSTEM') + and a.table_owner not in (select username from dba_users where oracle_maintained = 'Y') + and a.origin_con_id = sys_context('userenv', 'con_id') ) loop execute immediate i.drop_orphaned_synonym; dbms_output.put_line('synonym '||i.syn||' dropped'); diff --git a/development/install.sh b/development/install.sh index 4104e2672..22a3166b2 100755 --- a/development/install.sh +++ b/development/install.sh @@ -1,20 +1,24 @@ -#!/usr/bin/env bash +#!/bin/bash #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" -. development/env.sh +. ./development/env.sh header="******************************************************************************************" if ! development/cleanup.sh; then echo -e ${header}"\nFailed to cleanup utPLSQL environment\n"${header} exit 1 fi -if ! .travis/install.sh; then - echo -e ${header}"\nFailed to install utPLSQL from current branch into ${UT3_OWNER} schema\n"${header} +if ! .github/scripts/install.sh; then + echo -e ${header}"\nFailed to install utPLSQL from current branch into ${UT3_DEVELOP_SCHEMA} schema\n"${header} exit 1 fi -if ! .travis/install_utplsql_release.sh; then +if ! .github/scripts/create_test_users.sh; then + echo -e ${header}"\nFailed to create test users from current branch\n"${header} + exit 1 +fi +if ! .github/scripts/install_utplsql_release.sh; then echo -e ${header}"\nFailed to install utPLSQL from branch ${SELFTESTING_BRANCH} into ${UT3_RELEASE_VERSION_SCHEMA}\n"${header} exit 1 fi diff --git a/development/refresh_sources.sh b/development/refresh_sources.sh index 9474c3553..36dd20b47 100755 --- a/development/refresh_sources.sh +++ b/development/refresh_sources.sh @@ -1,19 +1,19 @@ -#!/usr/bin/env bash +#!/bin/bash #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" -. development/env.sh +. ./development/env.sh -# remove sub-direcotry containing master branch shallow copy +# remove sub-direcotry containing main branch shallow copy rm -rf ${UTPLSQL_DIR:-utPLSQL_latest_release} -# clone utPLSQL master branch from upstream into utPLSQL sub-directory of your project -git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR:-utPLSQL_latest_release} +# clone utPLSQL main branch from upstream into utPLSQL sub-directory of your project +git clone --depth=1 --branch=${SELFTESTING_BRANCH:-main} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR:-utPLSQL_latest_release} +rm -rf ${UTPLSQL_DIR:-utPLSQL_latest_release}/.git rm -rf utPLSQL-cli/* # download latest release version of utPLSQL-cli -curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/v${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip +curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip # unzip utPLSQL-cli and remove the zip file unzip utPLSQL-cli.zip && chmod u+x utPLSQL-cli/bin/utplsql && rm utPLSQL-cli.zip -cp development/*.jar utPLSQL-cli/lib/ diff --git a/development/refresh_ut3.sh b/development/refresh_ut3.sh index 542f5a01c..5fff37e81 100755 --- a/development/refresh_ut3.sh +++ b/development/refresh_ut3.sh @@ -1,14 +1,24 @@ -#!/usr/bin/env bash +#!/bin/bash +set -e #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" . development/env.sh cd source +"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA @uninstall ${UT3_DEVELOP_SCHEMA} + +# Same install steps as .github/scripts/install.sh, without recreating the user or public synonyms "${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL -@uninstall ${UT3_OWNER} -@install ${UT3_OWNER} +whenever sqlerror exit failure rollback +alter session set plsql_optimize_level=0; +@install ${UT3_DEVELOP_SCHEMA} +@create_grants ${UT3_DEVELOP_SCHEMA} PUBLIC +@install_ddl_trigger ${UT3_DEVELOP_SCHEMA} exit SQL + +# Reinstall dropped the grants on ${UT3_DEVELOP_SCHEMA} objects +../.github/scripts/create_test_grants.sh diff --git a/development/releasing.md b/development/releasing.md index 3e9ac64fa..9b3f464a1 100644 --- a/development/releasing.md +++ b/development/releasing.md @@ -1,28 +1,27 @@ -The release process is semi-automated. +# Release process -With every build, the build process on Travis updates files with an appropriate version number before deployment into the database. -This step is performed, to confirm that the update of versions works properly. +To create a release, follow the below steps. -To create a release: - - create release branch from development branch and make sure to name the release branch: `release/vX.Y.Z` - - update, commit and push at least one file change in the release branch, to kickoff a Travis build - - wait for th build to complete successfully - - merge the release branch to master and wait for master build to complete successfully (do not use Squash/rebase for merge operation) - - create a Github release from the master branch using [github releases page](https://github.com/utPLSQL/utPLSQL/releases) and populate release description using information found on the issues and pull requests since previous release. - To find issues closed after certain date use [advanced filters](https://help.github.com/articles/searching-issues-and-pull-requests/#search-by-open-or-closed-state). - Example: [`is:issue closed:>2018-07-22`](https://github.com/utPLSQL/utPLSQL/issues?utf8=%E2%9C%93&q=is%3Aissue+closed%3A%3E2018-07-22+) - - After A build was completed on a TAG (github release) was successful, merge master branch back into develop branch. - - At this point, master branch and release tag should be at the same commit version and artifacts should be uploaded into Github release. - - After develop branch was built, update version number in `VERSION` file to represent next planned release version. - - Clone `utplsql.githug.io` project and add a new announcement about next version being released in `_posts`. Use previous announcements as a template. Make sure to set date, time and post title properly. +## Release preparation + - Create a **draft** of a Release with a new tag number `vX.Y.X` sourced from the `develop` branch on [github releases page](https://github.com/utPLSQL/utPLSQL/releases) + - Populate release description using the `Generate release notes` button + - Review the auto-generated release notes and update tem if needed + - Add this line at the end of the release notes: `This release was made possible by our sponsors: https://www.utplsql.org/sponsors.html` (a link, not a list of names, so it always shows who is current) + - Optionally, split the default `## What's Changed` list into `## New features`, `## Enhancements`, `## Bug fixes`. See previous release notes for details -The following will happen: - - build executed on branch `release/vX.Y.Z-[something]` updates files `sonar-project.properties`, `VERSION` with project version derived from the release branch name - - changes to those two files are committed and pushed back to release branch by Travis - - builds on master branch are **not getting executed** - - when a Github release is created, a new tag is added in on the repository and a tag build is executed - - the documentation for new release is published on `utplsql.github.io` and installation archives are added to the tag. +## Performing a release + - Publish [the previously prepared](#release-preparation) release draft. + - Wait for the [Github Actions `Release`](https://github.com/utPLSQL/utPLSQL/actions/workflows/release.yml) process to complete successfully. The process will do the following: + - create a new tag + - generate html documentation to be included in the release file. + - publish documentation for the new version into utPLSQL site + - upload release artifacts (`zip` and `tar.gz` files along with `sha256` files) + - update the CHANGELOG.md file with the release details + - publish an announcement about the release in the utPLSQL Organization Discussions + - publish a release post on utplsql.github.io (new post in `docs/announcements/posts`) + - both announcements are created by the shared [announce-release action](https://github.com/utPLSQL/.github/tree/main/actions/announce-release), also used by utPLSQL-cli, utPLSQL-maven-plugin and utPLSQL-java-api + - After the release process is finished, manually increase the version number in the `VERSION` file on `develop` branch to start the next release version. + - Send an announcement about the release on:Twitter(X), BlueSky, LinkedIn account about the utPLSQL release. -Note: -The sources for release are provided in separate zip files delivered from the Travis build process. -The built zip files include HTML documentation generated from MD files. +# Note: +The release artifacts include HTML documentation generated from MD files, sources and tests diff --git a/development/template.env.sh b/development/template.env.sh index ab4f4efa2..fdbed4b6b 100755 --- a/development/template.env.sh +++ b/development/template.env.sh @@ -1,20 +1,15 @@ -#!/usr/bin/env bash +#!/bin/bash -export SQLCLI=sql # For sqlcl client -#export SQLCLI=sqlplus # For sqlplus client -export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string -export ORACLE_PWD=oracle # Adjust your local SYS password -export UTPLSQL_CLI_VERSION="3.1.6" +export SQLCLI=sql # For sqlcl client +#export SQLCLI=sqlplus # For sqlplus client +export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string +export ORACLE_PWD=oracle # Adjust your local SYS password +export UTPLSQL_CLI_VERSION="v3.1.8" export SELFTESTING_BRANCH=develop export UTPLSQL_DIR="utPLSQL_latest_release" -export UT3_OWNER=ut3 -export UT3_OWNER_PASSWORD=ut3 -export UT3_RELEASE_VERSION_SCHEMA=ut3_latest_release -export UT3_TESTER=ut3_tester -export UT3_TESTER_PASSWORD=ut3 -export UT3_TESTER_HELPER=ut3_tester_helper -export UT3_TESTER_HELPER_PASSWORD=ut3 +export UT3_DEVELOP_SCHEMA=UT3_DEVELOP +export UT3_DEVELOP_SCHEMA_PASSWORD=ut3 +export UT3_RELEASE_VERSION_SCHEMA=UT3 +export UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3 export UT3_TABLESPACE=users -export UT3_USER="UT3\$USER#" -export UT3_USER_PASSWORD=ut3 diff --git a/docs/about/authors.md b/docs/about/authors.md deleted file mode 100644 index d486fde91..000000000 --- a/docs/about/authors.md +++ /dev/null @@ -1,26 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -### utPLSQL v3 Major Contributors - -**Listed Alphabetically** - -| Name | GitHub account -| ---------------- | -------------- -| David Pyke | [Shoelace](https://github.com/Shoelace) -| Jacek Gebal | [jgebal](https://github.com/jgebal) -| Lukasz Wasylow | [lwasylow](https://github.com/lwasylow/) -| Pavel Kaplya | [Pazus](https://github.com/Pazus) -| Robert Love | [rlove](https://github.com/rlove) -| Samuel Nitsche | [pesse](https://github.com/pesse/) -| Vinicius Avellar | [viniciusam](https://github.com/viniciusam/) - - - -Many thanks to all the [contributors](https://github.com/utPLSQL/utPLSQL/graphs/contributors) - -### Special thanks to prior major contributors - -- Steven Feuerstein - Original Author -- Chris Rimmer -- Patrick Barel -- Paul Walker diff --git a/docs/about/license.md b/docs/about/license.md deleted file mode 100644 index f988a85e3..000000000 --- a/docs/about/license.md +++ /dev/null @@ -1,17 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -# Version Information - -**utPLSQL version 3** is licensed under -[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) - -External code used in the development of this project, but is not required for use. - -| Tool | License | Purpose | -| ---- | --------| --------| -| [Travis-Oracle](https://github.com/cbandy/travis-oracle) | [ISC](https://github.com/cbandy/travis-oracle/blob/master/LICENSE) | Install Oracle for Travis Builds | -| [mkDocs](http://www.mkdocs.org/) | [BSD](http://www.mkdocs.org/about/license/) | Produce HTML version of documentation | - -**Note:** - -Version 1 & 2 of utPLSQL were licensed under GPL, version 3 was a complete rewrite from scratch which a allowed us to change the license to be more permissive. diff --git a/docs/about/project-details.md b/docs/about/project-details.md deleted file mode 100644 index 93fe63df3..000000000 --- a/docs/about/project-details.md +++ /dev/null @@ -1,18 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -# utPLSQL Project Details - -[![chat](http://img.shields.io/badge/GitHub_Project-Active-blue.svg)](https://github.com/utPLSQL/utPLSQL) -[![license](http://img.shields.io/badge/license-apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) -[![chat](http://img.shields.io/badge/chat-slack-blue.svg)](http://utplsql-slack-invite.herokuapp.com/) -[![twitter](https://img.shields.io/twitter/follow/utPLSQL.svg?style=social&label=Follow)](https://twitter.com/utPLSQL) - - -utPLSQL is open source project [hosted on GitHub](https://github.com/utPLSQL/utPLSQL). - -Contributions, help and constructive feedback is always appreciated. - -If you are interested in helping please read our [contributing guide](https://github.com/utPLSQL/utPLSQL/blob/develop/CONTRIBUTING.md) - - - diff --git a/docs/about/support.md b/docs/about/support.md deleted file mode 100644 index 60dacc2f1..000000000 --- a/docs/about/support.md +++ /dev/null @@ -1,6 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -# How to get support - -- Feel free to post questions, bugs or issues in the [issues area of GitHub](https://github.com/utPLSQL/utPLSQL/issues) -- Join developers at the [utPLSQL team](http://utplsql-slack-invite.herokuapp.com) on [Slack](https://slack.com/) diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png new file mode 100644 index 000000000..7c34109d0 Binary files /dev/null and b/docs/assets/favicon.png differ diff --git a/docs/assets/icon-transparent.png b/docs/assets/icon-transparent.png new file mode 100644 index 000000000..6e4534aad Binary files /dev/null and b/docs/assets/icon-transparent.png differ diff --git a/docs/compare_version2_to_3.md b/docs/compare_version2_to_3.md new file mode 100644 index 000000000..121fafc59 --- /dev/null +++ b/docs/compare_version2_to_3.md @@ -0,0 +1,55 @@ +For version 3 has been a complete rewrite of the framework, the way it can be used is different to +the previous versions, but also more in line with other modern unit-testing frameworks like JUnit and RSpec. + +There is a [migration tool](https://github.com/utPLSQL/utPLSQL-v2-v3-migration) that can help you to migrate your existing utPLSQL v2 tests to the v3 capabilities. + +# Feature comparison + +| Feature | Version 2 | Version 3 | +| -------------------------------------- | ---------------------- | ---------------------- | +| Easy to install | Yes | Yes | +| Documentation | Yes | Yes | +| License | GPL v2 | Apache 2.0 | +| **Tests Creation** | | | +| Declarative test configuration | No | Yes - Annotations1| +| Tests as Packages | Yes | Yes | +| Multiple Tests in a single Package | Yes | Yes | +| Optional Setup/Teardown | No | Yes | +| Different Setup/Teardown
For Each Test in a Single Package| No | Yes - Annotations1 | +| Suite Definition Storage | Tables | Package - Annotations1 | +| Multiple Suites | Yes | Yes | +| Suites can contain Suites | No | Yes | +| Automatic Test detection | No | Yes - Annotations1| +| Unconstrained naming of Test packages | No - prefixes | Yes - name not relevant| +| Require Prefix on Test procedures | No - prefixes | Yes - name not relevant| +| Auto Compilation of Tests | Yes | No (Let us know if you use this) | +| Assertion Library | 30 assertions2 | 26 matchers (13 + 13 negated) | +| Extendable assertions | No | Yes - custom matchers | +| PLSQL Record Assertions | generated code through **utRecEq** Package | [possible on Oracle 12c+](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1) using [cursor matchers](userguide/expectations.md#comparing-cursors)| +| Test Skeleton Generation | Yes | No (Let us know if you use this) | +| **Test Execution3** | | | +| Single Test Package Execution | Yes | Yes | +| Single Test Procedure Execution | No | Yes | +| Test Suite Execution | Yes | Yes | +| Subset of Suite Execution | No | Yes | +| Multiple Suite Execution | No | Yes | +| Organizing Suites into hierarchies | No | Yes | +| **Code Coverage Reporting** | No | Yes | +| Html Coverage Report | No | Yes | +| Sonar XML Coverage Report | No | Yes | +| Framework Transaction Control | No | Yes - Annotations1 | +| **Test Output** | | | +| Real-time test execution progress reporting | No | Yes | +| Multiple Output Reporters can be used during test execution | No| Yes | +| DBMS_OUTPUT | Yes | Yes (clean formatting) | +| File | Yes (to db server only)| Yes (on client side) | +| Stored in Table | Yes | No (can be added as custom reporter) | +| XUnit format support | No | Yes | +| HTML Format | Yes | No | +| Custom Output reporter | Yes-needs configuration| Yes - no config needed | + +1 Annotations are specially formatted comments in your package specification. This enables *declarative* test configuration that is coupled with the source code. See Documentation for more details. + +2 **utAssert2** package - Contains 59 Assertions - 2 Not implemented = 57, 28 are duplicated only change on outcome_in parameter 57-28 = 29, **utPipe** package - Contains 1 Assertion 29 + 1 = 30 + +3 Test execution comparison is in a single call so the results are combined. We know it was always possible to group in any way with multiple calls. But that may not be desired under a CI system where you want a single JUnit XML Output. diff --git a/docs/images/supported_by_redgate_100.png b/docs/images/supported_by_redgate_100.png deleted file mode 100644 index ea9f93ac5..000000000 Binary files a/docs/images/supported_by_redgate_100.png and /dev/null differ diff --git a/docs/images/tap_reporter_colored.png b/docs/images/tap_reporter_colored.png new file mode 100644 index 000000000..d4a5e9326 Binary files /dev/null and b/docs/images/tap_reporter_colored.png differ diff --git a/docs/images/tap_reporter_no_color.png b/docs/images/tap_reporter_no_color.png new file mode 100644 index 000000000..e7379a889 Binary files /dev/null and b/docs/images/tap_reporter_no_color.png differ diff --git a/docs/images/tap_reporter_suitepath.png b/docs/images/tap_reporter_suitepath.png new file mode 100644 index 000000000..488c7cfbf Binary files /dev/null and b/docs/images/tap_reporter_suitepath.png differ diff --git a/docs/index.md b/docs/index.md index 187b02c0e..c0b531359 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,43 +1,30 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) -# Introduction to utPLSQL +## What is utPLSQL utPLSQL is a Unit Testing framework for Oracle PL/SQL. -The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](http://junit.org/junit4/) and [RSpec](http://rspec.info/) - - - User Guide - - [Installation](userguide/install.md) - - [Getting Started](userguide/getting-started.md) - - [Annotations](userguide/annotations.md) - - [Expectations](userguide/expectations.md) - - [Advanced data comparison](userguide/advanced_data_comparison.md) - - [Running unit tests](userguide/running-unit-tests.md) - - [Querying for test suites](userguide/querying_suites.md) - - [Testing best practices](userguide/best-practices.md) - - [Upgrade utPLSQL](userguide/upgrade.md) - - Reporting - - [Using reporters](userguide/reporters.md) - - [Reporting errors](userguide/exception-reporting.md) - - [Code coverage](userguide/coverage.md) - - [Cheat-sheet](https://www.cheatography.com/jgebal/cheat-sheets/utplsql-v3-1-2/#downloads) - - About - - [Project Details](about/project-details.md) - - [License](about/license.md) - - [Support](about/support.md) - - [Authors](about/authors.md) - -# Demo project - -Have a look at our [demo project](https://github.com/utPLSQL/utPLSQL-demo-project/). - -It uses [Travis CI](https://travis-ci.org/utPLSQL/utPLSQL-demo-project) to build on every commit, runs all tests, publishes test results and code coverage to [SonarQube](https://sonarqube.com/dashboard?id=utPLSQL%3AutPLSQL-demo-project%3Adevelop). - -# Three steps +The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](https://junit.org/) and [RSpec](https://rspec.info/). + +See [About](https://www.utplsql.org/about.html) for project history, contributors and stewardship. + +## Demo project + +Have a look at [utPLSQL demo project](https://github.com/utPLSQL/utPLSQL-demo-project/) to see: + +- sample code and tests +- demo of deployment automation that leverages: + - Flyway / Liquibase for scripting and deployment of DB changes + - Docker container with Oracle XE Database + - GitHub Actions and Azure Pipelines to orchestrate the deployment and testing process + - utPLSQL framework for writing and executing tests, as well as reporting test results and code coverage + - [Sonar](https://sonarcloud.io/project/overview?id=utPLSQL:utPLSQL-demo-project) for code quality gate, test results and code coverage reporting + +## Three steps With just three simple steps you can define and run your unit tests for PLSQL code. 1. Install the utPLSQL framework -2. Create Unit Tests to for the code +2. Create unit tests for the code 3. Run the tests Here is how you can simply create tested code, unit tests and execute the tests using SQL Developer @@ -47,22 +34,22 @@ Here is how you can simply create tested code, unit tests and execute the tests Check out the sections on [annotations](userguide/annotations.md) and [expectations](userguide/expectations.md) to see how to define your tests. -# Command line +## Command line You can use the utPLSQL command line client [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) to run tests without the need for Oracle Client or any IDE like SQLDeveloper/TOAD etc. Amongst many benefits they provide ability to: + * see the progress of test execution for long-running tests - real-time reporting * use many reporting formats simultaneously and save reports to files (publish) * map your project source files and test files into database objects -Just download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest), download Oracle jdbc driver you are good to go. +Download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest) and you are good to go. See [project readme](https://github.com/utPLSQL/utPLSQL-cli/blob/develop/README.md) for details. -# Coverage - -If you want to have code coverage gathered on your code , it's best to use `ut_run` to execute your tests with multiple reporters and have both test execution report as well as coverage report saved to a file. +## Coverage +It is best to use utPLSQL-cli or execute tests and gather code coverage from command line. Check out the [coverage documentation](userguide/coverage.md) for options of coverage reporting diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 000000000..fdfe1a3be --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{# + Sub-repository template override. + Loads the shared utPLSQL.org top navigation bar from the central org site. + The topbar.js file is the single source of truth — update nav links there only. +#} + +{% block extrahead %} + {{ super() }} + + +{% endblock %} diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css new file mode 100644 index 000000000..ff7721882 --- /dev/null +++ b/docs/stylesheets/extra.css @@ -0,0 +1,64 @@ +[data-md-color-scheme="default"] { + --md-primary-fg-color: #1565c0; /* link + header colour: 5.8:1 with white text */ + --md-typeset-a-color: #1565c0; /* link = header colour: 5.8:1 */ + --md-accent-fg-color: #1e88e5; /* hover: lighter than the link, 3.7:1 */ + --md-accent-fg-color--transparent: rgba(30, 136, 229, .1); + --md-default-fg-color--light: hsla(0, 0%, 0%, .64); /* muted text 6.7:1 */ +} + +[data-md-color-scheme="slate"] { + --md-hue: 215; + --md-primary-fg-color: #1565c0; /* header background keeps the brand blue */ + --md-accent-fg-color: #3578cc; /* hover: darker than the link, 3.6:1 */ + --md-accent-fg-color--transparent: rgba(53, 120, 204, .1); + --md-default-fg-color: hsla(var(--md-hue), 15%, 90%, .90); /* body ~10:1 */ + --md-default-fg-color--light: hsla(var(--md-hue), 15%, 90%, .68); /* muted 6.5:1 */ + --md-code-hl-keyword-color: hsl(219, 80%, 72%); +} + +/* Material sets the dark link colour per primary colour with higher specificity */ +[data-md-color-scheme="slate"][data-md-color-primary] { + --md-typeset-a-color: #4a90e2; /* link: header blue lightened just enough to read on dark, 4.8:1 */ +} + +/* Footer: make the sponsor and cookie links stand out from the copyright text */ +.md-copyright a.footer-sponsor { + display: inline-flex; + overflow: hidden; + margin: 0 .4rem; + font-size: .65rem; + font-weight: 600; + line-height: 1; + color: #fff; + text-decoration: none; + vertical-align: middle; + border-radius: .2rem; +} + +.footer-sponsor__label, +.footer-sponsor__name { + padding: .3rem .5rem; +} + +.footer-sponsor__label { + background: #555; +} + +.footer-sponsor__name { + background: #ea4aaa; +} + +.md-copyright a.footer-sponsor:hover { + color: #fff; + opacity: .85; +} + +.md-copyright a.footer-cookies { + color: var(--md-footer-fg-color); + text-decoration: underline; + text-underline-offset: .15em; +} + +.md-copyright a.footer-cookies:hover { + color: var(--md-accent-fg-color); +} diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index a4f387676..50e2bbd0d 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) # Advanced data comparison @@ -48,7 +48,7 @@ When specifying column/attribute names, keep in mind that the names are **case s ## Excluding elements from data comparison Consider the following examples -```sql +```sql linenums="1" declare l_expected sys_refcursor; l_actual sys_refcursor; @@ -86,7 +86,7 @@ The actual data is equal/contains expected, when those columns are excluded. ## Selecting columns for data comparison Consider the following example -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -125,7 +125,7 @@ The actual data is equal/contains expected, when only those columns are included You can chain the advanced options in an expectation and mix the `varchar2` with `ut_varchar2_list` arguments. When doing so, the final list of items to include/exclude will be a concatenation of all items. -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -163,7 +163,7 @@ SUCCESS Example of `include / exclude` for anydata.convertCollection -```sql +```sql linenums="1" create or replace type person as object( name varchar2(100), age integer @@ -219,7 +219,7 @@ Unordered option allows for quick comparison of two compound data types without Result of such comparison will be limited to only information about row existing or not existing in given set without actual information about exact differences. -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -250,8 +250,9 @@ FAILURE at "anonymous block", line 15 ``` **Note** -> `join_by` matcher is much faster on performing data comparison, consider using `join_by` over unordered -> `contain` matcher is not considering order of compared data-sets. Using `unordered` makes no difference (it's default) +> Consider using `join_by( columns... )` over `unordered()` with the `equal` matcher. The `join_by` method is much faster at performing data comparison. +> +> The `contain` matcher is not considering the order of the compared data-sets. Using `unordered` makes no difference (it's default). ## Join By option @@ -266,7 +267,7 @@ The extra or missing rows will be presented to user as well as all non-matching Join by option can be used in conjunction with include or exclude options. However if any of the join keys is part of exclude set, comparison will fail and report to user that sets could not be joined on specific key, as the key was excluded. -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -304,7 +305,7 @@ FAILURE You can use `join_by` syntax in combination with `contain` matcher. -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -321,7 +322,7 @@ end; ``` Above test will indicate that in actual data-set -```sql +```sql linenums="1" FAILURE Actual: refcursor [ count = 28 ] was expected to contain: refcursor [ count = 29 ] Diff: @@ -334,7 +335,7 @@ FAILURE You can specify multiple columns in `join_by` -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -370,7 +371,7 @@ To reference attribute as PK, use slash symbol `/` to separate nested elements. In the below example, cursors are joined using the `NAME` attribute of object in column `SOMEONE` -```sql +```sql linenums="1" create or replace type person as object( name varchar2(100), age integer @@ -413,7 +414,7 @@ FAILURE > `join_by` does not support joining on individual elements of nested table. You can still use data of the nested table as a PK value. > When collection is referenced in `join_by`, test will fail with appropriate message, as it cannot perform a join. -```sql +```sql linenums="1" create or replace type person as object( name varchar2(100), age integer @@ -462,7 +463,7 @@ You may provide items for `include`/`exclude`/`join_by` as a a ut_varchar2_list - nested table and varray items type attributes are nested under `` elements Example of a valid parameter to include columns: `RN`, `A_Column`, `SOME_COL` in data comparison. -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -493,7 +494,7 @@ Expectations that compare compound data type data with `unordered_columns` optio This option can be useful whn we have no control over the ordering of the column or the column order is not of importance from testing perspective. -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index a2520f2ba..13ed97a23 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -1,44 +1,149 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -# Annotations +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) Annotations are used to configure tests and suites in a declarative way similar to modern OOP languages. This way, test configuration is stored along with the test logic inside the test package. -No configuration files or tables are needed. The annotation names are based on popular testing frameworks such as JUnit. +No additional configuration files or tables are needed for test cases. The annotation names are based on popular testing frameworks such as JUnit. The framework runner searches for all the suitable annotated packages, automatically configures suites, forms the suite hierarchy, executes it and reports results in specified formats. -Annotations are interpreted only in the package specification and are case-insensitive. We strongly recommend using lower-case annotations as described in this documentation. +Annotation is defined by: + +- single line comment `--` (double hyphen) +- followed directly by a `%` (percent) +- followed by annotation name +- followed by optional annotation text placed in single brackets. + +All text between first opening bracket and last closing bracket in annotation line is considered to be annotation text + +For example `--%suite(The name of my test suite)` represents `suite` annotation with `The name of my test suite` as annotation text. + +utPLSQL interprets the whole line of annotation and will treat text from the first opening bracket in the line to the last closing bracket in that line as annotation text + +In below example we have a `suite` annotation with `Stuff) -- we should name this ( correctly ` as the annotation text + +`--%suite(Stuff) -- we should name this ( correctly )` + +Do not place comments within annotation line to avoid unexpected behaviors. + +!!! note + Annotations are interpreted only in the package specification and are case-insensitive. We strongly recommend using lower-case annotations as described in this documentation. + +There are two distinct types of annotations, identified by their location in package. +- package annotations +- procedure annotations + +### Procedure level annotations + +Annotation placed directly before a procedure (`--%test`, `--%beforeall`, `--%beforeeach` etc.). +There **can not** be any empty lines or comments between annotation line and procedure line. +There can be many annotations for a procedure. + +Valid procedure annotations example: +```sql linenums="1" +package test_package is + --%suite + + + --%test() + --%disabled + procedure my_first_procedure; + + $if dbms_db_version.version >= 19 $then --This is ok - annotation before procedure + --%test() + procedure my_first_procedure; + $end + + --A comment goes before annotations + --%test() + procedure my_first_procedure; +end; +``` + +Invalid procedure annotations examples: +```sql linenums="1" +package test_package is + --%suite + + --%test() --This is wrong as there is an empty line between procedure and annotation + + procedure my_first_procedure; + + --%test() + --This is wrong as there is a comment line between procedure and annotation + procedure proc1; + + --%test() --This is wrong as there is a compiler directive between procedure and annotation + $if dbms_db_version.version >= 19 $then + procedure proc_12; + $end -There are two distinct types of annotations, identified by their location in package: -- Procedure level annotations - placed directly before a procedure (`--%test`, `--%beforeall`, `--%beforeeach` etc.). -- Package level annotations - placed at any place in package except directly before procedure (`--%suite`, `--%suitepath` etc.). + --%test() + -- procedure another_proc; + /* The above is wrong as the procedure is commented out + and annotation is not procedure annotation anymore */ +end; +``` + +### Package level annotations + +Those annotations placed at any place in package except directly before procedure (`--%suite`, `--%suitepath` etc.). We strongly recommend putting package level annotations at the very top of package except for the `--%context` annotations (described below) +Valid package annotations example: +```sql linenums="1" +package test_package is + + --%suite + + --%suitepath(org.utplsql.example) + + --%beforeall(some_package.some_procedure) + + --%context + + --%test() + procedure my_first_procedure; + --%endcontext +end; +``` + +Invalid package annotations examples: +```sql linenums="1" +package test_package is + --%suite --This is wrong as suite annotation is not a procedure annotation + procedure irrelevant; + + --%context --This is wrong as there is no empty line between package level annotation and procedure level annotation + --%test() + procedure my_first_procedure; + +end; +``` ## Supported annotations -| Annotation |Level| Description | -| --- | --- | --- | -| `--%suite()` | Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). | -| `--%suitepath()` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. | -| `--%displayname()` | Package/procedure | Human-readable and meaningful description of a context/suite/test. Provides description to a `context` when used within `context`. When used with `test` or `suite` annotation, overrides the `` provided with `suite`/`test`. | -| `--%test()` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). | -| `--%throws([,...])`| Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric contant names, exception constant names, predefined Oracle exception names. | -| `--%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. | -| `--%beforeall([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed once before all elements of the suite. | -| `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. | -| `--%afterall([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed once after all elements of the suite. | -| `--%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. | -| `--%beforeeach([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed before each `%test` procedure in the suite. | -| `--%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. | -| `--%aftereach([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed after each `%test` procedure in the suite. | -| `--%beforetest([[.].][,...])` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. | -| `--%aftertest([[.].][,...])` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. | -| `--%rollback()` | Package/procedure | Defines transaction control. Supported values: `auto`(default) - a savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | -| `--%disabled` | Package/procedure | Used to disable a suite or a test. Disabled suites/tests do not get executed, they are however marked and reported as disabled in a test run. | -| `--%context()` | Package | Denotes start of a named context (sub-suite) in a suite package | -| `--%endcontext` | Package | Denotes end of a nested context (sub-suite) in a suite package | -| `--%tags` | Package/procedure | Used to label a test or a suite for purpose of identification | +| Annotation | Level | Description | +|------------------------------------------------------------|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `--%suite( )` | Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). | +| `--%suitepath( )` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. | +| `--%displayname( )` | Package/procedure | Human-readable and meaningful description of a context/suite/test. Overrides the `` provided with `suite`/`test`/`context` annotation. This annotation is redundant and might be removed in future releases. | +| `--%test( )` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can be provided (see `displayname`). | +| `--%throws( [,...] )` | Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric constant names, exception constant names, predefined Oracle exception names. | +| `--%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. | +| `--%beforeall( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed once before all elements of the suite. | +| `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. | +| `--%afterall( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed once after all elements of the suite. | +| `--%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. | +| `--%beforeeach( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed before each `%test` procedure in the suite. | +| `--%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. | +| `--%aftereach( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed after each `%test` procedure in the suite. | +| `--%beforetest( [[.].][,...] )` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. | +| `--%aftertest( [[.].][,...] )` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. | +| `--%rollback( )` | Package/procedure | Defines transaction control. Supported values: `auto`(default) - a savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | +| `--%disabled( )` | Package/procedure | Used to disable a suite, whole context or a test. Disabled suites/contexts/tests do not get executed, they are however marked and reported as disabled in a test run. The reason that will be displayed next to disabled tests is decided based on hierarchy suites -> context -> test | +| `--%context( )` | Package | Denotes start of a named context (sub-suite) in a suite package an optional description for context can be provided. | +| `--%name( )` | Package | Denotes name for a context. Must be placed after the context annotation and before start of nested context. | +| `--%endcontext` | Package | Denotes end of a nested context (sub-suite) in a suite package | +| `--%tags` | Package/procedure | Used to label a test or a suite for purpose of identification | ### Suite @@ -46,25 +151,23 @@ The `--%suite` annotation denotes PLSQL package as a unit test suite. It accepts an optional description that will be visible when running the tests. When description is not provided, package name is displayed on report. -**Note** ->Package is considered a test-suite only when package specification contains the `--%suite` annotation at the package level. -> ->Some annotations like `--%suite`, `--%test` and `--%displayname` accept parameters. The parameters for annotations need to be placed in brackets. -Values for parameters should be provided without any quotation marks. -If the parameters are placed without brackets or with incomplete brackets, they will be ignored. -> ->Example: `--%suite(The name of suite without closing bracket` ->Example: `--%suite The name of suite without brackets` +!!! note + Package is considered a test-suite only when package specification contains the `--%suite` annotation at the package level. + Some annotations like `--%suite`, `--%test` and `--%displayname` accept parameters. The parameters for annotations need to be placed in brackets. + Values for parameters should be provided without any quotation marks. + If the parameters are placed without brackets or with incomplete brackets, they will be ignored. + Example: `--%suite(The name of suite without closing bracket` + Example: `--%suite The name of suite without brackets` Suite package without description. -```sql +```sql linenums="1" create or replace package test_package as --%suite end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -75,13 +178,13 @@ Finished in .002415 seconds ``` Suite package with description. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -92,14 +195,14 @@ Finished in .001646 seconds ``` When multiple `--%suite` annotations are specified in package, the first annotation will be used and a warning message will appear indicating duplicate annotation. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) --%suite(Bad annotation) end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -117,14 +220,14 @@ Finished in .003318 seconds ``` When `--%suite` annotation is bound to procedure, it is ignored and results in package not getting recognized as test suite. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) procedure some_proc; end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -151,7 +254,7 @@ If `--%test` raises an unhandled exception the following will happen: - test execution will continue uninterrupted for rest of the suite Test procedure without description. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -164,7 +267,7 @@ create or replace package body test_package as end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -176,7 +279,7 @@ Finished in .004109 seconds ``` Test procedure with description. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -190,7 +293,7 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -202,7 +305,7 @@ Finished in .006828 seconds ``` When multiple `--%test` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -217,7 +320,7 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -237,12 +340,13 @@ Finished in .008815 seconds ### Disabled Marks annotated suite package or test procedure as disabled. +You can provide the reason why the test is disabled that will be displayed in output. Disabling suite. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) - --%disabled + --%disabled(Reason for disabling suite) --%test(Description of tested behavior) procedure some_test; @@ -260,20 +364,65 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` Tests for a package - Description of tested behavior [0 sec] (DISABLED) - Description of another behavior [0 sec] (DISABLED) + Description of tested behavior [0 sec] (DISABLED - Reason for disabling suite) + Description of another behavior [0 sec] (DISABLED - Reason for disabling suite) Finished in .001441 seconds 2 tests, 0 failed, 0 errored, 2 disabled, 0 warning(s) ``` +Disabling the context(s). +```sql linenums="1" +create or replace package test_package as + --%suite(Tests for a package) + + --%context(Context1) + + --%test(Description of tested behavior) + procedure some_test; + + --%endcontext + + --%context(Context2) + + --%disabled(Reason for disabling context2) + + --%test(Description of another behavior) + procedure other_test; + + --%endcontext +end; +/ +create or replace package body test_package as + + procedure some_test is begin null; end; + + procedure other_test is begin null; end; +end; +/ +``` + +```sql linenums="1" +exec ut.run('test_package'); +``` +``` +Tests for a package + Context1 + Description of tested behavior [.002 sec] + Context2 + Description of another behavior [0 sec] (DISABLED - Reason for disabling context2) + +Finished in .005079 seconds +2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s) +``` + Disabling individual test(s). -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -281,7 +430,7 @@ create or replace package test_package as procedure some_test; --%test(Description of another behavior) - --%disabled + --%disabled(Reason for disabling test) procedure other_test; end; / @@ -294,13 +443,13 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` Tests for a package Description of tested behavior [.004 sec] - Description of another behavior [0 sec] (DISABLED) + Description of another behavior [0 sec] (DISABLED - Reason for disabling test) Finished in .005868 seconds 2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s) @@ -308,10 +457,10 @@ Finished in .005868 seconds ### Beforeall -There are two possible ways to use the `--%beforeall` annotation. +There are two possible ways to use the `--%beforeall` annotation. As a procedure level annotation: -```sql +```sql linenums="1" --%suite(Some test suite) --%beforeall @@ -323,7 +472,7 @@ procedure some_test; Marks annotated procedure to be executed before all test procedures in a suite. As a package level annotation (not associated with any procedure). -```sql +```sql linenums="1" --%suite(Some test suite) --%beforeall(to_be_executed_before_all, other_package.some_setup) @@ -340,6 +489,7 @@ Indicates that the procedure(s) mentioned as the annotation parameter are to be If `--%beforeall` raises an exception, suite content cannot be safely executed as the setup was not executed successfully for the suite. If `--%beforeall` raises an exception the following will happen: + - the `--%beforeall` procedures that follow the failed one, **will not be executed** - all `--%test` procedures and their `--%beforeeach`, `--%aftereach`, `--%beforetest` and `--%aftertest` procedures within suite package **will not be executed** - all `--%test` procedures **will be marked as failed** @@ -350,7 +500,7 @@ When multiple `--%beforeall` procedures are defined in a suite package, all of t For multiple `--%beforeall` procedures order of execution is defined by annotation position in the package specification. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -378,9 +528,10 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` + ``` Tests for a package --- SETUP_STUFF invoked --- @@ -392,9 +543,9 @@ Finished in .012292 seconds ``` In the below example a combination pacakge and procedure level `--%beforeall` annotations is used. -The order of execution of the beforeall procedures is determined by the annotation position in package. +The execution order of the `--%beforeall` procedures is determined by the annotation position in the package. All of the `--%beforeall` procedures get invoked before any test is executed in a suite. - ```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -443,12 +594,13 @@ All of the `--%beforeall` procedures get invoked before any test is executed in procedure other_test is begin null; end; end; / - ``` +``` - ```sql +```sql linenums="1" exec ut.run('test_package'); - ``` - ``` +``` + +``` Tests for a package --- INITIAL_SETUP invoked --- --- ANOTHER_SETUP invoked --- @@ -459,11 +611,11 @@ Tests for a package Finished in .018944 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) - ``` +``` When multiple `--%beforeall` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation. When procedure is annotated as both `--%beforeall` and `--%test`, the procedure will become a test and a warning message will appear indicating invalid annotation combination. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -494,10 +646,11 @@ When procedure is annotated as both `--%beforeall` and `--%test`, the procedure / ``` - ```sql +```sql linenums="1" exec ut.run('test_package'); - ``` - ``` +``` + +``` Tests for a package --- INITIAL_SETUP invoked --- Description of tested behavior [.003 sec] @@ -515,15 +668,17 @@ Warnings: Finished in .012158 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 2 warning(s) - ``` +``` +!!! note "Suite scope" + The `--%beforeall` procedrues in parent suite package are always part of all suite packages that are children on the suitepath. ### Afterall There are two possible ways to use the `--%afterall` annotation. As a procedure level annotation: -```sql +```sql linenums="1" --%suite(Some test suite) --%afterall @@ -535,7 +690,7 @@ procedure some_test; Marks annotated procedure to be executed after all test procedures in a suite. As a package level annotation (not associated with any procedure). -```sql +```sql linenums="1" --%suite(Some test suite) --%afterall(to_be_executed_after_all, other_package.some_cleanup) @@ -544,11 +699,12 @@ As a package level annotation (not associated with any procedure). procedure some_test; procedure to_be_executed_after_all; - ``` + Indicates that the procedure(s) mentioned as the annotation parameter are to be executed after all test procedures in a suite. If `--%afterall` raises an exception the following will happen: + - a warning will be raised, indicating that `--%afterall` procedure has failed - execution will continue uninterrupted for rest of the suite @@ -561,7 +717,7 @@ For multiple `--%afterall` procedures order of execution is defined by annotatio All rules defined for `--%beforeall` also apply for `--%afterall` annotation. See [beforeall](#Beforeall) for more details. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -589,9 +745,10 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` + ``` Tests for a package Description of tested behavior [.003 sec] @@ -602,6 +759,10 @@ Finished in .014161 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +!!! note "Suite scope" + The `--%afterall` procedrues in parent suite package are always part of all suite packages that are children on the suitepath. + + ### Beforeeach The procedure annotated as `--%beforeeach` is getting executed before each test in a suite. @@ -610,7 +771,7 @@ That means that the procedure will be executed as many times as there are test i There are two possible ways to use the `--%beforeeach` annotation. As a procedure level annotation: -```sql +```sql linenums="1" --%suite(Some test suite) --%beforeeach @@ -622,7 +783,7 @@ procedure some_test; Marks annotated procedure to be executed before each test procedures in a suite. As a package level annotation (not associated with any procedure). -```sql +```sql linenums="1" --%suite(Some test suite) --%beforeeach(to_be_executed_before_each, other_package.some_setup) @@ -631,14 +792,15 @@ As a package level annotation (not associated with any procedure). procedure some_test; procedure to_be_executed_before_each; - ``` + Indicates that the procedure(s) mentioned as the annotation parameter are to be executed before each test procedure in a suite. If a test is marked as disabled the `--%beforeeach` procedure is not invoked for that test. If `--%beforeeach` raises an unhandled exception the following will happen: + - the following `--%beforeeach` as well as all `--%beforetest` for that test **will not be executed** - the test will be marked as errored and exception stack trace will be captured and reported - the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test @@ -651,7 +813,7 @@ When multiple `--%beforeeach` procedures are defined in a suite, all of them wil For multiple `--%beforeeach` procedures order of execution is defined by annotation position in the package specification. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -692,9 +854,10 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` + ``` Tests for a package ---SETUP_STUFF invoked --- @@ -709,6 +872,9 @@ Finished in .014683 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +!!! note "Package scope" + Unlike `--%beforeall`, the `--%beforeeach` annotation is only applicable within the scope of current test suite package. The `--%beforeeach` annotations from parent suite package are ignored. + See [beforeall](#Beforeall) for more examples. ### Aftereach @@ -721,7 +887,7 @@ That means that the procedure will be executed as many times as there are test i There are two possible ways to use the `--%aftereach` annotation. As a procedure level annotation: -```sql +```sql linenums="1" --%suite(Some test suite) --%aftereach @@ -733,7 +899,7 @@ procedure some_test; Marks annotated procedure to be executed after each test procedures in a suite. As a package level annotation (not associated with any procedure). -```sql +```sql linenums="1" --%suite(Some test suite) --%aftereach(to_be_executed_after_each, other_package.some_setup) @@ -742,13 +908,14 @@ As a package level annotation (not associated with any procedure). procedure some_test; procedure to_be_executed_after_each; - ``` + Indicates that the procedure(s) mentioned as the annotation parameter are to be executed after each test procedure in a suite. If a test is marked as disabled the `--%aftereach` procedure is not invoked for that test. If `--%aftereach` raises an unhandled exception the following will happen: + - the test will be marked as errored and exception stack trace will be captured and reported - the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test - the `--%afterall` procedures **will be executed** @@ -760,7 +927,7 @@ For multiple `--%aftereach` procedures order of execution is defined by the anno As a rule, the `--%aftereach` gets executed even if the associated `--%beforeeach`, `--%beforetest`, `--%test` or other `--%aftereach` procedures have raised unhandled exceptions. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -800,7 +967,7 @@ create or replace package body test_package as end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -817,11 +984,15 @@ Finished in .018115 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +!!! note "Package scope" + Unlike `--%afterall`, the `--%aftereach` annotation is only applicable within the scope of current test suite package. The `--%aftereach` annotations from parent suite package are ignored. + See [beforeall](#Beforeall) for more examples. ### Beforetest Indicates specific setup procedure(s) to be executed for a test. The procedure(s) can be located either: + - within current package (package name is optional) - within another package @@ -832,6 +1003,7 @@ The `--%beforetest` procedures are executed after invoking all `--%beforeeach` f If a test is marked as disabled the `--%beforetest` procedures are not invoked for that test. If `--%beforetest` raises an unhandled exception the following will happen: + - the following `--%beforetest` for that test **will not be executed** - the test will be marked as errored and exception stack trace will be captured and reported - the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test @@ -841,12 +1013,13 @@ If `--%beforetest` raises an unhandled exception the following will happen: When multiple `--%beforetest` procedures are defined for a test, all of them will be executed before invoking the test. The order of execution for `--%beforetest` procedures is defined by: + - position of procedure on the list within single annotation - annotation position As a rule, the `--%beforetest` execution gets aborted if preceding `--%beforeeach` or `--%beforetest` failed. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -888,7 +1061,7 @@ create or replace package body test_package as end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -910,6 +1083,7 @@ Finished in .015185 seconds ### Aftertest Indicates specific cleanup procedure(s) to be executed for a test. The procedure(s) can be located either: + - within current package (package name is optional) - within another package @@ -918,20 +1092,22 @@ The annotation need to be placed alongside `--%test` annotation. If a test is marked as disabled the `--%aftertest` procedures are not invoked for that test. If `--%aftertest` raises an unhandled exception the following will happen: + - the test will be marked as errored and exception stack trace will be captured and reported - the following `--%aftertest` and all `--%aftereach` procedures **will be executed** for the errored test - the `--%afterall` procedures **will be executed** - test execution will continue uninterrupted for rest of the suite -When multiple `--%aftertest` procedures are defined for a test, all of them will be executed before invoking the test. +When multiple `--%aftertest` procedures are defined for a test, all of them will be executed after invoking the test. The order of execution for `--%aftertest` procedures is defined by: + - position of procedure on the list within single annotation - annotation position As a rule, the `--%aftertest` gets executed even if the associated `--%beforeeach`, `--%beforetest`, `--%test` or other `--%aftertest` procedures have raised unhandled exceptions. -```sql +```sql linenums="1" create or replace package test_package as --%suite(Tests for a package) @@ -973,7 +1149,7 @@ create or replace package body test_package as end; / ``` -```sql +```sql linenums="1" exec ut.run('test_package'); ``` ``` @@ -997,9 +1173,9 @@ In most of the cases, the code to be tested is consisting of PLSQL packages cont When creating test suites, it's quite common to maintain `one to one` relationship between test suite packages and tested code. When it comes to test procedures themselves, it is best practice to have one test procedure for one tested behavior of the code that is tested. -The relationship between test procedure and tested procedure/function will be therefore `many to one` in most of the cases. +The relationship between test procedure and tested code will be therefore `many to one` or `many to many` in most of the cases. -With this comes a challenge. How to group tests, related to one tested procedure, so that it is obvious that they relate to the same code. +With this comes a challenge. How to group tests, related to one tested behavior, so that it is obvious that they relate to the same thing. This is where utPLSQL contexts come handy. @@ -1008,19 +1184,25 @@ Contexts allow for creating sub-suites within a suite package and they allow for In essence, context behaves like a suite within a suite. Context have following characteristics: -- start with the `--%context` annotation and ends with `--%endcontext` -- can have a name provided as parameter for example `--%context(remove_rooms_by_name)` -- when no name is provided for context, the context is names `context_N` where `N` is the number of the context in suite -- can have their own `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures -- `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures defined at suite level, propagate to context -- test suite package can have multiple contexts in it -- contexts cannot be nested +- context starts with the `--%context` annotation and ends with `--%endcontext`. Everything placed between those two annotations belongs to that context +- can have a description provided as parameter for example `--%context(Some interesting stuff)`. +- can have a name provided with `--%name` annotation. This is different than with `suite` and `test` annotations, where name is taken from `package/procedure` name. +- contexts can be nested, you can place a context inside another context +- when no name is provided for context, the context is named `context_N` where `N` is the number of the context in suite or parent context. +- context name must be unique within it's parent (suite / parent context) +- if context name is not unique within it's parent, context and it's entire content is excluded from execution +- context name should not contain spaces or special characters +- context name cannot contain a `.` (full stop/period) character +- suite/context can have multiple nested sibling contexts in it +- contexts can have their own `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures +- `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures defined at ancestor level, propagate to context +- if `--%endcontext` is missing for a context, the context spans to the end of package specification The below example illustrates usage of `--%context` for separating tests for individual procedures of package. -Tested tables and code -```sql +Sample tables and code +```sql linenums="1" create table rooms ( room_key number primary key, name varchar2(100) not null @@ -1077,11 +1259,12 @@ end; ``` Below test suite defines: + - `--%beforeall` outside of context, that will be executed before all tests -- `--%context(remove_rooms_by_name)` to group tests for `remove_rooms_by_name` procedure -- `--%context(add_rooms_content)` to group tests for `add_rooms_content` procedure +- `--%context(remove_rooms_by_name)` to group tests related to `remove_rooms_by_name` functionality +- `--%context(add_rooms_content)` to group tests related to `add_rooms_content` functionality -```sql +```sql linenums="1" create or replace package test_rooms_management is gc_null_value_exception constant integer := -1400; @@ -1103,7 +1286,6 @@ create or replace package test_rooms_management is --%endcontext - --%context(add_rooms_content) --%displayname(Add content to a room) @@ -1201,8 +1383,8 @@ end; / ``` -When te tests are executed -```sql +When the tests are executed +```sql linenums="1" exec ut.run('test_rooms_management'); ``` The following report is displayed @@ -1221,97 +1403,248 @@ Finished in .035261 seconds 5 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +Example of nested contexts test suite specification. +*Source - [slide 145](https://www.slideshare.net/Kevlin/structure-and-interpretation-of-test-cases/145?src=clipshare) of Structure and Interpretation of Test Cases by Kevlin Henney* +```sql linenums="1" +create or replace package queue_spec as + --%suite(Queue specification) -### Tags + --%context(A new queue) -Tag is a label attached to the test or a suite path. It is used for identification and execution a group of tests / suites that share same tag. + --%test(Is empty) + procedure is_empty; + --%test(Preserves positive bounding capacity) + procedure positive_bounding_capacity; + --%test(Cannot be created with non positive bounding capacity) + procedure non_positive_bounding_cap; + --%endcontext + --%context(An empty queue) + + --%test(Dequeues an empty value) + procedure deq_empty_value; + --%test(Remains empty when null enqueued) + procedure empty_with_null_enq; + --%test(Becomes non empty when non null value enqueued) + procedure non_empty_after_enq; + --%endcontext + --%context(A non empty queue) + + --%context(that is not full) + + --%test(Becomes longer when non null value enqueued) + procedure grow_on_enq_non_null; + --%test(Becomes full when enqueued up to capacity) + procedure full_on_enq_to_cap; + --%endcontext + --%context(that is full) + + --%test(Ignores further enqueued values) + procedure full_ignore_enq; + --%test(Becomes non full when dequeued) + procedure non_full_on_deq; + --%endcontext + + --%test(Dequeues values in order enqueued) + procedure dequeue_ordered; + --%test(Remains unchanged when null enqueued) + procedure no_change_on_null_enq; + --%endcontext +end; +``` -It allows us to group a tests / suites using a various categorization and place a test / suite in multiple buckets. Same tests can be group with other tests based on the functionality , frequency, type of output etc. -e.q. +When such specification gets executed `ut.run('queue_spec'')` (without body created) you will see the nesting of tests within contexts. +``` +Queue specification + An empty queue + Dequeues an empty value [.014 sec] (FAILED - 1) + Remains empty when null enqueued [.004 sec] (FAILED - 2) + Becomes non empty when non null value enqueued [.005 sec] (FAILED - 3) + A non empty queue + that is not full + Becomes longer when non null value enqueued [.005 sec] (FAILED - 4) + Becomes full when enqueued up to capacity [.005 sec] (FAILED - 5) + That is full + Ignores further enqueued values [.004 sec] (FAILED - 6) + Becomes non full when dequeued [.005 sec] (FAILED - 7) + Dequeues values in order enqueued [.006 sec] (FAILED - 8) + Remains unchanged when null enqueued [.004 sec] (FAILED - 9) + A new queue + Is empty [.007 sec] (FAILED - 10) + Preserves positive bounding capacity [.006 sec] (FAILED - 11) + Cannot be created with non positive bounding capacity [.005 sec] (FAILED - 12) +Failures: + 1) deq_empty_value + ORA-04067: not executed, package body "UT3.QUEUE_SPEC" does not exist + ORA-06508: PL/SQL: could not find program unit being called: "UT3.QUEUE_SPEC" + ORA-06512: at line 6 +... +Finished in .088573 seconds +12 tests, 0 failed, 12 errored, 0 disabled, 0 warning(s) +``` -```sql ---%tags(batch,daily,csv) -``` +Suite nesting allows for organizing tests into human-readable specification of behavior. -or +### Name +The `--%name` annotation is currently only used only for naming a context. +If a context doesn't have explicit name specified, then the name is given automatically by framework. -```sql ---%tags(api,online,json) -``` +The automatic name will be `context_#n` where `n` is a context number within a suite/parent context. +The `--%name` can be useful when you would like to run only a specific context or its items by `suitepath`. +Consider the below example. -Tags are defined as a coma separated list. When executing a test run with tag filter applied, framework will find all tests associated with given tags and execute them. Framework applies `OR` logic when resolving a tags so any tests / suites that match at least one tag will be included in the test run. +```sql linenums="1" +create or replace package queue_spec as + --%suite(Queue specification) -When a suite gets tagged all of its children will automatically inherit a tag and get executed along the parent. Parent suit tests are not executed. but a suitepath hierarchy is kept. + --%context(A new queue) -Sample tag package. + --%test(Cannot be created with non positive bounding capacity) + procedure non_positive_bounding_cap; + --%endcontext + --%context(An empty queue) -```sql -create or replace package ut_sample_test IS + --%test(Becomes non empty when non null value enqueued) + procedure non_empty_after_enq; + --%endcontext + --%context(A non empty queue) - --%suite(Sample Test Suite) - --%tag(suite1) + --%context(that is not full) - --%test(Compare Ref Cursors) - --%tag(test1,sample) - procedure ut_refcursors1; + --%test(Becomes full when enqueued up to capacity) + procedure full_on_enq_to_cap; + --%endcontext + --%context(that is full) - --%test(Run equality test) - --%tag(test2,sample) - procedure ut_test; - -end ut_sample_test; -/ + --%test(Becomes non full when dequeued) + procedure non_full_on_deq; + --%endcontext -create or replace package body ut_sample_test is + --%endcontext +end; +``` - procedure ut_refcursors1 is - v_actual sys_refcursor; - v_expected sys_refcursor; - begin - open v_expected for select 1 as test from dual; - open v_actual for select 2 as test from dual; +In the above code, suitepaths, context names and context descriptions will be as follows. - ut.expect(v_actual).to_equal(v_expected); - end; - - procedure ut_test is - begin - ut.expect(1).to_equal(0); - end; - -end ut_sample_test; -/ +| suitepath | description | name | +|----------------------------------|----------------------|------------| +| queue_spec | Queue specification | queue_spec | +| queue_spec.context_#1 | A new queue | context_#1 | +| queue_spec.context_#2 | An empty queue | context_#2 | +| queue_spec.context_#3 | A non empty queue | context_#3 | +| queue_spec.context_#3.context_#1 | that is not full | context_#1 | +| queue_spec.context_#3.context_#2 | that is full | context_#2 | + +In order to run only the tests for the context `A non empty queue that is not full` you will need to call utPLSQL as below: +```sql linenums="1" + exec ut.run(':queue_spec.context_#3.context_#1'); ``` -Execution of the test is done by using a parameter `a_tags` +You can use `--%name` annotation to explicitly name contexts on suitepath. +```sql linenums="1" +create or replace package queue_spec as + --%suite(Queue specification) -```sql -select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'suite1')); -select * from table(ut.run(a_tags => 'test1,test2')); -select * from table(ut.run(a_tags => 'sample')); + --%context(A new queue) + --%name(a_new_queue) -begin - ut.run(a_path => 'ut_sample_test',a_tags => 'suite1'); + --%test(Cannot be created with non positive bounding capacity) + procedure non_positive_bounding_cap; + --%endcontext + --%context(An empty queue) + --%name(an_empty_queue) + + --%test(Becomes non empty when non null value enqueued) + procedure non_empty_after_enq; + --%endcontext + --%context(A non empty queue) + --%name(a_non_empty_queue) + + --%context(that is not full) + --%name(that_is_not_full) + + --%test(Becomes full when enqueued up to capacity) + procedure full_on_enq_to_cap; + --%endcontext + --%context(that is full) + --%name(that_is_full) + + --%test(Becomes non full when dequeued) + procedure non_full_on_deq; + --%endcontext + + --%endcontext end; -/ +``` + +In the above code, suitepaths, context names and context descriptions will be as follows. + +| suitepath | description | name | +|-----------------------------------------------|-----------------------|-------------------| +| queue_spec | Queue specification | queue_spec | +| queue_spec.a_new_queue | A new queue | a_new_queue | +| queue_spec.an_empty_queue | An empty queue | an_empty_queue | +| queue_spec.a_non_empty_queue | A non empty queue | a_non_empty_queue | +| queue_spec.a_non_empty_queue.that_is_not_full | that is not full | that_is_not_full | +| queue_spec.a_non_empty_queue.that_is_full | that is full | that_is_full | + + +The `--%name` annotation is only relevant for: + +- running subsets of tests by given context suitepath +- some of test reports, like `ut_junit_reporter` that use suitepath or test-suite element names (not descriptions) for reporting + +#### Name naming convention + +The value of `--%name` annotation must follow the following naming rules: -exec ut.run('ut_sample_test', a_tags => 'sample'); +- cannot contain spaces +- cannot contain a `.` (full stop/dot) +- is case-insensitive + +### Tags + +Tag is a label attached to the test or a suite. It is used for identification and execution of a group of tests / suites that share the same tag. + +It allows for grouping of tests / suites using various categorization and place tests / suites in multiple buckets. Same tests can be grouped with other tests based on the functionality , frequency, type of output etc. + +e.g. + +```sql linenums="1" +--%tags(batch,daily,csv) ``` +or + +```sql linenums="1" +--%tags(online,json) +--%tags(api) +``` + +Tags are defined as a comma separated list within the `--%tags` annotation. +When a suite/context is tagged, all of its children will automatically inherit the tag and get executed along with the parent, unless they are excluded explicitly at runtime with a negated tag expression. +See [running unit tests](running-unit-tests.md) for more information on using tags to filter test suites that are to be executed. -Tags should adhere to following rules: +#### Tag naming convention -- tags are case sensitive -- tags cannot be an empty string -- tags cannot contain spaces e.g. to create a multi-word `tag` please use underscores,dashes, dots etc. e.g. `test_of_batch` -- tags with empty spaces will be ignored during execution -- tags can contain special characters +Tags must follow the below naming convention: +- tag is case sensitive +- tag must not contain any of the following reserved characters: + - comma (,) + - left or right parenthesis ((, )) + - ampersand (&) + - vertical bar (|) + - exclamation point (!) +- tag cannot be null or blank +- tag cannot start with a dash, e.g. `-some-stuff` is **not** a valid tag +- tag cannot contain spaces, e.g. `test of batch`. To create a multi-word tag use underscores or dashes, e.g. `test_of_batch`, `test-of-batch` +- leading and trailing spaces are ignored in tag name, e.g. `--%tags( tag1 , tag2 )` becomes `tag1` and `tag2` tag names +- tag cannot be one of two reserved words: `none` and `any`. `none` and `any` as a tag will be treated as no tag ### Suitepath @@ -1331,9 +1664,10 @@ If you want to create tests for your application it is recommended to structure * Payments recognition * Payments set off -The `%suitepath` annotation is used for such grouping. Even though test packages are defined in a flat structure the `%suitepath` is used by the framework to form them into a hierarchical structure. Your payments recognition test package might look like: +The `--%suitepath` annotation is used for such grouping. Even though test packages are defined in a flat structure the `--%suitepath` is used by the framework to form them into a hierarchical structure. -```sql +Your payments recognition test package might look like: +```sql linenums="1" create or replace package test_payment_recognition as --%suite(Payment recognition tests) @@ -1352,7 +1686,7 @@ end test_payment_recognition; ``` And payments set off test package: -```sql +```sql linenums="1" create or replace package test_payment_set_off as --%suite(Payment set off tests) @@ -1367,11 +1701,15 @@ create or replace package test_payment_set_off as end test_payment_set_off; ``` -When you execute tests for your application, the framework constructs a test suite for each test package. Then it combines suites into grouping suites by the `%suitepath` annotation value so that the fully qualified path to the `recognize_by_num` procedure is `USER:payments.test_payment_recognition.test_recognize_by_num`. If any of its expectations fails then the test is marked as failed, also the `test_payment_recognition` suite, the parent suite `payments` and the whole run is marked as failed. -The test report indicates which expectation has failed on the payments module. The payments recognition submodule is causing the failure as `recognize_by_num` has not met the expectations of the test. Grouping tests into modules and submodules using the `%suitepath` annotation allows you to logically organize your project's flat structure of packages into functional groups. +When you execute tests for your application, the framework constructs a test suite for each test package. Then it combines suites into grouping suites by the `--%suitepath` annotation value so that the fully qualified path to the `recognize_by_num` procedure is `USER:payments.test_payment_recognition.test_recognize_by_num`. If any of its expectations fails then the test is marked as failed, also the `test_payment_recognition` suite, the parent suite `payments` and the whole run is marked as failed. +The test report indicates which expectation has failed on the payments module. The payments recognition submodule is causing the failure as `recognize_by_num` has not met the expectations of the test. Grouping tests into modules and submodules using the `--%suitepath` annotation allows you to logically organize your project's flat structure of packages into functional groups. + +!!! note "Suitepath limits" + - A suitepath can have at most 20 levels (elements separated by dots), for example `org.utplsql.example` has 3. Suites with a deeper suitepath are not run and not listed. + - The full path of every suite item (suitepath, package, contexts and test name) can be at most 1000 characters long. Longer paths raise an error when the suites are built. An additional advantage of such grouping is the fact that every element level of the grouping can be an actual unit test package containing a common module level setup for all of the submodules. So in addition to the packages mentioned above you could have the following package. -```sql +```sql linenums="1" create or replace package payments as --%suite(Payments) @@ -1384,11 +1722,15 @@ create or replace package payments as end payments; ``` -A `%suitepath` can be provided in three ways: + +When executing tests, `path` for executing tests can be provided in three ways: + * schema - execute all tests in the schema -* [schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests in all suites from suite1[.suite2][.suite3]...[.procedure] path. If schema is not provided, then the current schema is used. Example: `:all.rooms_tests` +* [schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests by `suitepath` in all suites on path suite1[.suite2][.suite3]...[.procedure]. If schema is not provided, then the current schema is used. Example: `:all.rooms_tests` * [schema.]package[.procedure] - execute all tests in the specified test package. The whole hierarchy of suites in the schema is built before all before/after hooks or part suites for the provided suite package are executed as well. Example: `tests.test_contact.test_last_name_validator` or simply `test_contact.test_last_name_validator` if `tests` is the current schema. +!!! note + Only the `beforeall` and `afterall` hooks of the parent suite are executed for the suite package. The `beforeeach` and `aftereach` hooks of the suite package are not executed. ### Rollback @@ -1414,23 +1756,24 @@ Doing so allows your tests to use the framework's automatic transaction control When you are testing code that performs explicit or implicit commits, you may set the test procedure to run as an autonomous transaction with `pragma autonomous_transaction`. Keep in mind that when your test runs as autonomous transaction it will not see the data prepared in a setup procedure unless the setup procedure committed the changes. -**Note** -> The `--%suitepath` annotation, when used, must be provided with a value of path. -> The path in suitepath cannot contain spaces. Dot (.) identifies individual elements of the path. -> -> Example: `--%suitepath(org.utplsql.core.utils)` -> +!!! note + The `--%rollback(manual)` annotation is only relevant for suites that use shared setup/cleanup with beforeall, + The `--%suitepath` annotation, when used, must be provided with a value of path. + The path in suitepath cannot contain spaces. Dot (.) identifies individual elements of the path. + Example: `--%suitepath(org.utplsql.core.utils)` + ### Throws The `--%throws` annotation allows you to specify a list of exceptions as one of: + - number literals - example `--%throws(-20134)` -- variables of type exception defined in a package specification - example `--%throws(exc_pkg.c_exception_No_variable)` -- variables of type number defined in a package specification - example `--%throws(exc_pkg.c_some_exception)` -- [predefined oracle exceptions](https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm#CIHFIGFE) - example `--%throws(no_data_found)` +- variables of type `exception` defined in a package specification - example `--%throws(exc_pkg.c_exception_no_variable)` +- variables or constants of containing a valid negative exception number defined in a package specification - example `--%throws(exc_pkg.c_some_exception)` +- [predefined oracle exceptions](https://docs.oracle.com/en//database/oracle/oracle-database/19/lnpls/predefined-exceptions.html) - example `--%throws(no_data_found)` -The annotation is ignored, when no valid arguments are provided. Examples of invalid annotations `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. +The annotation is ignored when no valid arguments are provided. Examples of invalid annotations `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. If `--%throws` annotation is specified with arguments and no exception is raised, the test is marked as failed. @@ -1441,22 +1784,30 @@ The framework will raise a warning, when `--%throws` annotation has invalid argu Annotation `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`. Please note that `NO_DATA_FOUND` exception is a special case in Oracle. To capture it use `NO_DATA_FOUND` named exception or `-1403` exception No. -​ + +Syntax: `--%throws( [[schema.]package.]exception [, ... ])` + +The exception name can be provided with or without the schema and package name. The package name is required only when the exception variable is located in another package than the unit test package. The schema name is required only when the exception variable is located in a package in another schema. + Example: -```sql +```sql linenums="1" create or replace package exc_pkg is c_e_option1 constant number := -20200; c_e_option2 constant varchar2(10) := '-20201'; - c_e_option3 number := -20202; - - e_option4 exception; - pragma exception_init(e_option4, -20203); + c_e_option3 integer := -20202; + e_initialized_exception exception; + pragma exception_init(e_initialized_exception, -20203); + + e_uninitialized_exception exception; end; / create or replace package example_pgk as + e_local_exception exception; + e_local_exception_num constant integer := -20123; + --%suite(Example Throws Annotation) --%test(Throws one of the listed exceptions) @@ -1487,10 +1838,22 @@ create or replace package example_pgk as --%throws(exc_pkg.c_e_option3) procedure raised_option3_exception; - --%test(Throws package exception option4) - --%throws(exc_pkg.e_option4) - procedure raised_option4_exception; + --%test(Throws exception associated with exception number) + --%throws(exc_pkg.e_initialized_exception) + procedure raised_initialized_exception; + + --%test(Throws uninitialized exception) + --%throws(exc_pkg.e_uninitialized_exception) + procedure raised_uninitialized_exception; + --%test(Throws exception local to unit tests package) + --%throws(e_local_exception) + procedure raised_local_exception; + + --%test(Throws exception local to unit tests package with exception number) + --%throws(e_local_exception_num) + procedure raised_local_exception_num; + --%test(Raise name exception) --%throws(DUP_VAL_ON_INDEX) procedure raise_named_exc; @@ -1501,6 +1864,7 @@ create or replace package example_pgk as end; / + create or replace package body example_pgk is procedure raised_one_listed_exception is begin @@ -1537,11 +1901,28 @@ create or replace package body example_pgk is raise_application_error(exc_pkg.c_e_option3, 'Test error'); end; - procedure raised_option4_exception is + procedure raised_initialized_exception is + begin + raise exc_pkg.e_initialized_exception; + end; + + procedure raised_uninitialized_exception is begin - raise exc_pkg.e_option4; + raise exc_pkg.e_uninitialized_exception; end; + procedure raised_local_exception is + pragma autonomous_transaction; + begin + raise e_local_exception; + end; + + procedure raised_local_exception_num is + pragma autonomous_transaction; + begin + raise_application_error(e_local_exception_num, 'Test error'); + end; + procedure raise_named_exc is begin raise DUP_VAL_ON_INDEX; @@ -1560,53 +1941,60 @@ exec ut3.ut.run('example_pgk'); Running the test will give report: ``` Example Throws Annotation - Throws one of the listed exceptions [.002 sec] - Throws different exception than expected [.002 sec] (FAILED - 1) - Throws different exception than listed [.003 sec] (FAILED - 2) - Gives failure when an exception is expected and nothing is thrown [.002 sec] (FAILED - 3) - Throws package exception option1 [.003 sec] - Throws package exception option2 [.002 sec] - Throws package exception option3 [.002 sec] - Throws package exception option4 [.002 sec] - Raise name exception [.002 sec] - Invalid throws annotation [.002 sec] - + Throws one of the listed exceptions [,026 sec] + Throws different exception than expected [,009 sec] (FAILED - 1) + Throws different exception than listed [,014 sec] (FAILED - 2) + Gives failure when an exception is expected and nothing is thrown [,016 sec] (FAILED - 3) + SUCCESS + Actual: 1 (number) was expected to equal: 1 (number) + Throws package exception option1 [,007 sec] + Throws package exception option2 [,008 sec] + Throws package exception option3 [,007 sec] + Throws exception associated with exception number [,006 sec] + Throws uninitialized exception [,006 sec] + Throws exception local to unit tests package [,009 sec] + Throws exception local to unit tests package with exception number [,011 sec] + Raise name exception [,006 sec] + Invalid throws annotation [,004 sec] + Failures: - + 1) raised_different_exception Actual: -20143 was expected to equal: -20144 ORA-20143: Test error - ORA-06512: at "UT3.EXAMPLE_PGK", line 9 - ORA-06512: at "UT3.EXAMPLE_PGK", line 9 - ORA-06512: at line 6 - + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 9 + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 9 + ORA-06512: at line 7 + 2) raised_unlisted_exception Actual: -20143 was expected to be one of: (-20144, -1, -20145) ORA-20143: Test error - ORA-06512: at "UT3.EXAMPLE_PGK", line 14 - ORA-06512: at "UT3.EXAMPLE_PGK", line 14 - ORA-06512: at line 6 - + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 14 + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 14 + ORA-06512: at line 7 + 3) nothing_thrown Expected one of exceptions (-20459, -20136, -20145) but nothing was raised. - - + + Warnings: - - 1) example_pgk + + 1) example_pgk.raised_one_listed_exception Invalid parameter value "bad" for "--%throws" annotation. Parameter ignored. - at "UT3.EXAMPLE_PGK.RAISED_ONE_LISTED_EXCEPTION", line 6 + at package "UT3_TESTER.EXAMPLE_PGK.RAISED_ONE_LISTED_EXCEPTION", line 8 + 2) example_pgk "--%throws" annotation requires a parameter. Annotation ignored. - at "UT3.EXAMPLE_PGK.BAD_THROWS_ANNOTATION", line 42 - -Finished in .025784 seconds -10 tests, 3 failed, 0 errored, 0 disabled, 2 warning(s) + at package "UT3_TESTER.EXAMPLE_PGK.BAD_THROWS_ANNOTATION", line 57 + +Finished in ,138276 seconds +13 tests, 3 failed, 0 errored, 0 disabled, 2 warning(s) + ``` ## Order of execution -```sql +```sql linenums="1" create or replace package test_employee_pkg is --%suite(Employee management) @@ -1728,39 +2116,50 @@ When processing the test suite `test_employee_pkg` defined in [Example of annota rollback to savepoint 'before-suite' ``` -**Note** ->utPLSQL does not guarantee ordering of tests in suite. On contrary utPLSQL might give random order of tests/contexts in suite. -> ->Order of execution within multiple occurrences of `before`/`after` procedures is determined by the order of annotations in specific block (context/suite) of package specification. +!!! note + utPLSQL does not guarantee ordering of tests in suite. On contrary utPLSQL might give random order of tests/contexts in suite.
+ Order of execution within multiple occurrences of `before`/`after` procedures is determined by the order of annotations in specific block (context/suite) of package specification. ## sys_context -It is possible to access information about currently running suite, test and befire/after procedure form within PLSQL procedure using SYS_CONTEXT. - +It is possible to access information about currently running suite. The information is available by calling `sys_context( 'UT3_INFO', attribute )`. +It can be accessed from any procedure invoked as part of utPLSQL test execution. + +!!! note + Context name is derived from schema name where utPLSQL is installed.
+ The context name in below examples represents the default install schema -> `UT3`
+ If you install utPLSQL into another schema the context name will be different.
+ For example if utPLSQL is installed into `HR` schema, the context name will be `HR_INFO` Following attributes are populated: -- Always: - - `sys_context( 'UT3_INFO', 'RUN_PATHS' );` - list of suitepaths / suitenames used as input parameters for call to `ut.run(...)` or `ut_runner.run(...)` - - `sys_context( 'UT3_INFO', 'SUITE_DESCRIPTION' );` - the description of test suite that is currently being executed - - `sys_context( 'UT3_INFO', 'SUITE_PACKAGE' );` - the owner and name of test suite package that is currently being executed - - `sys_context( 'UT3_INFO', 'SUITE_PATH' );` - the suitepath for the test suite package that is currently being executed - - `sys_context( 'UT3_INFO', 'SUITE_START_TIME' );` - the execution start timestamp of test suite package that is currently being executed - - `sys_context( 'UT3_INFO', 'CURRENT_EXECUTABLE_NAME' );` - the owner.package.procedure of currently running test suite executable - - `sys_context( 'UT3_INFO', 'CURRENT_EXECUTABLE_TYPE' );` - the type of currently running test suite executable (one of: `beforeall`, `beforeeach`, `beforetest`, `test`, `aftertest`, `aftereach`, `afterall` - -- When running in suite context - - `sys_context( 'UT3_INFO', 'CONTEXT_DESCRIPTION' );` - the description of test suite context that is currently being executed - - `sys_context( 'UT3_INFO', 'CONTEXT_NAME' );` - the name of test suite context that is currently being executed - - `sys_context( 'UT3_INFO', 'CONTEXT_PATH' );` - the suitepath for the currently executed test suite context - - `sys_context( 'UT3_INFO', 'CONTEXT_START_TIME' );` - the execution start timestamp for the currently executed test suite context -- When running a suite executable procedure that is a `test` or `beforeeach`, `aftereach`, `beforetest`, `aftertest` - - `sys_context( 'UT3_INFO', 'TEST_DESCRIPTION' );` - the description of test for which the current executable is being invoked - - `sys_context( 'UT3_INFO', 'TEST_NAME' );` - the name of test for which the current executable is being invoked - - `sys_context( 'UT3_INFO', 'TEST_START_TIME' );` - the execution start timestamp of test that is currently being executed (the time when first `beforeeach`/`beforetest` was called for that test) + +| Name | Scope | Description | +|-------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| +| COVERAGE_RUN_ID | run | Value of COVERAGE_RUN_ID used by utPLSQL internally for coverage gathering | +| RUN_PATHS | run | list of suitepaths / suitenames used as input parameters for call to `ut.run(...)` or `ut_runner.run(...)` | +| SUITE_DESCRIPTION | run | the description of test suite that is currently being executed | +| SUITE_PACKAGE | run | the owner and name of test suite package that is currently being executed | +| SUITE_PATH | run | the suitepath for the test suite package that is currently being executed | +| SUITE_START_TIME | run | the execution start timestamp of test suite package that is currently being executed | +| CURRENT_EXECUTABLE_NAME | run | the owner.package.procedure of currently running test suite executable | +| CURRENT_EXECUTABLE_TYPE | run | the type of currently running test suite executable (one of: `beforeall`, `beforeeach`, `beforetest`, `test`, `aftertest`, `aftereach`, `afterall` | + | CONTEXT_DESCRIPTION | suite context | the description of test suite context that is currently being executed | + | CONTEXT_NAME | suite context | the name of test suite context that is currently being executed | + | CONTEXT_PATH | suite context | the suitepath for the currently executed test suite context | + | CONTEXT_START_TIME | suite context | the execution start timestamp for the currently executed test suite context | +| TEST_DESCRIPTION | test* | the description of test for which the current executable is being invoked | +| TEST_NAME | test* | the name of test for which the current executable is being invoked | +| TEST_START_TIME | test* | the execution start timestamp of test that is currently being executed (the time when first `beforeeach`/`beforetest` was called for that test) | + +!!! note "Scopes" + - run - context information is available in any element of test run
+ - suite context - context information is available in any element nested within a suite context
+ - test* - context information is available when executing following procedure types: test, beforetest, aftertest, beforeeach or aftereach + Example: -```sql +```sql linenums="1" create or replace procedure which_procecure_called_me is begin dbms_output.put_line( @@ -1819,7 +2218,7 @@ end; / ``` -```sql +```sql linenums="1" exec ut.run('test_call'); ``` @@ -1852,14 +2251,14 @@ If you are in a situation where your database is controlled via CI/CD server and To build the annotation cache without actually invoking any tests, call `ut_runner.rebuild_annotation_cache(a_object_owner)` for every unit test owner for which you want to have the annotation cache prebuilt. Example: -```sql +```sql linenums="1" exec ut_runner.rebuild_annotation_cache('HR'); ``` To purge the annotation cache call `ut_runner.purge_cache(a_object_owner, a_object_type)`. Both parameters are optional and if not provided, all owners/object_types will be purged. Example: -```sql +```sql linenums="1" exec ut_runner.purge_cache('HR', 'PACKAGE'); ``` diff --git a/docs/userguide/best-practices.md b/docs/userguide/best-practices.md index 36acc19f6..ff7e26fdb 100644 --- a/docs/userguide/best-practices.md +++ b/docs/userguide/best-practices.md @@ -1,6 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -# Best Practices +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) The following are best practices we at utPLSQL have learned about PL/SQL and Unit Testing. @@ -17,9 +15,9 @@ The following are best practices we at utPLSQL have learned about PL/SQL and Uni - Tests should not mimic / duplicate the logic of tested code - Tests should contain zero logic (or as close to zero as possible) - The 3A rule: - - Arrange (setup inputs/data/environment for the tested code) - - Act (execute code under test) - - Assert (validate the outcomes of the execution) + - Arrange (setup inputs/data/environment for the tested code) + - Act (execute code under test) + - Assert (validate the outcomes of the execution) - Each tested procedure/function/trigger (code block) should have more than one test - Each test should check only one behavior (one requirement) of the code block under test - Tests should be maintained as thoroughly as production code diff --git a/docs/userguide/coverage.md b/docs/userguide/coverage.md index 89098ecaf..6dd9a233c 100644 --- a/docs/userguide/coverage.md +++ b/docs/userguide/coverage.md @@ -1,28 +1,34 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) -# Coverage -utPLSQL comes with a built-in coverage reporting engine. The code coverage reporting is based on the DBMS_PROFILER package provided with Oracle database. +utPLSQL comes with a built-in coverage reporting engine. The code coverage reporting combines data from package DBMS_PROFILER and DBMS_PLSQL_CODE_COVERAGE. Code coverage is gathered for the following source types: + * package bodies * type bodies * triggers * procedures * functions -**Note** +!!! note -> The package and type specifications are explicitly excluded from code coverage analysis. This limitation is introduced to avoid false-negatives. Typically package specifications contain no executable code. The only exception is initialization of global constants and variables in package specification. Since most package specifications are not executable at all, there is no information available on the number of lines covered and those would be reported as 0% covered, which is not desirable. + The package and type specifications are excluded from code coverage analysis. + This limitation is introduced to avoid false-negatives. + Typically package specifications contain no executable code. + The only exception is initialization of global constants and variables in package specification. + Since most package specifications are not executable at all, there is no information available + on the number of lines covered and those would be reported as 0% covered, which is not desirable. -To obtain information about code coverage of your unit tests, all you need to do is run your unit tests with one of built-in code coverage reporters. +To obtain information about code coverage for unit tests, run utPLSQL with one of built-in code coverage reporters. The following code coverage reporters are supplied with utPLSQL: -* `ut_coverage_html_reporter` - generates a HTML coverage report providing summary and detailed information on code coverage. The HTML reporter is based on the open-source [simplecov-html](https://github.com/colszowka/simplecov-html) reporter for Ruby. It includes source code of the code that was covered (if possible) -* `ut_coveralls_reporter` - generates a [Coveralls compatible JSON](https://coveralls.zendesk.com/hc/en-us/articles/201774865-API-Introduction) coverage report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by cloud services like [Coveralls](https://coveralls.io) -* `ut_coverage_sonar_reporter` - generates a [Sonar Compatible XML](https://docs.sonarqube.org/display/SONAR/Generic+Test+Data) coverage report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by services like [SonarQube/SonarCloud](https://about.sonarcloud.io/) + +* `ut_coverage_html_reporter` - generates a HTML coverage report providing summary and detailed information on code coverage. The HTML reporter is based on the open-source [simplecov-html](https://github.com/colszowka/simplecov-html) reporter for Ruby. It includes source code of the code that was covered (if the code is accessible for test user) +* `ut_coverage_sonar_reporter` - generates a [Sonar Compatible XML](https://docs.sonarqube.org/latest/analysis/generic-test/) coverage report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by services like [SonarQube](https://www.sonarqube.org/) and [SonarCloud](https://about.sonarcloud.io/) * `ut_coverage_cobertura_reporter` - generates a basic Cobertura coverage (http://cobertura.sourceforge.net/xml/coverage-04.dtd) report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by services like TFS and Jenkins. Check this link for an example of XML generated by Java: https://raw.githubusercontent.com/jenkinsci/cobertura-plugin/master/src/test/resources/hudson/plugins/cobertura/coverage-with-data.xml ## Security model -utPLSQL code coverage uses DBMS_PROFILER to gather information about the execution of code under test and therefore follows the [DBMS_PROFILER's Security Model](https://docs.oracle.com/database/121/ARPLS/d_profil.htm#ARPLS67465). +utPLSQL code coverage uses DBMS_PROFILER to gather information about the execution of code under test and therefore follows the [DBMS_PROFILER's Security Model](https://docs.oracle.com/en/database/oracle/oracle-database/19/arpls/DBMS_PROFILER.html#GUID-DEE5EA97-14AA-4AF2-A5F7-4AB1D004B99F). In order to be able to gather coverage information, the user executing unit tests needs to be either: + * The owner of the code that is being tested * Have the following privileges to be able to gather coverage on code owned by other users: * `create any procedure` system privilege @@ -30,23 +36,24 @@ In order to be able to gather coverage information, the user executing unit test If you have `execute` privilege on the code that is being tested, but do not have `create any procedure` system privilege, then the code that is being tested will be reported as not covered (coverage = 0%). If you have `execute` privilege only on the unit tests, but do not have `execute` privilege on the code that is being tested, the code will not be reported by coverage - as if it did not exist in the database. -If the code that is being tested is complied as NATIVE, the code coverage will not be reported as well. +If the code that is being tested is compiled as NATIVE, the code coverage will not be reported as well. -## Running unit tests with coverage -Using the code coverage functionality is as easy as using any other [reporter](reporters.md) for the utPLSQL project. You just run your tests from your preferred SQL tool and save the reporter results to a file. -All you need to do is pass the constructor of the reporter to your `ut.run` +## Manually running unit tests with coverage +Using the code coverage functionality is as easy as using any other [reporter](reporters.md) for the utPLSQL test-run. Run your tests from your preferred SQL tool and save the reporter results to a file. +All you need to do, is pass the constructor of the reporter to the `ut.run` procedure call. Example: -```sql +```sql linenums="1" +set serveroutput on begin ut.run(ut_coverage_html_reporter()); end; / ``` -Executes all unit tests in the current schema, gathers information about code coverage and outputs the HTML text into DBMS_OUTPUT. +The above command executes all unit tests in the **current schema**, gathers information about code coverage for all sources in that schema and outputs the HTML report as text into DBMS_OUTPUT. The `ut_coverage_html_reporter` will produce an interactive HTML report. You can see a sample of code coverage for the utPLSQL project [here](https://utplsql.github.io/utPLSQL-coverage-html/) -The report provides summary information with a list of source code that was expected to be covered. +The report provides summary information with a list of source code that should be covered. ![Coverage Summary page](../images/coverage_html_summary.png) @@ -55,16 +62,18 @@ The report allow you to navigate to each source file and inspect line by line co ![Coverage Details page](../images/coverage_html_details.png) -#### Oracle 12.2 extended coverage with profiler and block coverage -Using data collected from profiler and block coverage running parallel we are able to enrich information about coverage. -For every line recorded by profiler if we have a partially covered same line in block coverage we will display that information -presenting line as partially covered, displaying number of block and how many blocks been covered in that line.The feature will be automatically enabled in the Oracle database version 12.2 and higher, for older versions current profiler will be used. +### Partial Coverage -utPLSQL installation automatically creates tables needed by `dbms_plsql_code_coverage` on databases in versions above 12c Release 1. -Due to security model of `dbms_plsql_code_coverage` package, utPLSQL grants access to those tables and creates synonyms for those tables. -The access and synonyms will be public when using the headless installation. This approach avoids complexity of forcing every user of utPLSQL framework to create tables on their own. +#### What it does +Partial coverage combines two data sources — the profiler and block coverage — to give you a more detailed picture of which parts of your code have been tested. +When a line appears in both sources, and block coverage shows it was only partially covered, the display will reflect that: you'll see the line marked as partially covered, along with how many blocks on that line were executed out of the total. + +#### Setup and permissions +utPLSQL automatically creates the tables required by Oracle's dbms_plsql_code_coverage package — you don't need to create them manually. +Because of how dbms_plsql_code_coverage handles security, utPLSQL also takes care of granting access to those tables and creating the necessary synonyms. In a headless installation, both the grants and synonyms are made public, keeping things simple without requiring every utPLSQL user to set up their own tables. Sample output: + ![Package Coverage Summary](../images/extended_coverage_html_summary.png) ![Line Coverage Details](../images/extended_coverage_html_line.png) @@ -78,41 +87,41 @@ There are two distinct ways to gather code coverage: - Coverage on project files Those two options are mutually exclusive and cannot be mixed. -By default, when using one of coverage reporters, coverage is gathered on schema(s). +By default, when using one of coverage reporters, coverage is gathered on schema(s). +The database schema(s) containing the tests that were executed during the run will be reported on by coverage reporter. The parameters used to execute tests determine if utPLSQL will be using one approach or the other. +If parameter `a_source_file_mappings` or `a_source_files` is provided, then coverage is gathered on project files provided, otherwise coverage is gathered on schemas. -The database schema(s) containing the tests that were executed during the run will be reported on by coverage reporter. - -**Note** -> Regardless of the options provided, all unit test packages are excluded from the coverage report. Coverage reports provide information only about the **tested** code. +!!! note + Regardless of the options provided, all unit test packages are excluded from the coverage report. Coverage reports provide information only about the **tested** code. The default behavior of coverage reporting can be altered using invocation parameters. ### Schema based Coverage -To simply gather coverage for all objects in your current schema execute tests with coverage reporting. +To gather coverage for all objects in the **current schema** execute tests with coverage report as argument. +This is the default reporting option and therefore additional coverage options don't need to be provided. -```sql +```sql linenums="1" exec ut.run(ut_coverage_html_reporter()); ``` -**Note** +!!! note -> When no filters are used, the size of the coverage report will depend two factors: -> - the type of report (does the report include source code or not) -> - the amount of source code in the database schema -> ->Keep in mind that for schemas containing a lot of code, it can take quite some time to produce the coverage report. + When no filters are used, the size of the coverage report will depend two factors:
+ - the type of report (does the report include source code or not)
+ - the amount of source code in the database schema
+ Keep in mind that for schemas containing a lot of code, it can take quite some time to produce the coverage report. #### Setting coverage schema(s) By default, coverage is gathered on the schema(s) derived from suite paths provided to execute tests. -This is correct as long as your test packages and tested code share the same schema. +This is a valid approach as long as your test packages and tested code share the same schema. So when you run: -```sql +```sql linenums="1" exec ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter()); ``` Coverage will be gathered on both `user_1` and `user_2` objects. @@ -121,31 +130,92 @@ If your tests live in a different schema from the tested code you may override t In the example below, coverage will still be gathered for `user_1` and `user_2` objects, even thought we run the tests located in schema `unit_test_schema` -```sql -exec ut.run('unit_test_schema', ut_coverage_html_reporter(), a_coverage_schemes => ut_varchar2_list('user_1','user_2') ); +```sql linenums="1" +begin + ut.run('unit_test_schema', ut_coverage_html_reporter(), + a_coverage_schemes => ut_varchar2_list('user_1','user_2') + ); +end; ``` #### Filtering objects in coverage reports -There are two options that can be used to narrow down the scope of coverage report: -- `a_include_objects` - list of `[object_owner.].object_name` to be included in the coverage report -- `a_exclude_objects` - list of `[object_owner.].object_name` to be excluded from the coverage report - -You may specify both _include_ and _exclude_ object lists to gain more control over what needs to be included / excluded from the coverage report. - -The object owner is optional in the object list. -If you do not provide an object owner, the _include_/_exclude_ list will be considered for every schema used for coverage gathering (as described above). - +By default, coverage is reported on all objects of the schema(s) described above. Several parameters narrow the scope of the coverage report. +You can describe the scope with lists of names, or with regular expressions that match names. + +| Parameter | Type | Meaning | +|-------------------------|----------------------|------------------------------------------------------------------------------------------------------| +| `a_coverage_schemes` | `ut_varchar2_list` | schemas to gather coverage on | +| `a_include_objects` | `ut_varchar2_list` | `[object_owner.]object_name` to be included in the coverage report | +| `a_exclude_objects` | `ut_varchar2_list` | `[object_owner.]object_name` to be excluded from the coverage report | +| `a_include_schema_expr` | `varchar2(4000)` | regular expression, schemas whose name matches are included in the coverage report | +| `a_include_object_expr` | `varchar2(4000)` | regular expression, objects whose name (without schema name) matches are included in the report | +| `a_exclude_schema_expr` | `varchar2(4000)` | regular expression, schemas whose name matches are excluded from the coverage report | +| `a_exclude_object_expr` | `varchar2(4000)` | regular expression, objects whose name (without schema name) matches are excluded from the report | +| `a_source_file_mappings`| `ut_file_mappings` | map of filenames to database objects, used for file-based coverage - see [Project based Coverage](#project-based-coverage) | + +Use lists when the scope is a handful of known objects. Use regular expressions when the scope follows a naming convention, +for example all schemas that start with `APP_`, or all objects that end with `_TMP`. +A rule written once as a regular expression also covers the objects and schemas that are created later. + +You may specify both _include_ and _exclude_ options to gain more control over what needs to be included / excluded from the coverage report. +An object is reported when it passes the include filters and does not match any of the exclude filters. + +##### Regular expressions + +- The expression is evaluated by Oracle `REGEXP_LIKE`. It is **case-insensitive**, so `app_` matches `APP_ORDERS`. +- A schema expression is matched against the schema name. An object expression is matched against the object name **without** the schema name. +- The expression is **not anchored**. `util` matches `UT_UTILS`, `UTIL_TRAINING` and `ERROR_UTIL_2`. + Use `^` to match from the beginning of the name and `$` to match up to the end, for example `^app_` or `_tmp$`. +- When both an include schema expression and an include object expression are specified, an object must match both. + +##### Which parameters are used when several are given + +| If you specify | utPLSQL ignores | +|-----------------------------------------------------------------|-----------------------------------------------------------| +| `a_source_file_mappings` | all other include/exclude parameters | +| `a_include_schema_expr` or `a_include_object_expr` | `a_include_objects` (and associated `a_coverage_schemes`) | +| `a_exclude_schema_expr` or `a_exclude_object_expr` | `a_exclude_objects` (and associated `a_coverage_schemes`) | + +Everything else can be combined. In particular: + +- include expressions can be combined with exclude expressions and with `a_exclude_objects`, +- `a_exclude_schema_expr` and `a_exclude_object_expr` can be used together, +- without include parameters, coverage is gathered on the schemas described in [Setting coverage schema(s)](#setting-coverage-schemas) + and the exclude parameters remove objects from that scope. + +!!! warning "Important note" + + The order of priority is for evaluation of include/exclude filter parameters is as follows.
+ - if `a_source_file_mappings` is defined then all include/exclude parameters are ignored (see section below for usage of `a_source_file_mappings` parameter )
+ - else if `a_include_schema_expr` or `a_include_object_expr` parameter is specified then parameters `a_coverage_schemes` and `a_include_objects` are ignored
+ - else if `a_include_objects` is specified then the coverage is gathered only on specified database objects.
+ - if `a_coverage_schemes` is specified then those schemas are used for objects without schema name in `a_include_objects` and `a_exclude_objects`
+ - if `a_coverage_schemes` is not specified then schema from paths (`a_paths`) parameter are used for objects without schema name in `a_include_objects` and `a_exclude_objects`
+ - else if, only the `a_coverage_schemes` is specified then the coverage is gathered only on specified database schemas
+ - else if no coverage specific parameters are provided coverage is gathered on all schemas specified in paths passed to run procedure
+ - else if no paths were specified, the coverage is gathered on current schema of the session running the tests + +##### Examples + +The examples use a system split into schemas `app_orders` and `app_billing` that contain the application code, +and schemas `app_orders_test` and `app_billing_test` that contain the unit tests. + +###### Filtering by lists of names Example: Limiting coverage by object name, for tested code located in the same schema as the unit tests. -```sql -exec ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), a_include_objects=>ut_varchar2_list('award_bonus')); +```sql linenums="1" +begin + ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), + a_include_objects=>ut_varchar2_list('award_bonus') + ); +end; ``` Executes all tests in schemas: `user_1` and `user_2`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.award_bonus` Example: Limiting coverage by object name, for tested code located in different schemas than the unit tests. -```sql +```sql linenums="1" begin ut.run( 'unit_test_schema', ut_coverage_html_reporter(), @@ -158,7 +228,7 @@ Executes all tests in schema `unit_test_schema`. Coverage will only be reported Objects that do not exist in the database but were specified in `a_include_objects` will be ignored. Example: Limiting coverage by object owner and name. -```sql +```sql linenums="1" begin ut.run( 'unit_test_schema', ut_coverage_html_reporter(), @@ -171,7 +241,7 @@ Executes all tests in schema `unit_test_schema`. Coverage will only be reported The `a_exclude_objects` can be used in the same way as `a_include_objects`. Example: Excluding objects from coverage report by providing a list of object owner/name to be excluded. -```sql +```sql linenums="1" begin ut.run( 'unit_test_schema.test_award_bonus', ut_coverage_html_reporter(), @@ -181,25 +251,105 @@ end; ``` Executes test `test_award_bonus` in schema `unit_test_schema`. Coverage will be reported on all objects in schema `ut3_user` except the `betwnstr` object. -**Note** -> Filtering using `a_include_objects` and `a_exclude_objects` is only applicable when gathering coverage for a schema. Those filters are not applied when reporting coverage on project files. +###### Filtering by regular expressions + +Example: Tests are located in other schemas than the application code. Report coverage on the application schemas, selected by a pattern. +```sql linenums="1" +begin + ut.run( + ut_varchar2_list('app_orders_test','app_billing_test'), ut_coverage_html_reporter(), + a_include_schema_expr => '^app_(orders|billing)$' + ); +end; +``` +Executes all tests in schemas `app_orders_test` and `app_billing_test`. +Coverage will be reported on all objects in the schemas `app_orders` and `app_billing`, even though those schemas are not mentioned in the paths. +Any other schema whose name matches the expression is reported as well. + +Example: Include all application schemas and exclude the test schemas, using one include and one exclude expression. +```sql linenums="1" +begin + ut.run( + ut_varchar2_list('app_orders_test','app_billing_test'), ut_coverage_html_reporter(), + a_include_schema_expr => '^app_', + a_exclude_schema_expr => '_test$' + ); +end; +``` +Coverage will be reported on all schemas whose name starts with `app_` except the ones whose name ends with `_test`. +When a new schema `app_shipping` is created, it is included without any change to the call. + +Example: Report coverage on one functional area of a schema, identified by a naming convention. +```sql linenums="1" +begin + ut.run( + 'app_orders_test', ut_coverage_html_reporter(), + a_include_schema_expr => '^app_orders$', + a_include_object_expr => '^(ord|invoice)_' + ); +end; +``` +Coverage will be reported only on objects in schema `app_orders` whose name starts with `ord_` or `invoice_`. + +Example: Keep generated and temporary objects out of the coverage report. +```sql linenums="1" +begin + ut.run( + 'app_orders_test', ut_coverage_html_reporter(), + a_coverage_schemes => ut_varchar2_list('app_orders'), + a_exclude_object_expr => '(_tmp|_gen)$' + ); +end; +``` +There is no include expression, so coverage is gathered on the schema `app_orders` given in `a_coverage_schemes`. +Objects whose name ends with `_tmp` or `_gen` are left out. + +Example: Use an expression for the bulk of the scope and a list for the exceptions. +```sql linenums="1" +begin + ut.run( + 'app_orders_test', ut_coverage_html_reporter(), + a_include_schema_expr => '^app_orders$', + a_exclude_objects => ut_varchar2_list('app_orders.ord_legacy') + ); +end; +``` +Coverage will be reported on all objects in schema `app_orders` except for `ord_legacy`. +The list can be used with an include expression. It would be ignored if an exclude expression was given too. + +!!! note + An include object expression used **without** an include schema expression is not limited to the schemas of your tests. + It is applied to the objects of all schemas visible to the user running the tests, for example `a_include_object_expr => '^ord_'` + also reports objects named `ord_...` in other schemas. Add `a_include_schema_expr` to keep the scope where you want it. -**Note** -> When running coverage on schema objects, all source code of package bodies, functions, procedures, type bodies and triggers that were not executed will be reported as having 0% code coverage and all source code lines will show as uncovered. -> This is different than the behavior when gathering coverage on project files. +!!! note + Filtering using `a_include_objects` and `a_exclude_objects` is only applicable when gathering coverage for a schema. Those filters are not applied when reporting coverage on project files. + The same is true for the expression parameters. + +!!! note + When running coverage on schema objects, all source code of package bodies, functions, procedures, type bodies and triggers that were not executed will be reported as having 0% code coverage and all source code lines will show as uncovered. + This is different from the behavior when gathering coverage on project files. + +##### Using the filters from utPLSQL-cli and the Maven plugin + +The filter options described above are available in [utPLSQL-cli](https://www.utplsql.org/utPLSQL-cli.html) +and in the [utPLSQL-maven-plugin](https://www.utplsql.org/utPLSQL-maven-plugin.html), and the same rules apply +(which options are ignored when several are given, how expressions are matched, and that the filters are not applied when coverage is gathered on project files). +See the documentation of those tools for the list of supported options and their names. ### Project based Coverage -utPLSQL provides reporters that produce reports consumable by external tools like `Sonar`/`SonarCloud` & `Coveralls`. +utPLSQL provides reporters that produce reports consumable by external tools like `Sonar`/`SonarCloud`. -Services like Sonar, Coveralls and others perform analysis based on source code in project files. +Services like Sonar and others perform analysis based on source code in project files. They are abstracted from database, schema names, packages, procedures and functions, and operate on a more generic concept of project source code. To be able to effectively use reporters dedicated for those tools, utPLSQL provides functionality for mapping database object names to project files. There are a few significant differences when running coverage on project files compared to running coverage on schema(s). + - Coverage is only reported on objects that were successfully mapped to project files. -- Project files (database objects) that were not executed at all are not reported as fully uncovered. It is up to the consumer (Sonar/Coveralls) to determine if project file should be considered as 0% coverage or just ignored. +- Project files (database objects) that were not executed at all are not reported as fully uncovered. It is up to the consumer (Sonar) to determine if project file should be considered as 0% coverage or just ignored. In order to successfully use coverage on project files, those files must be mapped to database objects. @@ -233,21 +383,23 @@ C: ``` By default, utPLSQL will convert file paths into database objects using the following regular expression `/(((\w|[$#])+)\.)?((\w|[$#])+)\.(\w{3})$` + - object owner (if it is present) is identified by the expression in the second set of brackets - object name is identified by the expression in the fourth set of brackets - object type is identified by the expression in the sixth set of brackets -**Note** -> utPLSQL will replace any '\\' with '/' for the purpose of mapping files to objects. The paths shown in the results will remain (contain '\' where it was present). -> This is done to simplify the syntax of regular expressions. Regular expression will always use '/' as a directory separator on a file path regardless of whether you're on a Windows or Unix system. +!!! note + utPLSQL will replace any '\\' with '/' for the purpose of mapping files to objects. The paths shown in the results will remain (contain '\' where it was present). + This is done to simplify the syntax of regular expressions. Regular expression will always use '/' as a directory separator on a file path regardless of whether you're on a Windows or Unix system. -**Note** -> Below examples assume that you have downloaded latest version of [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli/releases), extracted it into your projects root directory (my_project) and placed ojdbc8.jar and orai18n.jar files in utPLSQL-cli\lib directory. -> The examples assume that you run the utPLSQL-cli from `my_project` directory. +!!! note + Below examples assume that you have downloaded latest version of [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli/releases) + and extracted it into your projects root directory + and that you run the utPLSQL-cli from that directory. Windows: -``` +```pwsh utPLSQL-cli\bin\utplsql run test_runner/pass@db_host:db_port/db_service_name ^ -p=hr,hotel ^ -source_path=sources ^ @@ -267,6 +419,7 @@ utPLSQL-cli/bin/utplsql run test_runner/pass@db_host:db_port/db_service_name \ ``` The above commands will: + - connect as user `test_runner` - run all utPLSQL v3 tests for users `hr`, `hotel` - map database code to project files in `sources` directory and save code coverage results into `coverage.html` @@ -317,7 +470,7 @@ Note that the owner/name/type subexpressions don't need to be explicitly specifi In the below example, they were specified explicitly only for `source_path`, `test_path` doesn't have subexpressions specified and so they are default (2/3/4). Windows: -``` +```pwsh utPLSQL-cli\bin\utplsql run test_runner/pass@db_url ^ -p=hr,hotel ^ -source_path=sources ^ @@ -380,7 +533,7 @@ For the database objects mapped to `souces` directory user `code_owner` will be For the database objects mapped to `tests` directory user `tests_owner` will be used. Windows: -``` +```pwsh utPLSQL-cli\bin\utplsql run test_runner/pass@db_url ^ -p=tests_owner ^ -source_path=sources -owner=code_owner ^ @@ -399,9 +552,9 @@ utPLSQL-cli/bin/utplsql run test_runner/pass@db_url \ -f=ut_sonar_test_reporter -o=test_results.xml ``` -**Note** -> When the project folder structure does not provide any information about source code owner and test owner, you can specify the owner for tests and owner for code explicitly. -> Such project configuration supports only single-owner for source code and single owner for tests. +!!! note + When the project folder structure does not provide any information about source code owner and test owner, you can specify the owner for tests and owner for code explicitly. + Such project configuration supports only single-owner for source code and single owner for tests. Tested code is mapped to files in `coverage.html` @@ -478,7 +631,7 @@ C: Windows: -``` +```pwsh utPLSQL-cli\bin\utplsql run test_runner/pass@db_url ^ -p=hr,hotel ^ -source_path=sources ^ @@ -529,10 +682,11 @@ Unit test code is mapped to files in `test_results.xml` #### Object-file mapping rules -In order to allow deterministic and accurate mapping of database source-code into project files, the project directory and file structure needs to meet certain criteria. +In order to allow deterministic and accurate mapping of database source-code into project files, the project directory and file structure needs to meet certain criteria. + - Source code is kept separate from test code (separate directories) -- Each database (source-code) object is stored in individual file. Package/type specification is kept separate from it's body. -- File name (file path) contains name of database object +- Each database (source-code) object is stored in an individual file. Package/type specification is kept separate from its body. +- File name (file path) contains the name of database object - Each file-path clearly identifies object type (by file extension) - Each file contains representation of database object "as is". No extra commands (like `set echo off` `ALTER SESSION SET PLSQL_CCFLAGS = 'debug:TRUE';`) or blank lines are present before `CREATE TYPE`,`CREATE TYPE` etc. - When project is spanning across multiple database schemes, each file-path clearly and uniformly identifies object owner @@ -543,6 +697,7 @@ In order to allow deterministic and accurate mapping of database source-code int The `ut.run` command provides interface to map project into database objects when executing tests. While it is much easier to perform mapping directly from command line, it is possible to achieve similar functionality from any SQL client. The main differences when using the `ut.run(...)` command, will be: + - you can only use single reporter and therefore will get only one report from test execution - you need to provide fill list of project files rather than point to `sources` and `tests` directories @@ -594,7 +749,7 @@ C: To execute all tests and map database source code into source file names you could use the following command in any SQL client: -```sql +```sql linenums="1" begin ut.run( ut_varchar2_list('hr','hotel'), @@ -626,7 +781,7 @@ end; ``` To execute all tests and map database tests code into test file names you could use the following command in any SQL client: -```sql +```sql linenums="1" begin ut.run( ut_varchar2_list('hr','hotel'), @@ -659,3 +814,127 @@ begin end; ``` +## Reporting coverage outside utPLSQL and in parallel sessions + +utPSLQL allows fo standalone reporting code coverage across multiple database sessions. This functionality enables coverage reporting for external testing tools. + +Following API calls enable the standalone coverage reporting. + +- `ut_runner.coverage_start( coverage_run_id );` - initiates code coverage within a session +- `ut_runner.coverage_stop();` - stops gathering of code coverage within a session +- `.get_report( ... )` - coverage reporters function producing coverage report as pipelined data-set (to be used in SQL query) +- `.get_report_cursor( ... )` - coverage reporters function producing coverage report as ref-cursor + +Example: +```sql linenums="1" +--SESSION 1 +-- gather coverage on code using specific coverage_run_id value +declare + l_coverage_run_id raw(32); +begin + l_coverage_run_id := 'A6AA5B7361251CE6E053020011ACA055'; +-- l_coverage_run_id := sys_guid; + ut_runner.coverage_start(l_coverage_run_id); + + --The code to gather coverage on goes here + + ut_runner.coverage_stop(); +end; +/ +``` + +```sql linenums="1" +--SESSION 2 +-- alternative approach +-- gather coverage on code using specific coverage_run_id value +exec ut_runner.coverage_start('A6AA5B7361251CE6E053020011ACA055'); + +--The code to gather coverage on goes here + +exec ut_runner.coverage_stop(); +``` + + +```sql linenums="1" +--SESSION 1 or SESSION2 2 or SESSION 3 +-- run after calls in SESSION 1 & 2 are finished +-- retrieve coverage report in HTML format coverage_run_id value +select * + from table( + ut_coverage_html_reporter().get_report( + a_coverage_options => ut_coverage_options( + coverage_run_id => 'A6AA5B7361251CE6E053020011ACA055' + ) + ) + ); +``` + +```sql linenums="1" +--SESSION 1 or SESSION2 2 or SESSION 3 +-- run after calls in SESSION 1 & 2 are finished +declare + l_results_cursor sys_refcursor; +begin + l_results_cursor := ut_coverage_html_reporter().get_report_cursor( + a_coverage_options => ut_coverage_options( + coverage_run_id => 'A6AA5B7361251CE6E053020011ACA055' + ) + ); + --fetch and process the cursor results + close l_results_cursor; +end; +/ +``` + +Specification of parameters for `get_report` and `get_report_cursor` +```sql linenums="1" +function get_report( + a_coverage_options ut_coverage_options, + a_client_character_set varchar2 := null +) return ut_varchar2_rows pipelined +``` + +```sql linenums="1" +function get_report_cursor( + a_coverage_options ut_coverage_options, + a_client_character_set varchar2 := null +) return sys_refcursor +``` +```sql linenums="1" +ut_coverage_options( + coverage_run_id raw, + schema_names ut_varchar2_rows := null, + exclude_objects ut_varchar2_rows := null, + include_objects ut_varchar2_rows := null, + file_mappings ut_file_mappings := null + include_schema_expr varchar2(4000) := null, + include_object_expr varchar2(4000) := null, + exclude_schema_expr varchar2(4000) := null, + exclude_object_expr varchar2(4000) := null +); +``` + +The `a_client_character_set` is used to provide character set to the report. Coverage reports in XML and HTML format include this information to assure that HMTL/XML encoding tag is aligned with encoding of the report produced. +Use this parameter to provide encoding of your client application. + +The `a_coverage_options` parameter is used to control the scope and formatting of data returned by report. + +`ut_coverage_options` object accepts the following arguments + +- `coverage_run_id` - identifier of coverage run to generate report for - data-type `RAW(32)` +- `schema_names` - optional - list of schema names to include in coverage report - data-type `UT_VARCHAR2_ROWS` +- `exclude_objects` - optional - list of object names to exclude from report - data-type `UT_VARCHAR2_ROWS` +- `include_objects` - optional - list of object names to gather coverage on - data-type `UT_VARCHAR2_ROWS` +- `file_mappings` - optional - list of schema names to gather coverage on - data-type `UT_FILE_MAPPINGS` +- `include_schema_expr` - optional - regular expression to match against schema name to include in coverage - data-type `VARCHAR2(4000)` +- `include_object_expr` - optional - regular expression to match against object name to include in coverage - data-type `VARCHAR2(4000)` +- `exclude_schema_expr` - optional - regular expression to match against schema name to exclude in coverage - data-type `VARCHAR2(4000)` +- `exclude_object_expr` - optional - regular expression to match against object name to exclude in coverage - data-type `VARCHAR2(4000)` + +`coverage_run_id` parameter identifies a common coverage run. The valid value type for that parameter is RAW(32). +It is recommended to use `sys_guid()` to generate a common, unique identifier for a specific coverage run. +If the identifier is not unique, previous runs of coverage that used the same `coverage_run_id` will be aggregated to the resulting coverage report. + +For details on the meaning of `schema_names`, `exclude_objects`, `include_objects`, `file_mappings` see sections above. +Note that data-types of include/exclude/schema lists are different when calling `ut.run` vs. calling `get_report/get_report_cursor`. + diff --git a/docs/userguide/exception-reporting.md b/docs/userguide/exception-reporting.md index 7c8293095..f3faf2847 100644 --- a/docs/userguide/exception-reporting.md +++ b/docs/userguide/exception-reporting.md @@ -1,23 +1,28 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) -# Exception handling and reporting - -The utPLSQL is responsible for handling exceptions wherever they occur in the test run. utPLSQL is trapping most of the exceptions so that the test execution is not affected by individual tests or test packages throwing an exception. -The framework provides a full stacktrace for every exception that was thrown. The stacktrace is clean and does not include any utPLSQL library calls in it. +utPLSQL is responsible for handling exceptions wherever they occur in the test run. The framework is trapping most of the exceptions so that the test execution is not affected by individual tests or test packages throwing an exception. +The framework provides a full stacktrace for every exception that was thrown. The reported stacktrace does not include any utPLSQL library calls in it. To achieve rerunability, the package state invalidation exceptions (ORA-04068, ORA-04061) are not handled and test execution will be interrupted if such exceptions are encountered. This is because of how Oracle behaves on those exceptions. Test execution can fail for different reasons. The failures on different exceptions are handled as follows: -* A test package without body - each `--%test` is reported as failed with exception, nothing is executed -* A test package with _invalid body_ - each `--%test` is reported as failed with exception, nothing is executed -* A test package with _invalid spec_ - package is not considered a valid unit test package and is excluded from execution. When trying to run a test package with invalid spec explicitly, exception is raised. Only valid specifications are parsed for annotations -* A test package that is raising an exception in `--%beforeall` - each `--%test` is reported as failed with exception, `--%test`, `--%beforeeach`, `--%beforetest`, `--%aftertest` and `--%aftereach` are not executed. `--%afterall` is executed to allow cleanup of whatever was done in `--%beforeall` -* A test package that is raising an exception in `--%beforeeach` - each `--%test` is reported as failed with exception, `--%test`, `--%beforetest` and `--%aftertest` is not executed. The `--%aftereach` and `--%afterall` blocks are getting executed to allow cleanup of whatever was done in `--%before...` blocks -* A test package that is raising an exception in `--%beforetest` - the `--%test` is reported as failed with exception, `--%test` is not executed. The `--%aftertest`, `--%aftereach` and `--%afterall` blocks are getting executed to allow cleanup of whatever was done in `--%before...` blocks -* A test package that is raising an exception in `--%test` - the `--%test` is reported as failed with exception. The execution of other blocks continues normally -* A test package that is raising an exception in `--%aftertest` - the `--%test` is reported as failed with exception. The execution of other blocks continues normally -* A test package that is raising an exception in `--%aftereach` - each `--%test` is reported as failed with exception. -* A test package that is raising an exception in `--%afterall` - all blocks of the package are executed, as the `--%afterall` is the last step of package execution. Exception in `--%afterall` is not affecting test results. A warning with exception stacktrace is displayed in the summary +| Problem / error | Framework behavior | +|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| A test package **without body** | each `--%test` is reported as failed with exception, nothing is executed | +| A test package with **invalid body** | each `--%test` is reported as failed with exception, nothing is executed | +| A test package with **invalid spec** | package is not considered a valid unit test package and is excluded from execution. When trying to run a test package with invalid spec explicitly, exception is raised. Only valid specifications are parsed for annotations | +| A test package that is raising an exception in `--%beforeall` | each `--%test` is reported as failed with exception, `--%test`, `--%beforeeach`, `--%beforetest`, `--%aftertest` and `--%aftereach` are not executed. `--%afterall` is executed to allow cleanup of whatever was done in `--%beforeall` | +| A test package that is raising an exception in `--%beforeeach` | each `--%test` is reported as failed with exception, `--%test`, `--%beforetest` and `--%aftertest` is not executed. The `--%aftereach` and `--%afterall` blocks are getting executed to allow cleanup of whatever was done in `--%before...` blocks | +| A test package that is raising an exception in `--%beforetest` | the `--%test` is reported as failed with exception, `--%test` is not executed. The `--%aftertest`, `--%aftereach` and `--%afterall` blocks are getting executed to allow cleanup of whatever was done in `--%before...` blocks | +| A test package that is raising an exception in `--%test` | the `--%test` is reported as failed with exception. The execution of other blocks continues normally | +| A test package that is raising an exception in `--%aftertest` | the `--%test` is reported as failed with exception. The execution of other blocks continues normally | +| A test package that is raising an exception in `--%aftereach` | each `--%test` is reported as failed with exception. | +| A test package that is raising an exception in `--%afterall` | all blocks of the package are executed, as the `--%afterall` is the last step of package execution. Exception in `--%afterall` is not affecting test results. A warning with exception stacktrace is displayed in the summary | + + +!!! warning + If an exception is thrown in an `afterall` procedure then **no failure reported by utPLSQL**.
+ Framework will only report a warning on the suite that the `afterall` belongs to. Example of reporting with exception thrown in `%beforetest`: ```` diff --git a/docs/userguide/expectations.md b/docs/userguide/expectations.md index 7fc22f457..31593e53d 100644 --- a/docs/userguide/expectations.md +++ b/docs/userguide/expectations.md @@ -1,12 +1,13 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) + +## Expectation concepts -# Expectation concepts Validation of the code under test (the tested logic of procedure/function etc.) is performed by comparing the actual data against the expected data. utPLSQL uses expectations and matchers to perform the check on the data. Example of an expectation -```sql +```sql linenums="1" begin ut.expect( 'the tested value' ).to_equal('the expected value'); end; @@ -21,15 +22,16 @@ FAILURE ``` Expectation is a combination of: + - the expected value - optional custom message for the expectation - the matcher used to perform comparison -- them matcher parameters (actual value), depending on the matcher type +- the matcher parameters (actual value), depending on the matcher type Matcher defines the comparison operation to be performed on expected (and actual) value. Pseudo-code: -```sql +```sql linenums="1" ut.expect( a_actual {data-type} [, a_message {varchar2}] ).to_( {matcher} ); ut.expect( a_actual {data-type} [, a_message {varchar2}] ).not_to( {matcher} ); ``` @@ -37,7 +39,7 @@ Pseudo-code: Expectations provide two variants of syntax that you can use. Both variants are functionally-equal but give different usage flexibility. Syntax where matcher is passed as parameter to the expectation: -```sql +```sql linenums="1" ut.expect( a_actual ).to_( {matcher} ); ut.expect( a_actual ).not_to( {matcher} ); -- example @@ -45,18 +47,18 @@ Syntax where matcher is passed as parameter to the expectation: ``` Shortcut syntax, where matcher is directly part of expectation: -```sql +```sql linenums="1" ut.expect( a_actual ).to_{matcher}; ut.expect( a_actual ).not_to_{matcher}; --example - ut.expect( 1 ).to_( be_null() ); + ut.expect( 1 ).to_be_null(); ``` When using shortcut syntax you don't need to surround matcher with brackets. Shortcut syntax is provided for convenience. If you would like to perform more dynamic checks in your code, you could pass the matcher into a procedure like in the below example: -```sql +```sql linenums="1" declare procedure do_check( p_actual varchar2, p_matcher ut_matcher ) is begin @@ -79,26 +81,30 @@ SUCCESS Actual: 'Alibaba' (varchar2) was expected to match: 'ali' , modifiers 'i' ``` -**Note:** -> The examples in the document will be only using shortcut syntax, to keep the document brief. +!!! note + In order to keep the document brief, the examples in the document are only using the standalone expectations syntax. + +## Using expectations -# Using expectations There are two ways to use expectations: - by invoking utPLSQL framework to execute suite(s) of utPLSQL tests - without invoking the utPLSQL framework - running expectations standalone ## Running expectations within utPLSQL framework -When expectations are ran a part of test suite, the framework tracks: + +When expectations are run as a part of a test suite, the framework tracks: + - status of each expectation - outcomes (messages) produced by each expectation - call stack to each expectation In this case: + - expectation results of are not sent directly to `dbms_output` - utPLSQL Reporters used when running suite decide on how the expectation results are formatted and displayed Example of test suite with an expectation: -```sql +```sql linenums="1" create or replace package test_divide as --%suite(Divide two numbers) @@ -156,17 +162,15 @@ Please read about different options for [running test suites](running-unit-tests ## Running expectations outside utPLSQL framework When expectations are invoked outside of utPLSQL framework the outputs from expectations are redirected straight to `dbms_output`. -**Note:** -> The output from expectation contains call stack trace only when expectation fails. -> Source code of the line which called the expectation is only reported when the line is part of in-database code (package) and the user calling expectation has privileges to see that source code. +!!! note + The output from expectation contains call stack trace only when expectation fails.
+ Source code of the line which called the expectation is only reported when the line is part of in-database code (package) and the user calling expectation has privileges to see that source code. -**Important** -> Please do not use expectations as part of your production code. They are not designed to be used as part ot your code. Expectations are meant to be used only as part of your day-to-day testing activities. +!!! warning "**Important**" + Please do not use expectations as part of your production code. They are not designed to be used as part of your code. Expectations are meant to be used only as part of your day-to-day testing activities. -**Note:** -> The examples in the document will be only using standalone expectations, to keep the document brief. -# Matchers +## Matchers utPLSQL provides the following matchers to perform checks on the expected and actual values. - `be_between( a_upper_bound {data-type}, a_lower_bound {data-type} )` @@ -186,11 +190,11 @@ utPLSQL provides the following matchers to perform checks on the expected and ac - `match( a_patter {varchar2} [, a_modifiers {varchar2}] )` ## Providing a custom message -You can provide a custom failure message as second argument for the expectation by passing message as the second parameter to the expectation. +You can provide a custom failure message by passing it as the second parameter to the expectation. `ut.expect( a_actual {data-type}, a_message {varchar2} ).to_{matcher}` Example: -````sql +````sql linenums="1" exec ut.expect( 'supercat', 'checked superhero-animal was not a dog' ).to_equal('superdog'); ```` @@ -205,6 +209,7 @@ If the message is provided, it is being added to the normal failure message retu This is mostly useful when your expectations accept dynamic content, as you can provide additional context to make failing test results more readable. In most cases, there is no need to provide custom message to expectation. This is because utPLSQL identifies: + - The test used to execute the expectation - The line number where the expectation is placed in your test code - The line text of the expectation @@ -212,7 +217,7 @@ In most cases, there is no need to provide custom message to expectation. This i Custom message is useful, if your expectation is placed in a shared procedure to perform a check and your test is using the procedure multiple times. Example: -```sql +```sql linenums="1" create or replace package shared_expectation_test is --%suite @@ -249,19 +254,20 @@ Failures: 1) the_test "Checking table ALL_USERS" Actual: 28 (number) was expected to equal: 0 (number) - at "UT3$USER#.SHARED_EXPECTATION_TEST.TABLE_IS_EMPTY", line 6 ut.expect( l_count, 'Checking table '||p_table_name ).to_equal(0); - at "UT3$USER#.SHARED_EXPECTATION_TEST.THE_TEST", line 11 + at "UT3_USER.SHARED_EXPECTATION_TEST.TABLE_IS_EMPTY", line 6 ut.expect( l_count, 'Checking table '||p_table_name ).to_equal(0); + at "UT3_USER.SHARED_EXPECTATION_TEST.THE_TEST", line 11 "Checking table ALL_TABLES" Actual: 55 (number) was expected to equal: 0 (number) - at "UT3$USER#.SHARED_EXPECTATION_TEST.TABLE_IS_EMPTY", line 6 ut.expect( l_count, 'Checking table '||p_table_name ).to_equal(0); - at "UT3$USER#.SHARED_EXPECTATION_TEST.THE_TEST", line 12 + at "UT3_USER.SHARED_EXPECTATION_TEST.TABLE_IS_EMPTY", line 6 ut.expect( l_count, 'Checking table '||p_table_name ).to_equal(0); + at "UT3_USER.SHARED_EXPECTATION_TEST.THE_TEST", line 12 Finished in .066344 seconds 1 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s) ``` In the tests results window you can see the list of failed expectations for a test as well as: + - the additional message for expectation - the reason why the expectation failed - the line number of the expectation @@ -273,7 +279,7 @@ In the tests results window you can see the list of failed expectations for a te Expectations provide a very convenient way to perform a check on a negated matcher. Syntax to check for matcher evaluating to true: -```sql +```sql linenums="1" begin ut.expect( a_actual {data-type} ).to_{matcher}; ut.expect( a_actual {data-type} ).to_( {matcher} ); @@ -281,7 +287,7 @@ end; ``` Syntax to check for matcher evaluating to false: -```sql +```sql linenums="1" begin ut.expect( a_actual {data-type} ).not_to_{matcher}; ut.expect( a_actual {data-type} ).not_to( {matcher} ); @@ -291,7 +297,7 @@ end; If a matcher evaluated to NULL, then both `to_` and `not_to` will cause the expectation to report failure. Example: -```sql +```sql linenums="1" declare l_actual boolean; begin @@ -312,37 +318,38 @@ FAILURE ``` Since NULL is neither *true* nor *false*, both expectations will report failure. -# Supported data types +## Supported data types The matrix below illustrates the data types supported by different matchers. -| Matcher | blob | boolean | clob | date | number | timestamp | timestamp
with
timezone | timestamp
with
local
timezone | varchar2 | interval
year
to
month | interval
day
to
second | cursor | nested
table
/ varray | object | json | -| :---------------------: | :--: | :-----: | :--: | :--: | :----: | :-------: | :---------------------------: | :------------------------------------: | :------: | :-----------------------------: | :-----------------------------: | :----: | :-------------------------: | :----: | :--: | -| **be_not_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -| **be_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -| **be_false** | | X | | | | | | | | | | | | | | -| **be_true** | | X | | | | | | | | | | | | | | -| **be_greater_than** | | | | X | X | X | X | X | | X | X | | | | | -| **be_greater_or_equal** | | | | X | X | X | X | X | | X | X | | | | | -| **be_less_or_equal** | | | | X | X | X | X | X | | X | X | | | | | -| **be_less_than** | | | | X | X | X | X | X | | X | X | | | | | -| **be_between** | | | | X | X | X | X | X | X | X | X | | | | | -| **equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -| **contain** | | | | | | | | | | | | X | X | X | | -| **match** | | | X | | | | | | X | | | | | | | -| **be_like** | | | X | | | | | | X | | | | | | | -| **be_empty** | X | | X | | | | | | | | | X | X | | X | -| **have_count** | | | | | | | | | | | | X | X | | X | - - -# Expecting exceptions +| Matcher | blob | boolean | clob | date | number | timestamp | timestamp
with
timezone | timestamp
with
local
timezone | varchar2 | interval
year
to
month | interval
day
to
second | cursor | nested
table
/ varray | object | json | +| :-----------------------: | :--: | :-----: | :--: | :--: | :----: | :-------: | :---------------------------: | :------------------------------------: | :------: | :-----------------------------: | :-----------------------------: | :----: | :-------------------------: | :----: | :--: | +| **be_not_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | +| **be_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | +| **be_false** | | X | | | | | | | | | | | | | | +| **be_true** | | X | | | | | | | | | | | | | | +| **be_greater_than** | | | | X | X | X | X | X | | X | X | | | | | +| **be_greater_or_equal** | | | | X | X | X | X | X | | X | X | | | | | +| **be_less_or_equal** | | | | X | X | X | X | X | | X | X | | | | | +| **be_less_than** | | | | X | X | X | X | X | | X | X | | | | | +| **be_between** | | | | X | X | X | X | X | X | X | X | | | | | +| **equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | +| **contain** | | | | | | | | | | | | X | X | X | | +| **match** | | | X | | | | | | X | | | | | | | +| **be_like** | | | X | | | | | | X | | | | | | | +| **be_empty** | X | | X | | | | | | | | | X | X | | X | +| **have_count** | | | | | | | | | | | | X | X | | X | +| **be_within().of_()** | | | | X | X | X | X | X | | | | | | | | +| **be_within_pct().of_()** | | | | | X | | | | | | | | | | | + +## Expecting exceptions Testing is not limited to checking for happy-path scenarios. When writing tests, you often want to validate that in specific scenarios, an exception is thrown. Use the `--%throws` annotation, to test for expected exceptions. Example: -```sql +```sql linenums="1" create or replace function divide(x varchar2, y varchar2) return number is begin return x/y; @@ -381,19 +388,19 @@ Finished in .009229 seconds 1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` -For more details see documentation of the [`--%throws` annotation.](annotations.md#throws-annotation) +For more details see documentation of the [`--%throws` annotation.](annotations.md#throws) -# Matchers +## Matchers -You can choose different matchers to validate the your PL/SQL code is working as expected. +You can choose different matchers to validate that your PL/SQL code is working as expected. -## be_between +### be_between Validates that the actual value is between the lower and upper bound. Example: -```sql +```sql linenums="1" declare l_timestamp timestamp := current_timestamp; l_timestamp_tz timestamp with time zone := systimestamp; @@ -445,17 +452,17 @@ SUCCESS Actual: 'Abb' (varchar2) was expected to be between: 'Aba' and 'Abc' ``` -## be_empty +### be_empty Unary matcher that validates if the provided dataset is empty. Can be used with `BLOB`,`CLOB`, `refcursor` or `nested table`/`varray` passed as `ANYDATA` -**Note:** -BLOB/CLOB that is initialized is not NULL but it is actually equal to `empty_blob()`/`empty_clob()`. +!!! note + BLOB/CLOB that is initialized is not NULL but it is actually equal to `empty_blob()`/`empty_clob()`. Example: -```sql +```sql linenums="1" declare l_cursor sys_refcursor; begin @@ -494,11 +501,11 @@ FAILURE at "anonymous block", line 9 ``` -## be_false +### be_false Unary matcher that validates if the provided value is false. Usage: -```sql +```sql linenums="1" begin ut.expect( ( 1 = 0 ) ).to_be_false(); ut.expect( ( 1 = 1 ) ).to_( be_false() ); @@ -522,11 +529,11 @@ SUCCESS Actual: TRUE (boolean) was expected not to be false ``` -## be_greater_or_equal +### be_greater_or_equal Checks if the actual value is greater or equal than the expected. Usage: -```sql +```sql linenums="1" begin ut.expect( sysdate ).to_be_greater_or_equal( sysdate - 1 ); ut.expect( sysdate ).to_( be_greater_or_equal( sysdate + 1 ) ); @@ -550,11 +557,11 @@ SUCCESS Actual: 2019-07-07T22:43:29 (date) was expected not to be greater or equal: 2019-07-08T22:43:29 (date) ``` -## be_greater_than +### be_greater_than Checks if the actual value is greater than the expected. Usage: -```sql +```sql linenums="1" begin ut.expect( 2 ).to_be_greater_than( 1 ); ut.expect( 0 ).to_( be_greater_than( 1 ) ); @@ -578,11 +585,11 @@ SUCCESS Actual: 0 (number) was expected not to be greater than: 1 (number) ``` -## be_less_or_equal +### be_less_or_equal Checks if the actual value is less or equal than the expected. Usage: -```sql +```sql linenums="1" begin ut.expect( 3 ).to_be_less_or_equal( 3 ); ut.expect( 4 ).to_( be_less_or_equal( 3 ) ); @@ -606,11 +613,11 @@ SUCCESS Actual: 4 (number) was expected not to be less or equal: 3 (number) ``` -## be_less_than +### be_less_than Checks if the actual value is less than the expected. Usage: -```sql +```sql linenums="1" begin ut.expect( 3 ).to_be_less_than( 2 ); ut.expect( 0 ).to_( be_less_than( 2 ) ); @@ -634,19 +641,17 @@ FAILURE at "anonymous block", line 5 ``` -## be_like +### be_like Validates that the actual value is like the expected expression. Syntax: `ut.expect( a_actual ).to_be_like( a_mask [, a_escape_char] )` -Parameters `a_mask` and `a_escape_char` represent valid parameters of the [Oracle LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF52142). - -If you use Oracle Database version 11.2.0.4, you may run into Oracle Bug 14402514: WRONG RESULTS WITH LIKE ON CLOB USING ESCAPE CHARACTER. In this case we recommend to use `match` instead of `be_like`. +Parameters `a_mask` and `a_escape_char` represent valid parameters of the [Oracle LIKE condition](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Pattern-matching-Conditions.html). Usage: -```sql +```sql linenums="1" begin ut.expect( 'Lorem_impsum' ).to_be_like( '%rem%'); ut.expect( 'Lorem_impsum' ).to_be_like( '%rem\_i%', '\' ); @@ -672,11 +677,11 @@ SUCCESS Actual: 'Lorem_impsum' (varchar2) was expected not to be like: '%reM%' ``` -## be_not_null +### be_not_null Unary matcher that validates if the actual value is not null. Usage: -```sql +```sql linenums="1" begin ut.expect( to_clob('ABC') ).to_be_not_null(); ut.expect( to_clob('') ).to_( be_not_null() ); @@ -700,11 +705,11 @@ SUCCESS Actual: NULL (varchar2) was expected not to be not null ``` -## be_null +### be_null Unary matcher that validates if the actual value is null. Usage: -```sql +```sql linenums="1" begin ut.expect( '' ).to_be_null(); ut.expect( 0 ).to_( be_null() ); @@ -728,11 +733,11 @@ SUCCESS Actual: 0 (number) was expected not to be null ``` -## be_true +### be_true Unary matcher that validates if the provided value is true. Usage: -```sql +```sql linenums="1" begin ut.expect( ( 1 = 0 ) ).to_be_true(); ut.expect( ( 1 = 1 ) ).to_( be_true() ); @@ -756,13 +761,13 @@ FAILURE at "anonymous block", line 5 ``` -## have_count +### have_count Unary matcher that validates if the provided dataset count is equal to expected value. -Can be used with `refcursor` , `json`or `table type` +Can be used with `refcursor`, `json` or `table type` Usage: -```sql +```sql linenums="1" declare l_cursor sys_refcursor; l_collection ut_varchar2_list; @@ -792,17 +797,17 @@ FAILURE at "anonymous block", line 11 ``` -## match +### match Validates that the actual value is matching the expected regular expression. Syntax: `ut.expect( a_actual ).to_match( a_pattern [, a_modifiers] );` -Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle REGEXP_LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF00501) +Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle REGEXP_LIKE condition](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Pattern-matching-Conditions.html#GUID-D2124F3A-C6E4-4CCA-A40E-2FFCABFD8E19) Usage: -```sql +```sql linenums="1" begin ut.expect( '123-456-ABcd' ).to_match( '\d{3}-\d{3}-[a-z]{4}', 'i' ); ut.expect( 'some value' ).to_( match( '^some.*' ) ) ; @@ -826,9 +831,9 @@ FAILURE at "anonymous block", line 5 ``` -## equal -The equal matcher is very restrictive. Test using this matcher succeeds only when the compared data-types are exactly the same. -If you are comparing `varchar2` to a `number` will fail even if the text contains the same numeric value as the number. +### equal +The `equal` matcher is very restrictive. Test using this matcher succeeds only when the compared data-types are exactly the same. +If you are comparing a `varchar2` to a `number`, it will fail even if the text contains the same numeric value as the number. The matcher will also fail when comparing a `timestamp` to a `timestamp with timezone` data-type etc. The matcher enables detection of data-type changes. @@ -840,7 +845,7 @@ Syntax: `ut.expect( a_actual ).to_equal( a_expected [, a_nulls_are_equal])[.advanced_options]` Example usage -```sql +```sql linenums="1" declare l_actual varchar2(20); l_expected varchar2(20); @@ -907,27 +912,27 @@ FAILURE ``` -**Note:** ->**Comparing NULLs gives success by default ** -The `a_nulls_are_equal` parameter controls the behavior of a `null = null` comparison. -To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal => false` to the `equal` matcher. +!!! note + **by default, comparing NULL to NULL gives success**
+ The `a_nulls_are_equal` parameter controls the behavior of a `null = null` comparison.
+ To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal => false` to the `equal` matcher. -## contain +### contain This matcher supports only compound data-types comparison. It check if the actual set contains all values of expected subset. -When comparing data using `contain` matcher, the data-types of columns for compared compound types must be exactly the same. +When comparing data using the `contain` matcher, the data-types of columns for compared compound types must be exactly the same. The matcher supports all advanced comparison options as `equal` like: `include` , `exclude`, `join_by` etc.. The matcher is successful when actual data set contains all of the values from expected results. -The matcher will cause a test to fail if actual data set does not contain any of expected values. +The matcher will cause a test to fail if actual data set does not contain some of expected values. ![included_set](../images/venn21.gif) **Example 1.** -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -959,7 +964,7 @@ FAILURE When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicates. **Example 2.** -```sql +```sql linenums="1" declare l_actual ut_varchar2_list; l_expected ut_varchar2_list; @@ -987,7 +992,7 @@ The negated version of `contain` ( `not_to_contain` ) is successful only when al ![not_overlapping_set](../images/venn22.gif) **Example 3.** -```sql +```sql linenums="1" declare l_actual ut_varchar2_list; l_expected ut_varchar2_list; @@ -1024,7 +1029,7 @@ FAILURE **Example 4.** -```sql +```sql linenums="1" declare l_actual ut_varchar2_list; l_expected ut_varchar2_list; @@ -1057,7 +1062,7 @@ FAILURE **Example 5.** -```sql +```sql linenums="1" declare l_actual ut_varchar2_list; l_expected ut_varchar2_list; @@ -1093,10 +1098,116 @@ SUCCESS DEF ``` +### to_be_within of + +Determines whether expected value is within range (tolerance) from another value. + +The logical formual used for calcuating the matcher is: +``` + result := ( abs( expected - actual ) <= distance ) +``` +The actual formula used for calculation is more complex to handle different data-types of expected/actual values as well as differnet types of distance value. +The matcher will fail if the `expected` and `actual` are more than `distance` apart from each other. +The matcher will fail if the dataypes of `expected` and `actual` are not the same. + +The matcher works with data-types: `number`, `date`, `timestamp`, `timestamp with time zone`, `timestamp with local time zone` +The data-types of compared values must match exactly and if type does not match, the expectation will fail. + +| expected/actual
data-type | distance data-type | +|:------------------------------:|:----------------------:| +| number | number | +| date | interval day to second | +| date | interval year to month | +| timestamp | interval day to second | +| timestamp | interval year to month | +| timestamp with time zone | interval day to second | +| timestamp with time zone | interval year to month | +| timestamp with local time zone | interval day to second | +| timestamp with local time zone | interval year to month | + + +The distance must be expressed as a non-negative number or non-negative interval. + +>Note: +> Interval year-to-moth as a distance is giving sucess if the distance between the given dates/timestamps evaluates to value less or equal of the specified interval +> Keep in mind that a checking for distance of `interval '0-1' year to month` will actuall be successful if the distance is less than a month and 15 days. +> This is due to how oracle evaluates conversion between timestamp difference converted to `year to month interval`. +> The behavior is similar to a call to `months_between()` function with results rounded to full monts ie. round(months_between(date, date)) + +**Example 1.** +```sql linenums="1" +begin + ut.expect(3).to_be_within(1).of_(4); +end; +/ +``` + +**Example 2.** +```sql linenums="1" +begin + ut.expect(3).to_be_within(1).of_(5); +end; +/ +``` + +Returns following output via DBMS_OUTPUT: +``` +Failures: + + 1) wihtin_test + Actual: 3 (number) was expected to be within 1 of 5 (number) + at "UT3_DEVELOP.UT_BE_WITHIN.OF_", line 48 l_result.expectation.to_(l_result ); + at "UT3_DEVELOP.TEST_BETWNSTR.WIHTIN_TEST", line 5 +``` + +**Example 3.** +```sql linenums="1" +begin + ut.expect(sysdate).to_be_within(interval '1' day).of_(sysdate+2); +end; +/ +``` + +Returns following output via DBMS_OUTPUT: +``` +Failures: + + 1) wihtin_test + Actual: 2020-06-07T13:32:58 (date) was expected to be within 1 day of 2020-06-09T13:32:58 (date) + at "UT3_DEVELOP.UT_BE_WITHIN.OF_", line 55 l_result.expectation.to_(l_result ); + at "UT3_DEVELOP.TEST_BETWNSTR.WIHTIN_TEST", line 5 +``` + + +### to_be_within_pct of + +Determines whether actual value is within percentage range of expected value. +The matcher only works with `number` data-type. + +The percentage deviation (distance) must be expressed as a non-negative number. +The formula used for calcuation of expectation is: +``` + result := ( ( distance ) * expected >= abs( expected - actual ) * 100 ) +``` + +**Example 1.** +```sql linenums="1" +begin + ut.expect(9).to_be_within_pct(10).of_(10); +end; +/ +``` + +``` +SUCCESS + Actual: 9 (number) was expected to be within 10 % of 10 (number) +``` + ## Comparing cursors, object types, nested tables and varrays utPLSQL is capable of comparing compound data-types including: + - ref cursors - object types - nested table/varray types @@ -1108,15 +1219,15 @@ utPLSQL is capable of comparing compound data-types including: - Columns in compound data are compared as **ordered list of elements** by default. Use `unordered_columns` option when order of columns in cursor is not relevant - Comparison of compound data is data-type aware. So a column `ID NUMBER` in a cursor is not the same as `ID VARCHAR2(100)`, even if they both hold the same numeric values. - Comparison of cursor columns containing `DATE` will only compare date part **and ignore time** by default. See [Comparing cursor data containing DATE fields](#comparing-cursor-data-containing-date-fields) to check how to enable date-time comparison in cursors. -- Comparison of cursor returning `TIMESTAMP` **columns** against cursor returning `TIMESTAMP` **bind variables** requires variables to be casted to proper precision. This is an Oracle SQL - PLSQL compatibility issue and usage of CAST is the only known workaround for now. See [Comparing cursor data containing TIMESTAMP bind variables](#comparing-cursor-data-containing-timestamp-bind-variables) for examples. +- Comparison of cursor returning `TIMESTAMP` **columns** against cursor returning `TIMESTAMP` **bind variables** requires variables to be cast to proper precision. This is an Oracle SQL - PLSQL compatibility issue and usage of CAST is the only known workaround for now. See [Comparing cursor data containing TIMESTAMP bind variables](#comparing-cursor-data-containing-timestamp-bind-variables) for examples. - To compare nested table/varray type you need to convert it to `anydata` by using `anydata.convertCollection()` - To compare object type you need to convert it to `anydata` by using `anydata.convertObject()` -- It is possible to compare PL/SQL records, collections, varrays and associative arrays. To compare this types of data, use cursor comparison feature of utPLSQL and TABLE operator in SQL query - - On Oracle 11g Release 2 - pipelined table functions are needed (see section [Implicit (Shadow) Types in this artcile](https://oracle-base.com/articles/misc/pipelined-table-functions)) - - On Oracle 12c and above - use [TABLE function on nested tables/varrays/associative arrays of PL/SQL records](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1) - +- It is possible to compare PL/SQL records, collections, varrays and associative arrays. To compare this types of data, use cursor comparison feature of utPLSQL and [TABLE operator in SQL query](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1) +- utPLSQL is not able to distinguish between NULL and whitespace-only column/attribute value when comparing compound data. This is due to Oracle limitation on of XMLType. + See [issue #880](https://github.com/utPLSQL/utPLSQL/issues/880) for details. *Note: This behavior might be fixed in future releases, when utPLSQL is no longer depending on XMLType for compound data comparison.* utPLSQL offers advanced data-comparison options, for comparing compound data-types. The options allow you to: + - define columns/attributes to exclude from comparison - define columns/attributes to include in comparison - and more ... @@ -1127,6 +1238,7 @@ For details on available options and how to use them, read the [advanced data co When comparing compound data, utPLSQL will determine the difference between the expected and the actual data. The diff includes: + - differences in column names, column positions and column data-type for cursor data - only data in columns/rows that differ @@ -1136,9 +1248,9 @@ Consider the following expected cursor data | ID (NUMBER)| FIRST_NAME (VARCHAR2) | LAST_NAME (VARCHAR2) | SALARY (NUMBER) | |:----------:|:----------------------:|:----------------------:|:---------------:| -| 1 | JACK | SPARROW | 10000 | -| 2 | LUKE | SKYWALKER | 1000 | -| 3 | TONY | STARK | 1000000 | +| 1 | JACK | SPARROW | 10000 | +| 2 | LUKE | SKYWALKER | 1000 | +| 3 | TONY | STARK | 1000000 | And the actual cursor data: @@ -1151,6 +1263,7 @@ And the actual cursor data: The two data-sets above have the following differences: + - column ID is misplaced (should be first column but is last) - column SALARY has data-type VARCHAR2 but should be NUMBER - column GENDER exists in actual but not in the expected (it is an Extra column) @@ -1162,7 +1275,7 @@ The two data-sets above have the following differences: utPLSQL will report all of the above differences in a readable format to help you identify what is not correct in the compared dataset. Below example illustrates, how utPLSQL will report such differences. -```sql +```sql linenums="1" declare l_actual sys_refcursor; l_expected sys_refcursor; @@ -1210,11 +1323,13 @@ FAILURE ``` utPLSQL identifies and reports on columns: + - column misplacement - column data-type mismatch - extra/missing columns When comparing rows utPLSQL: + - reports only mismatched columns when rows match - reports columns existing in both data-sets when whole row is not matching - reports whole extra (not expected) row from actual when actual has extra rows @@ -1224,6 +1339,7 @@ When comparing rows utPLSQL: ### Object and nested table data-type comparison examples When comparing object type / nested table / varray, utPLSQL will check: + - if data-types match - if data in the compared elements is the same. @@ -1233,7 +1349,7 @@ When diffing, utPLSQL will not check name and data-type of individual attribute Below examples demonstrate how to compare object and nested table data-types. Object type comparison. -```sql +```sql linenums="1" create type department as object(name varchar2(30)) / @@ -1261,7 +1377,7 @@ FAILURE ``` Table type comparison. -```sql +```sql linenums="1" create type department as object(name varchar2(30)) / create type departments as table of department @@ -1299,7 +1415,7 @@ FAILURE ``` Some of the possible combinations of anydata and their results: -```sql +```sql linenums="1" clear screen set serverout on set feedback off @@ -1483,18 +1599,18 @@ FAILURE ### Comparing cursor data containing DATE fields -**Important note** +!!! warning "Important" -utPLSQL uses XMLType internally to represent rows of the cursor data. This is by far the most flexible method and allows comparison of cursors containing LONG, CLOB, BLOB, user defined types and even nested cursors. -Due to the way Oracle handles DATE data type when converting from cursor data to XML, utPLSQL has no control over the DATE formatting. -The NLS_DATE_FORMAT setting from the moment the cursor was opened determines the formatting of dates used for cursor data comparison. -By default, Oracle NLS_DATE_FORMAT is timeless, so data of DATE datatype, will be compared ignoring the time component. + utPLSQL uses XMLType internally to represent rows of the cursor data. This is by far the most flexible method and allows comparison of cursors containing LONG, CLOB, BLOB, user defined types and even nested cursors.
+ Due to the way Oracle handles DATE data type when converting from cursor data to XML, utPLSQL has no control over the DATE formatting.
+ The NLS_DATE_FORMAT setting from the moment the cursor was opened determines the formatting of dates used for cursor data comparison.
+ By default, Oracle NLS_DATE_FORMAT is timeless, so data of DATE datatype, will be compared ignoring the time component.
You should surround cursors and expectations with procedures `ut.set_nls`, `ut.reset_nls`. This way, the DATE data in cursors will be properly formatted for comparison using date-time format. The example below makes use of `ut.set_nls`, `ut.reset_nls`, so that the date in `l_expected` and `l_actual` is compared using date-time formatting. -```sql +```sql linenums="1" clear screen alter session set nls_date_format='yyyy-mm-dd'; set serverout on @@ -1539,8 +1655,9 @@ drop table events; ``` In the above example: + - The first expectation is successful, as the `l_expected` cursor contains different date-time then the cursor returned by `get_events` function call -- The second expectation fails, as the column `event_date` will get compared as DATE without TIME (suing default current session NLS date format) +- The second expectation fails, as the column `event_date` will get compared as DATE without TIME (using default current session NLS date format) Output via DBMS_OUTPUT from the above example: ``` @@ -1577,7 +1694,7 @@ This applies to `timestamp`,`timestamp with timezone`, `timestamp with local tim Example below illustrates usage of `cast` operator to assure appropriate precision is applied on timestamp bind-variables in cursor result-set -```sql +```sql linenums="1" clear screen set serverout on set feedback off @@ -1640,9 +1757,13 @@ FAILURE at "anonymous block", line 32 ``` -# Comparing Json objects +## Comparing Json objects + +utPLSQL is capable of comparing json data-types of `json_element_t`, and also `json` **on Oracle 21 and above** + +!!! note + Whenever a database is upgraded to compatible version the utPLSQL needs to be reinstalled to pick up json changes. E.g. upgrade from 19c to 23 AI to enable `json` type compare. -utPLSQL is capable of comparing json data-types **on Oracle 12.2 and above**. ### Notes on comparison of json data @@ -1650,11 +1771,12 @@ utPLSQL is capable of comparing json data-types **on Oracle 12.2 and above**. - During comparison of json objects the order doesn't matter. - During comparison of json arrays the index of element is taken into account - To compare json you have to make sure its type of `json_element_t` or its subtypes +- From version 21 and above a native `json` type is supported. -Compare JSON example: -```sql +Compare JSON example using `json_element_t`: +```sql linenums="1" declare l_expected json_element_t; l_actual json_element_t; @@ -1735,8 +1857,8 @@ FAILURE at "anonymous block", line 59 ``` -Comparing parts of JSON example: -```sql +Comparing parts of JSON example using `json_element_t` subtypes: +```sql linenums="1" declare l_actual json_object_t; l_actual_extract json_array_t; diff --git a/docs/userguide/getting-started.md b/docs/userguide/getting-started.md index 99383552a..4c2aa07f5 100644 --- a/docs/userguide/getting-started.md +++ b/docs/userguide/getting-started.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) # Getting started with TDD and utPLSQL @@ -7,7 +7,7 @@ utPLSQL is designed in a way that allows you to follow Below is an example of building a simple function with TDD. -# Gather requirements +## Gather requirements We have a requirement to build a function that will return a substring of a string that is passed to the function. @@ -17,14 +17,14 @@ The function should accept three parameters: - start_position - end_position -# Create a test +## Create a test We will start from the bare minimum and move step by step, executing tests every time we make minimal progress. This way, we assure we don't jump ahead too much and produce code that is untested or untestable. -## Create test package +### Create test package -```sql +```sql linenums="1" create or replace package test_betwnstr as --%suite(Between string function) @@ -43,9 +43,9 @@ Finished in .451423 seconds 0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` -## Define specification for the test +### Define specification for the test -```sql +```sql linenums="1" create or replace package test_betwnstr as --%suite(Between string function) @@ -76,9 +76,9 @@ Finished in .509673 seconds Well our test is failing as the package specification requires a body. -## Define body of first test +### Define body of first test -```sql +```sql linenums="1" create or replace package body test_betwnstr as procedure basic_usage is @@ -110,11 +110,11 @@ Finished in .415851 seconds Our test is failing as the test suite package body is invalid. Looks like we need to define the function we want to test. -# Implement code to fulfill the requirement +## Implement code to fulfill the requirement -## Define tested function +### Define tested function -```sql +```sql linenums="1" create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 is begin @@ -143,11 +143,11 @@ Finished in .375178 seconds So now we see that our test works but the function does not return the expected results. Let us fix this and continue from here. -## Fix the tested function +### Fix the tested function The function returned a string one character short, so we need to add 1 to the substr parameter. -```sql +```sql linenums="1" create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 is begin @@ -169,14 +169,14 @@ Finished in .006077 seconds So our test is now passing, great! -# Refactor +## Refactor Once our tests are passing, we can safely refactor (restructure) the code as we have a safety harness in place to ensure that after the restructuring and cleanup of the code, everything is still working. One thing worth mentioning is that refactoring of tests is as important as refactoring of code. Maintainability of both is equally important. -# Further requirements +## Further requirements It seems like our work is done. We have a function that returns a substring from start position to end position. As we move through the process of adding tests, it's very important to think about edge cases. @@ -195,12 +195,12 @@ Here is a list of edge cases for our function: We should define expected behavior for each of these edge cases. Once defined we can start implementing tests for those behaviors and adjust the tested function to meet the requirements specified in the tests. -## Add test for additional requirement +### Add test for additional requirement A new requirement was added: Start position zero - should be treated as start position one -```sql +```sql linenums="1" create or replace package test_betwnstr as --%suite(Between string function) @@ -250,11 +250,11 @@ Finished in .232584 seconds Looks like our function does not work as expected for zero start position. -## Implementing the requirement +### Implementing the requirement Let's fix our function so that the new requirement is met -```sql +```sql linenums="1" create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 is begin @@ -281,14 +281,14 @@ Finished in .012718 seconds Great! We have made some visible progress. -## Refactoring +### Refactoring When all tests are passing we can proceed with a safe cleanup of our code. The function works well, but we use the `return` twice, which is not the best coding practice. An alternative implementation could be cleaner. -```sql +```sql linenums="1" create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 is begin @@ -308,7 +308,7 @@ Finished in .013739 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` -# Remaining requirements +## Remaining requirements You may continue on with the remaining edge cases from here. diff --git a/docs/userguide/install.md b/docs/userguide/install.md index cc387a34f..04b47b97b 100644 --- a/docs/userguide/install.md +++ b/docs/userguide/install.md @@ -1,10 +1,56 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) -# Downloading latest version of utPLSQL +## Supported database versions -To download latest version of utPLSQL from github on both Unix/Linux as well as Windows machines use the below snippets. +- Oracle Database 19c with Release Update 19.20 or later, or any newer version (SE/EE/Cloud/Free) -## Unix/Linux +utPLSQL uses SQL macros. Earlier 19c Release Updates are not verified and supported. + +We do our best to assure full compatibility with **actively supported** versions of Oracle databases. +See [this page](https://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf#page=6) for Oracle Database Releases and their Support Lifetime by Oracle. + + +### Licensed features required + +utPLSQL doesn't require any extra licensed features of Oracle database. It can be installed on any Edition of Oracle Database. + +### Storage requirements + +utPLSQL will use tablespace for the following: +- storage of annotation cache +- storage of suite cache +- storage of profiler results +- storage for staging utPLSQL reports outputs + + +utPLSQL purges the staging storage for reports while fetching reports to screen / saving reports to files. + +Suite and annotation cache storage requirements are minimal and unless you have hundreds of thousands of tests, you'll probably not even notice the space used. + +Profiler results may require regular purging to assure low space consumption. +utPLSQl does not purge profiler tables as those tables can can be shared with other tools. + + +## Downloading utPLSQL + +### Manual download + +- Go to GitHub releases page for utPLSQL [`https://github.com/utPLSQL/utPLSQL/releases`](https://github.com/utPLSQL/utPLSQL/releases) +- Choose the version to download - latest is always greatest +- Download one of files + - utPLSQL.tar.gz + - utPLSQL.zip + +The files have identical content but use different compression (tar / zip ) so choose whichever you prefer depending on your platform (Win/Mac/Unix/Linux). + + +### Scripted download of latest utPLSQL version + +The below snippets can be used to download latest version of utPLSQL from github releases. + +After downloading follow the installation instructions in next sections of this document. + +#### Unix/Linux ```bash #!/bin/bash @@ -22,7 +68,7 @@ You may download with a one-liner if that is more convenient. curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip\"" | sed 's/"//g') ``` -## Windows +#### Windows To run the script on windows you will need [PowerShell 3.0](https://blogs.technet.microsoft.com/heyscriptingguy/2013/06/02/weekend-scripter-install-powershell-3-0-on-windows-7/) or above. You will also need .NET 4.0 Framework or above. @@ -51,30 +97,7 @@ foreach ($i in $urlList) { } ``` -# Checking environment and utPLSQL version - -To check the framework version execute the following query: -```sql -select substr(ut.version(),1,60) as ut_version from dual; -``` - -Additionally you may retrieve more information about your environment by executing the following query: -```sql -select - xmlserialize( content xmltype(ut_run_info()) as clob indent size = 2 ) - from dual; -``` - -# Supported database versions - -The utPLSQL may be installed on any supported version of Oracle Database [see](http://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf#page=6) -* 11g R2 -* 12c -* 12c R2 -* 18c -* 19c - -# Headless installation +## Headless installation utPLSQL can be installed with DDL trigger, to enable tracking of DDL changes to your unit test packages. This is the recommended installation approach, when you want to compile and run unit test packages in a schema containing huge amount of database packages (for example Oracle EBS installation schema). @@ -85,28 +108,17 @@ This process can be time-consuming if DB schema is large. The headless scripts accept three optional parameters that define: - username to create as owner of utPLSQL (default `ut3`) - password for owner of utPLSQL (default `XNtxj8eEgA6X6b6f`) -- tablespace to use for storage of profiler data (default `users`) +- tablespace to use for storage of profiler and utPLSQL cache data (default `users`) The scripts need to be executed by `SYSDBA`, in order to grant access to `DBMS_LOCK` and `DBMS_CRYPTO` system packages. -**Note:** -> Grant on `DBMS_LOCK` is required only for installation on Oracle versions below 18c. For versions 18c and above, utPLSQL uses `DBMS_SESSION.SLEEP` so access to `DBMS_LOCK` package is no longer needed. - -**Note:** -> The user performing the installation must have the `ADMINISTER DATABASE TRIGGER` privilege. This is required for installation of trigger that is responsible for parsing annotations at at compile-time of a package. - -**Note:** -> When installing with DDL trigger, utPLSQL will not be registering unit tests for any of oracle-maintained schemas. -For Oracle 11g following users are excluded: -> ANONYMOUS, APPQOSSYS, AUDSYS, DBSFWUSER, DBSNMP, DIP, GGSYS, GSMADMIN_INTERNAL, GSMCATUSER, GSMUSER, ORACLE_OCM, OUTLN, REMOTE_SCHEDULER_AGENT, SYS, SYS$UMF, SYSBACKUP, SYSDG, SYSKM, SYSRAC, SYSTEM, WMSYS, XDB, XS$NULL -> -> For Oracle 12c and above the users returned by below query are excluded by utPLSQL: -> ->```sql -> select username from all_users where oracle_maintained='Y'; ->``` +!!! warning "Important" + - `DBMS_LOCK` is required for session synchronization between main session and session consuming realtime reports.
+ - The user performing the installation must have the `ADMINISTER DATABASE TRIGGER` privilege. This is required for installation of trigger that is responsible for parsing annotations at at compile-time of a package.
+ - When installed with DDL trigger, utPLSQL will not be registering unit tests for any of oracle-maintained schemas.
+ `select username from all_users where oracle_maintained='Y';`
-## Installation without DDL trigger +### Installation without DDL trigger To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql` as SYSDBA. @@ -122,7 +134,7 @@ cd source sqlplus sys/sys_pass@db as sysdba @install_headless.sql utp3 my_verySecret_password utp3_tablespace ``` -## Installation with DDL trigger +### Installation with DDL trigger To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless_with_trigger.sql` as SYSDBA. @@ -138,16 +150,9 @@ cd source sqlplus sys/sys_pass@db as sysdba @install_headless_with_trigger.sql utp3 my_verySecret_password utp3_tablespace ``` -**Note:** ->When installing utPLSQL into database with existing unit test packages, utPLSQL will not be able to already-existing unit test packages. When utPSLQL was installed with DDL trigger, you have to do one of: ->- Recompile existing Unit Test packages to make utPLSQL aware of their existence ->- Invoke `exec ut_runner.rebuild_annotation_cache(a_schema_name=> ... );` for every schema containing unit tests in your database -> -> Steps above are required to assure annotation cache is populated properly from existing objects. Rebuilding annotation cache might be faster than code recompilation. - -# Recommended Schema +## Recommended Schema It is highly recommended to install utPLSQL in it's own schema. You are free to choose any name for this schema. -Installing uPLSQL into shared schema is really not recommended as you loose isolation of framework. +Installing uPLSQL into a shared schema is really not recommended as you loose isolation of framework. If the installing user and utPLSQL owner is one and the same, the user must have the following Oracle system permissions before you can proceed with the installation. @@ -160,17 +165,18 @@ If the installing user and utPLSQL owner is one and the same, the user must have - CREATE SYNONYM - ALTER SESSION - CREATE TRIGGER + - CREATE ROLE + - CREATE ANY CONTEXT (needed only for the installation, see [Installing utPLSQL](#installing-utplsql)) -In addition the user must be granted the execute privilege on `DBMS_LOCK` and `DBMS_CRYPTO` packages. +In addition, the user must be granted the execute privilege on `DBMS_LOCK` and `DBMS_CRYPTO` packages. -utPLSQL is using [DBMS_PROFILER tables](https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_profil.htm#i999476) for code coverage. The tables required by DBMS_PROFILER will be created in the installation schema unless they already exist. -The uninstall process will **not** drop profiler tables, as they can potentially be shared and reused for profiling PLSQL code. +utPLSQL is using [DBMS_PROFILER tables](https://docs.oracle.com/en/database/oracle/oracle-database/19/arpls/DBMS_PROFILER.html) for code coverage. The tables required by DBMS_PROFILER will be created in the installation schema unless they already exist. It is up to DBA to maintain the storage of the profiler tables. -# Manual installation procedure +## Manual installation procedure -## Creating schema for utPLSQL +### Creating schema for utPLSQL To create the utPLSQL schema and grant all the required privileges execute script `create_utplsql_owner.sql` from the `source` directory with parameters: - `user name` - the name of the user that will own of utPLSQL object @@ -183,18 +189,29 @@ cd source sqlplus sys/sys_password@database as sysdba @create_utPLSQL_owner.sql ut3 ut3 users ``` -## Installing utPLSQL +### Installing utPLSQL To install the utPLSQL framework into your database, go to `source` directory, run the `install.sql` providing the `schema_name` for utPLSQL as parameter. Schema must be created prior to calling the `install` script. You may install utPLSQL from any account that has sufficient privileges to create objects in other users schema. +The installation uses code based access control (CBAC) to give utPLSQL packages access to internal utPLSQL tables without granting those tables to users. +It creates the role `_cbac_modify_objects_role` (for example `ut3_cbac_modify_objects_role`), unless it already exists, and grants it to the utPLSQL schema and to utPLSQL packages. +The installing user therefore needs the `CREATE ROLE` privilege. Each utPLSQL schema gets its own role. The role is dropped when utPLSQL is uninstalled. + +The installation also creates the application context `_info` (for example `ut3_info`), which makes information about the running test available through [`sys_context`](annotations.md#sys_context). +The installing user therefore needs the `CREATE ANY CONTEXT` privilege. +This privilege is needed only while installing, not when running tests. +Because it is a powerful `ANY` privilege, `create_utplsql_owner.sql` deliberately does not grant it to the utPLSQL schema. +If you install utPLSQL as the utPLSQL schema owner, grant `CREATE ANY CONTEXT` to that user before the installation and revoke it afterwards. +The headless installation runs as `SYSDBA` and needs no additional grant. + Example invocation: ```bash cd source sqlplus admin/admins_password@database @install.sql ut3 ``` -## Installing DDL trigger +### Installing DDL trigger To minimize startup time of utPLSQL framework (especially on a database with large schema) it is recommended to install utPLSQL DDL trigger to enable utPLSQL annotation to be updated at compile-time. It's recommended to install DDL trigger when connected as `SYSDBA` user. Trigger is created in utPLSQL schema. @@ -209,11 +226,11 @@ cd source sqlplus admin/admins_password@database @install_ddl_trigger.sql ut3 ``` -**Note:** ->Trigger can be installed ant any point in time. +!!! note + Trigger can be installed ant any point in time after the utPLSQL installation. The framework will detect the presence of DDL trigger and act accordingly. -## Allowing other users to access the utPLSQL framework +### Allowing other users to access the utPLSQL framework In order to allow other users to access utPLSQL, synonyms must be created and privileges granted. You have two options: @@ -232,7 +249,7 @@ To grant utPLSQL to an individual user, execute scripts `source/create_user_gran Example invocation: ```bash cd source -sqlplus ut3_user/ut3_password@database @create_user_grants.sql ut3 hr +sqlplus ut3_owner_schema/ut3_password@database @create_user_grants.sql ut3 hr sqlplus user/user_password@database @create_user_synonyms.sql ut3 hr ``` @@ -242,15 +259,29 @@ The following tools that support the SQL*Plus commands can be used to run the in - [SQLcl](http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html) - [Oracle SQL Developer](http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html) -# Additional requirements +## Checking environment and utPLSQL version + +To check the framework version execute the following query: +```sql linenums="1" +select substr(ut.version(),1,60) as ut_version from dual; +``` + +Additionally you may retrieve more information about your environment by executing the following query: +```sql linenums="1" +select + xmlserialize( content xmltype(ut_run_info()) as clob indent size = 2 ) + from dual; +``` + +## Additional requirements In order to use the Code Coverage functionality of utPLSQL, users executing the tests must have the CREATE privilege on the PLSQL code that the coverage is gathered on. -This is a requirement of [DBMS_PROFILER package](https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_profil.htm#i999476). +This is a requirement of [DBMS_PROFILER package](https://docs.oracle.com/en/database/oracle/oracle-database/19/arpls/DBMS_PROFILER.html#GUID-DEE5EA97-14AA-4AF2-A5F7-4AB1D004B99F). In practice, user running tests for PLSQL code that he does not own, needs to have CREATE ANY PROCEDURE/CREATE ANY TRIGGER privileges. Running code coverage on objects that the user does not own will **not produce any coverage information** without those privileges. -# Uninstalling utPLSQL +## Uninstalling utPLSQL To uninstall run `uninstall.sql` and provide `schema_name` where utPLSQL is installed. @@ -260,7 +291,7 @@ cd source sqlplus admin/admins_password@database @uninstall.sql ut3 ``` -The uninstall script will remove all the objects installed by the install script. +The uninstall script will remove all the objects installed by the installation script. Additionally, all the public and private synonyms pointing to the objects in the utPLSQL schema will be removed. If you have extended any utPLSQL types such as a custom reporter, these will need to be dropped before the uninstall, otherwise the uninstall script might fail. @@ -268,15 +299,15 @@ If you have extended any utPLSQL types such as a custom reporter, these will nee The uninstall script does not drop the schema. **In order for the uninstall to be successful, you need to use the uninstall script that was provided with the exact utPLSQL version installed on your database.** -i.e. the uninstall script provided with version 3.0.1 will probably not work if you want to remove version 3.0.0 from your database. +i.e. the uninstall script provided with version 3.1.11 will not work correctly if you want to remove version 3.0.0 from your database. Alternatively you can drop the user that owns utPLSQL and re-create it using headless install. -# Version upgrade +## Version upgrade Currently, the only way to upgrade version of utPLSQL v3.0.0 and above is to remove the previous version and install the new version. -# Working with utPLSQL v2 +## Working with utPLSQL v2 If you are using utPLSQL v2, you can still install utPLSQL v3. The only requirement is that utPLSQL v3 needs to be installed in a different schema than utPLSQL v2. diff --git a/docs/userguide/querying_suites.md b/docs/userguide/querying_suites.md index 71619bec3..1aededc4a 100644 --- a/docs/userguide/querying_suites.md +++ b/docs/userguide/querying_suites.md @@ -1,7 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -# Qyerying for test suites - +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) ## Obtaining information about suites @@ -25,26 +22,36 @@ Querying the data from function provides the follwing details: - `tags` - tags associated with suites To get list of all test suites in current schema -```sql +```sql linenums="1" select * from table(ut_runner.get_suites_info()) where item_type = 'UT_SUITE'; ``` To get list of all tests for test suite `TEST_STUFF` in current user schema -```sql +```sql linenums="1" select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST'; ``` To get a full information about suite `TEST_STUFF` including suite description, all contexts and tests in a suite -```sql +```sql linenums="1" select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST'; ``` +To get a full information about suites that have a path like `ut3:tests.test_package_*` including suite description, all contexts and tests in a suite +```sql linenums="1" +select * from table(ut_runner.get_suites_info('ut3:tests.test_package_*') where item_type = 'UT_TEST'; +``` + +To get a full information about suites that have object name like `test_package_*` including suite description, all contexts and tests in a suite +```sql linenums="1" +select * from table(ut_runner.get_suites_info('test_package_*')); +``` + ## Checking if schema contains tests Function `ut_runner.has_suites(a_owner)` returns boolean value indicating if given schema contains test suites. Example: -```sql +```sql linenums="1" begin if ut_runner.has_suites(USER) then dbms_output.put_line( 'User '||USER||' owns test suites' ); @@ -59,7 +66,7 @@ end; Function `ut_runner.is_suite(a_owner, a_package_name) ` returns boolean value indicating if given package is a test suites. Example: -```sql +```sql linenums="1" begin if ut_runner.is_suite(USER,'TEST_STUFF') then dbms_output.put_line( 'Package '||USER||'.TEST_STUFF is a test suite' ); @@ -74,7 +81,7 @@ end; Function `ut_runner.is_test(a_owner, a_package_name, a_procedure_name) ` returns boolean value indicating if given package is a test suites. Example: -```sql +```sql linenums="1" begin if ut_runner.is_test(USER,'TEST_STUFF','A_TEST_TO_CHECK_STUFF') then dbms_output.put_line( 'Procedure '||USER||'.TEST_STUFF.A_TEST_TO_CHECK_STUFF is a test' ); diff --git a/docs/userguide/reporters.md b/docs/userguide/reporters.md index e7c5b5e8c..8a3a1bd55 100644 --- a/docs/userguide/reporters.md +++ b/docs/userguide/reporters.md @@ -1,8 +1,8 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) -utPLSQL provides the following reporting formats. +utPLSQL provides several reporting formats. The sections below describe most of them. -# Documentation reporter +## Documentation reporter The `ut_documentation_reporter` is the default reporting format used by the framework. It provides a human readable test results. @@ -17,7 +17,8 @@ Example outputs from documentation reporter. ![doc_reporter_outputs](../images/documentation_reporter.png) -The documentation report provides the following information. +Documentation reporter provides the following information. + - Test suite name or test package name (nested with suitepath if suitepath is used) - Test description name or test procedure name - Information about test failing `(FAILED - n)` @@ -26,7 +27,7 @@ The documentation report provides the following information. - Summary with total number of tests, number of tests with status and timing for the execution -## Color output from documentation reporter +### Color output from documentation reporter When invoking tests with documentation reporter and your command line supports ANSICONSOLE (default on Unix) [available for Windows](http://adoxa.altervista.org/ansicon/), you can obtain the coloured outputs from the documentation reporter. @@ -41,7 +42,7 @@ Example outputs from documentation reporter. ![doc_reporter_outputs](../images/documentation_reporter_color.png) -# JUnit reporter +## JUnit reporter Most of continuous integration servers (like Jenkins) are capable of consuming unit test execution results in [JUnit](https://en.wikipedia.org/wiki/JUnit) format. The `ut_junit_reporter` in earlier version referred as `ut_xunit_reporter` is producing outcomes as JUnit-compatible XML unit test report, that can be used by CI servers to display their custom reports and provide metrics (like tests execution trends). @@ -63,7 +64,7 @@ Example of failure report details -# Teamcity reporter +## Teamcity reporter [Teamcity](https://www.jetbrains.com/teamcity/) is a CI server by Jetbrains. It supports JUnit reporting and additionally has it's own format of reporting that allows tracking of progress of a CI step/task as it executes. The TeamCity format developed by Jetbrains is supported by utPLSQL with `ut_teamcity_reporter`. @@ -83,9 +84,12 @@ Example of failure report details ![junit_reporter_outputs_errors](../images/teamcity_report_example_errors.png) -# Sonar test reporter -If you are using [SonarQube](https://about.sonarqube.com/) to do static code analysis for you PLSQL projects, your code analysis can benefit from code coverage and test results. +## Sonar test reporter + +If you are using [SonarQube](https://www.sonarqube.org/) or [SonarCloud](https://about.sonarcloud.io/) to do static code analysis for you PLSQL projects, +your code analysis can benefit from code coverage and test results. utPLSQL provides two reporters to for SonarQube: + - `ut_sonar_test_reporter` - provides an XML output of each test executed per each project test file (package) - `ut_coverage_sonar_reporter` - provides XML output of code coverage per each project source file @@ -97,15 +101,15 @@ The paths to files can be relative to the project root directory (recommended) o Providing invalid paths or paths to non-existing files will result in failure when publishing test results/coverage results to sonar server. -For details on how to invoke reporter with paths, see the **Coverage reporters** section. +For details on how to invoke reporter with paths, see the [Code coverage](coverage.md) section. -# TFS / VSTS Reporter -If you are using [TFS](https://www.visualstudio.com/tfs/) or [VSTS](https://www.visualstudio.com/team-services/) to do static code analysis for you PLSQL projects and run builds, your code analysis can benefit from code coverage and test results. TFS reporter is designed specifically to [work with Microsoft Team Fundation Server](https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts) report format which is very old version of [JUnit](https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd). -Main diffrence between standard JUnit is that elements cannot be nested and attribute skipped is not present. +## TFS / VSTS Reporter -utPLSQL provides test reporter to for TFS / VSTS server: -- `ut_tfs_junit_reporter` - provides an XML output of each test executed per each project test file (package) +If you are using [TFS](https://www.visualstudio.com/tfs/) or [VSTS](https://www.visualstudio.com/team-services/) to do static code analysis for you PLSQL projects and run builds, +your code analysis can benefit from code coverage and test results. TFS reporter is designed specifically to [work with Microsoft Team Fundation Server](https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts) report format which is very old version of [JUnit](https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd). +Main difference between standard JUnit is that elements cannot be nested and attribute skipped is not present. +utPLSQL provides a dedicated `ut_tfs_junit_reporter` reporter to for TFS / VSTS servers. The reporter provides an XML output of each test executed per each project test file (package). Example of test report from TFS CI server. Summary: @@ -117,12 +121,26 @@ Details: ![tfs_junit_reporter_outputs](../images/tfs_details.png) -# Coverage reporters +## Coverage reporters + +utPLSQL comes with a set of build-in coverage reporters. +[Code coverage](coverage.md) section describes in details how to use configure and use code coverage. + +## TAP Reporter + +The `ut_tap_reporter` produces output compatible with the [Test Anything Protocol](https://testanything.org) (Version 14). TAP output can be consumed by a TAP consumer that can aggregate results from testsuites across different programming languages while maintaining good readability for humans. + +![tap_output_no_color](../images/tap_reporter_no_color.png) -utPLSQL comes with a set of build-in coverage reporters. Have a look into the [coverage documentation](coverage.md) to learn more about them. +If you use a compatible terminal, you can also have a colored result. Only top level `not ok`-results will be colored: +![tap_colored_output](../images/tap_reporter_colored.png) -# Debug reporter +Suites (and suitepaths) and contexts are included as [commented subtests](https://testanything.org/tap-version-14-specification.html#:~:text=Commented%20Subtests) including a summary of the tests performed for that specific context/suite. This example package has the suitepath "org.utplsql.tests.helpers": + +![tap_include_suitepath](../images/tap_reporter_suitepath.png) + +## Debug reporter The `ut_debug_reporter` provides a highly verbose output containing thorough details about framework and test execution. @@ -131,6 +149,7 @@ Use this reporter only when you need to investigate framework issues or raise a Usage of this reporter might have impact on performance of test-suite execution. Amongst others, reporter provides the following information: + - framework version - database version - database OS @@ -152,14 +171,51 @@ Amongst others, reporter provides the following information: - every test - every expectation and it's result -Some of the information in debug log might be redundant. +Some information in debug log might be redundant. -**Note:** ->Some of the information in debug log may be sensitive. In particular: -> - expectation results and messages (logged even for successful runs) -> - test structure -> - db object names -> - etc. +!!! note + Some information in debug log may be sensitive. In particular:
+ - expectation results and messages (logged even for successful runs)
+ - test structure
+ - db object names
+ - etc. - - \ No newline at end of file +## Support line + +utPLSQL is free and open source. Support and sponsorship provides funding for the project. To let teams know that commercial support is available and that their organization can help keep the project maintained, some reporters enrich their output with this line: + +``` +Using utPLSQL at work? Get support and help keep it maintained: https://utplsql.org/support +``` + +To switch the line off, call `ut.run` or `ut_runner.run` with `a_support_info => false` (or `a_support_info => 0` with `ut.run` functions). +See [Switching off the support line](running-unit-tests.md#switching-off-the-support-line). + +## Custom reporters + +It is possible to add your own reporters by creating an appropriate object type. +In principle, it has to be a subtype of `ut_reporter_base`. However, if the reporter is expected to produce output consumable by a client oustside of the database (e.g. the data has to be reported to the screen or to a file), then you should base it on `ut_output_reporter_base` (which is a subtype of `ut_reporter_base`). In contrast, if you would like to create a reporter that, for example, saves the data to a database table, then it should be based directly on `ut_reporter_base`. (Currently, all reporters in the utPLSQL framework are based on `ut_output_reporter_base`.) Coverage reporters are based on `ut_coverage_reporter_base` (a subtype of `ut_output_reporter_base`). + +If you need to produce a colored text output from the custom reporter, then you can build it basing on `ut_console_reporter_base` (a subtype of `ut_output_reporter_base`). In many cases it may also be more convenient to create the custom reporter type under a more specialized type, like `ut_documentation_reporter` or `ut_junit_reporter`, and override just some of the functionality. + +It is recommended to create the reporter type in the schema where utPLSQL is installed (by default it is the `UT3` schema). Note that before running the utPLSQL uninstall scripts, all custom reporters should be dropped (cf. [the installation documentation](install.md)). In particular, when upgrading to a newer version of utPLSQL, one has to drop the custom reporters and recreate them after the upgrade. + +!!! note + Please make sure that grants have been added and synonyms created for the custom reporter in order for reporter to be accessible the same way as other reporters. + Assuming that reporter with name `customer_reporter` was created in schema `UT3` +```sql + grant execute on ut3.custom_reporter to public; + create or replace public synonym custom_reporter for ut3.custom_reporter; +``` + + + +!!! note + It is possible, but cumbersome, to use another schema for storing the custom reporters. This requires to create a synonym for the base reporter type in the schema that is going to own the custom reporter, and to provide appropriate grants both to the owner of the custom reporter and to the user running the reporter. After upgrading or reinstalling utPLSQL, the extra privileges need to be recreated. This approach is not recommended. + +Assuming that the custom reporter type is created in the `UT3` schema, to run the tests using a custom reporter just call: `exec ut.run(ut3.custom_reporter_name());`, optionally providing parameter values to the `custom_reporter_name` constructor. + +One may get acquainted with the source code of the standard reporters bundled with utPLSQL (including the coverage reporters) by browsing the [`source/reporters/`](https://github.com/utPLSQL/utPLSQL/tree/develop/source/reporters) directory. The base reporter types `ut_reporter_base`, `ut_output_reporter_base` and `ut_console_reporter_base` are defined in [`source/core/types`](https://github.com/utPLSQL/utPLSQL/tree/develop/source/core/types). The base coverage reporter type `ut_coverage_reporter_base` is in [`source/core/coverage`](https://github.com/utPLSQL/utPLSQL/tree/develop/source/core/coverage). There are also two examples of custom reporters in [`examples/custom_reporters/`](https://github.com/utPLSQL/utPLSQL/tree/develop/examples/custom_reporters), both extending the functionality of `ut_documentation_reporter`: + +* `ut_custom_reporter` accepts an integer parameter `a_tab_size`; it alters the behaviour of `ut_documentation_reporter` by changing the size of the indentation according to the parameter value (by default the indentation is increased). +* `ut_expectations_reporter` accepts a `varchar2` parameter `a_report_all_expectations`; if its value is `'Y'` (which is the default), then the reporter shows the results of all expectations that are run. This stays in contrast with `ut_documentation_reporter`, which shows the results of all tests that are run, but only of the expectations that failed (keep in mind that a single test may consist of several expectations). diff --git a/docs/userguide/running-unit-tests.md b/docs/userguide/running-unit-tests.md index 7311d1b7a..e19ba66fc 100644 --- a/docs/userguide/running-unit-tests.md +++ b/docs/userguide/running-unit-tests.md @@ -1,6 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) - -# Running tests +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) utPLSQL framework provides two main entry points to run unit tests from within the database: @@ -10,7 +8,7 @@ utPLSQL framework provides two main entry points to run unit tests from within t These two entry points differ in purpose and behavior. Most of the time you will want to use `ut.run` as `ut_runner.run` is designed for API integration and does not display the results to the screen. -# Running from CI servers and command line +## Running from CI servers and command line The best way to run your tests from CI server or command line is to use the [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) command line client. @@ -24,16 +22,15 @@ You may download the latest release of the command line client from [here](https ```bash #!/bin/bash # Get the url to latest release "zip" file -DOWNLOAD_URL=$(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL-cli/releases/latest | awk '/zipball_url/ { print $2 }' | sed -r 's/"|,//g') +DOWNLOAD_URL=$(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL-cli/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip\"" | sed 's/"//g') # Download the latest release "zip" file curl -Lk "${DOWNLOAD_URL}" -o utplsql-cli.zip # Extract downloaded "zip" file unzip -q utplsql-cli.zip ``` -Keep in mind that you will need to download/provide Oracle JDBC driver separately, as it is not part of utPLSQL-cli due to licensing restrictions. -# ut.run +## ut.run The `ut` package contains overloaded `run` procedures and functions. The `run` API is designed to be called directly by a developer when using an IDE/SQL console to execute unit tests. @@ -43,11 +40,17 @@ A single line call is enough to execute a set of tests from one or more schemes. The **procedures** execute the specified tests and produce output to DBMS_OUTPUT using the specified reporter. The **functions** can only be used in SELECT statements. They execute the specified tests and produce outputs as a pipelined data stream to be consumed by a select statement. -## ut.run procedures +### ut.run procedures The examples below illustrate different ways and options to invoke `ut.run` procedures. - -```sql +You can use a wildcard character `*` to call tests by part of their name or to call tests that are located on paths matched by part of path string. +Wildcard character can be placed anywhere on the path and can occur mutliple times. +Schema name cannot contain a wildcard character whether is in a suitepath call or call by object name. +Only `*` is a wildcard. All other characters, including `_`, `.` and `$`, match only themselves. +A path with a wildcard selects every matching suite or test that you can run and that matches the tags (see [Run by Tags](#run-by-tags)). +Matches that you can't run, or that the tags exclude, are skipped. The run fails with a "does not exist" error only when nothing is left. + +```sql linenums="1" alter session set current_schema=hr; set serveroutput on begin @@ -57,7 +60,7 @@ end; Executes all tests in current schema (_HR_). -```sql +```sql linenums="1" set serveroutput on begin ut.run('HR'); @@ -66,7 +69,7 @@ end; Executes all tests in specified schema (_HR_). -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr:com.my_org.my_project'); @@ -76,8 +79,25 @@ end; Executes all tests from all packages that are on the _com.my_org.my_project_ suitepath. Check the [annotations documentation](annotations.md) to find out about suitepaths and how they can be used to organize test packages for your project. +```sql linenums="1" +set serveroutput on +begin + ut.run('hr:com*'); +end; +``` + +Executes all tests in schema `hr` from all packages that are on suitepath starting with `com`. + +```sql linenums="1" +set serveroutput on +begin + ut.run('hr:co*.my_*.my_*'); +end; +``` + +Executes all tests in schema `hr` from all packages that starting with `my_` and all tests starting with `my_*` that are on suitepath starting with `co` . -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr.test_apply_bonus'); @@ -86,7 +106,7 @@ end; Executes all tests from package _hr.test_apply_bonus_. -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr.test_apply_bonus.bonus_cannot_be_negative'); @@ -95,36 +115,53 @@ end; Executes single test procedure _hr.test_apply_bonus.bonus_cannot_be_negative_. -```sql +```sql linenums="1" set serveroutput on begin ut.run(ut_varchar2_list('hr.test_apply_bonus','cust')); end; ``` -Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. +Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_ (passing individual items to be executed as elements of the ut_varchar2_list table type). -```sql + +```sql linenums="1" set serveroutput on begin - ut.run(ut_varchar2_list('hr.test_apply_bonus,cust)'); + ut.run(ut_varchar2_list('hr.test_apply_bonus,cust')); end; ``` +Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_ (passing all items as a comma-separated-list of values into a single element of the ut_varchar2_list table type). -Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr.test_apply_bonus,cust'); end; ``` -Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. +Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_ (no explicit ut_varchar2_list table type). Using a list of items to execute allows you to execute a fine-grained set of tests. List can be passed as a comma separated list or a list of *ut_varchar2_list objects* or as a list within ut_varchar2_list. +```sql linenums="1" +set serveroutput on +begin + ut.run('hr.test*'); +end; +``` +Executes all tests in schema `hr` located in packages starting with name `test`. + +```sql linenums="1" +set serveroutput on +begin + ut.run('hr.test_apply_bonus.bonus_*'); +end; +``` +Executes test procedures with names starting with `bonus` in package `hr.test_apply_bonus` . + **Note:** @@ -133,7 +170,7 @@ List can be passed as a comma separated list or a list of *ut_varchar2_list obje The `ut.run` procedures and functions accept `a_reporter` attribute that defines the reporter to be used in the run. You can execute any set of tests with any of the predefined reporters. -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr.test_apply_bonus', ut_junit_reporter()); @@ -144,7 +181,7 @@ Executes all tests from package _HR.TEST_APPLY_BONUS_ and provide outputs to DBM For details on build-in reporters look at [reporters documentation](reporters.md). -## ut.run functions +### ut.run functions The `ut.run` functions provide exactly the same functionality as the `ut.run` procedures. You may use the same sets of parameters with both functions and procedures. @@ -156,11 +193,11 @@ Functions provide output as a pipelined stream and therefore need to be executed At the end of the run, the transaction is automatically rolled-back and all uncommitted changes are reverted. Example. -```sql +```sql linenums="1" select * from table(ut.run('hr.test_apply_bonus', ut_junit_reporter())); ``` -# ut_runner.run procedures +## ut_runner.run procedures The `ut_runner` package provides an API for integrating utPLSQL with other products. Maven, Jenkins, SQL Develper, PL/SQL Developer, TOAD and others can leverage this API to call utPLSQL. @@ -180,6 +217,7 @@ Outputs of multiple reporters can be consumed in parallel. This allows for live - controlling client character set for HTML and XML reports - controlling rollback behavior of test-run - controlling random order of test execution +- switching off the support line Running with multiple reporters. @@ -189,19 +227,19 @@ Running with multiple reporters. - each reporter for each test-run must have a unique `reporter_id`. The `reporter_id` is used between two sessions to identify the data stream Example: -```sql +```sql linenums="1" --main test run ( session 1 ) declare l_reporter ut_realtime_reporter := ut_realtime_reporter(); begin l_reporter.set_reporter_id( 'd8a79e85915640a6a4e1698fdf90ba74' ); l_reporter.output_buffer.init(); - ut_runner.run (ut_varchar2_list ('ut3_tester','ut3$user#'), ut_reporters( l_reporter ) ); + ut_runner.run (ut_varchar2_list ('ut3_tester','ut3_user'), ut_reporters( l_reporter ) ); end; / ``` -```sql +```sql linenums="1" --report consumer ( session 2 ) set arraysize 1 set pagesize 0 @@ -214,7 +252,7 @@ select * ); ``` -```sql +```sql linenums="1" --alternative version of report consumer ( session 2 ) set arraysize 1 set pagesize 0 @@ -226,17 +264,27 @@ select from dual; ``` +## Running tests owned by other users + +To run tests in another schema, you need the EXECUTE privilege on its test packages, or the EXECUTE ANY PROCEDURE privilege. +Packages that you can't execute are skipped. + +If such a package is a parent suite (by `--%suitepath`) of a package that you can execute, the child package still runs. +A logical suite with the same name takes the parent's place, so the parent's `--%beforeall`/`--%afterall`, `--%rollback` and `--%tags` don't apply to the child. +The run reports a warning that names the skipped parent suite. + +A path that selects only packages you can't execute fails with a "does not exist" error. -# Order of test execution +## Order of test execution -## Default order +### Default order When unit tests are executed without random order, they are ordered by: -- schema name +- schema name: when a run includes several schemas, the suites of each schema run together, in order of schema names - suite path or test package name if `--%suitepath` was not specified for that package - `--%test` line number in package -## Random order +### Random order You can force a test run to execute tests in random order by providing one of options to `ut.run`: - `a_random_test_order` - true/false for procedures and 1/0 for functions @@ -246,14 +294,14 @@ When tests are executed with random order, randomization is applied to single le This is needed to maintain visibility and accessibility of common setup/cleanup `beforeall`/`afterall` in tests. Example: -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr.test_apply_bonus', a_random_test_order => true); end; ``` -```sql +```sql linenums="1" select * from table(ut.run('hr.test_apply_bonus', a_random_test_order => 1)); ``` @@ -268,21 +316,241 @@ Tests were executed with random order seed '302980531'. If you want to re-run tests using previously generated seed, you may do so by running them with parameter `a_random_test_order_seed` Example: -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr.test_apply_bonus', a_random_test_order_seed => 302980531); end; ``` -```sql +```sql linenums="1" select * from table(ut.run('hr.test_apply_bonus', a_random_test_order_seed => 302980531)); ``` **Note** >Random order seed must be a positive number within range of 1 .. 1 000 000 000. -# Keeping uncommitted data after test-run +## Run by Tags + +In addition to the path, you can filter the tests to be run by specifying tags. Tags are defined in the test / context / suite with the `--%tags`-annotation ([Read more](annotations.md#tags)). +Multiple tags are separated by comma. + + +### Tag Expressions + +Tag expressions are boolean expressions created by combining tags with the `!`, `&`, `|` operators. Tag expressions can be grouped using `(` and `)` braces. Grouping tag expressions affects operator precedence. +An invalid tag expression raises an error (ORA-20219) before any test runs. +Spaces and tabs in a tag expression are ignored. A tag expression made only of spaces and tabs doesn't filter the tests, the same as no tag expression. + +Two reserved keywords, `any` and `none`, can be used when creating a tag expression to run tests. +- `any` keyword represents tests and suites with any tags +- `none` keyword represents tests and suites without tags + +These keywords may be combined with other expressions just like normal tags. +The keywords are lowercase only. Like tags, they are case sensitive, so `NONE` or `Any` in a tag expression is an ordinary tag name, not a keyword. + +!!! note + When specifying `none`, be aware that it will exclude any tests/suites/contexts contained within a tagged suite. + +| Operator | Meaning | +| -------- | --------| +| ! | not | +| & | and | +| \| | or | + +If you are tagging your tests across multiple dimensions, tag expressions help you to select which tests to execute. When tagging by test type (e.g., micro, integration, end-to-end) and feature (e.g., product, catalog, shipping), the following tag expressions can be useful. + + +| Tag Expression | Selection | +| -------- | --------| +| product | all tests for product | +| catalog \| shipping | all tests for catalog plus all tests for shipping | +| catalog & shipping | all tests that are tagged with both `catalog` and `shipping` tags | +| product & !end-to-end | all tests tagged `product`, except the tests tagged `end-to-end` | +| (micro \| integration) & (product \| shipping) | all micro or integration tests for product or shipping | + + +Taking the last expression above `(micro | integration) & (product | shipping)` + +| --%tags |included in run | +| -------- | --------| +| micro | no | +| integration | no | +| micro | no | +| product | no | +| shipping | no | +| micro | no | +| micro, integration | no | +| product, shipping | no | +| micro, product | yes | +| micro, shipping | yes | +| integration, product | yes | +| integration, shipping | yes | +| integration, micro, shipping | yes | +| integration, micro, product | yes | +| integration, shipping ,product | yes | +| micro, shipping ,product | yes | +| integration, micro, shipping ,product | yes | + + +### Sample execution of test with tags. + +Execution of the test with tag expressions is done using the parameter `a_tags`. +Given a test package `ut_sample_test` defined below + +```sql linenums="1" +create or replace package ut_sample_test is + + --%suite(Sample Test Suite) + --%tags(api) + + --%test(Compare Ref Cursors) + --%tags(complex,fast) + procedure ut_refcursors1; + + --%test(Run equality test) + --%tags(simple,fast) + procedure ut_test; + +end ut_sample_test; +/ + +create or replace package body ut_sample_test is + + procedure ut_refcursors1 is + v_actual sys_refcursor; + v_expected sys_refcursor; + begin + open v_expected for select 1 as test from dual; + open v_actual for select 2 as test from dual; + + ut.expect(v_actual).to_equal(v_expected); + end; + + procedure ut_test is + begin + ut.expect(1).to_equal(0); + end; + +end ut_sample_test; +/ +``` + +```sql linenums="1" +select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'api')); +``` +The above call will execute all tests from `ut_sample_test` package as the whole suite is tagged with `api` + +```sql linenums="1" +select * from table(ut.run(a_tags => 'fast&complex')); +``` +The above call will execute only the `ut_sample_test.ut_refcursors1` test, as only the test `ut_refcursors1` is tagged with `complex` and `fast` + +```sql linenums="1" +select * from table(ut.run(a_tags => 'fast')); +``` +The above call will execute both `ut_sample_test.ut_refcursors1` and `ut_sample_test.ut_test` tests, as both tests are tagged with `fast` + +### Excluding tests/suites by tags + +It is possible to exclude parts of test suites with tags. +In order to do so, prefix the tag name to exclude with a `!` (exclamation) sign when invoking the test run which is equivalent of `-` (dash) in legacy notation. +Examples (based on above sample test suite) + +```sql linenums="1" +select * from table(ut.run(a_tags => '(api|fast)&!complex')); +``` + +or + +```sql linenums="1" +select * from table(ut.run(a_tags => '(api|fast)&!complex&!test1')); +``` + +which is equivalent of exclusion on whole expression + +```sql linenums="1" +select * from table(ut.run(a_tags => '(api|fast)&!(complex|test1)')); +``` + +The above calls will execute all suites/contexts/tests that are marked with any of tags `api` or `fast` except those suites/contexts/tests that are marked as `complex` and except those suites/contexts/tests that are marked as `test1`. +Given the above example package `ut_sample_test`, only `ut_sample_test.ut_test` will be executed. + + +### Sample execution with `any` and `none` + +Given a sample test package: + +```sql linenums="1" +create or replace package ut_sample_test is + + --%suite(Sample Test Suite) + + --%test(Compare Ref Cursors) + --%tags(complex,fast) + procedure ut_refcursors1; + + --%test(Run equality test) + --%tags(simple,fast) + procedure ut_test; + + --%test(Run equality test no tag) + procedure ut_test_no_tag; + +end ut_sample_test; +/ + +create or replace package body ut_sample_test is + + procedure ut_refcursors1 is + v_actual sys_refcursor; + v_expected sys_refcursor; + begin + open v_expected for select 1 as test from dual; + open v_actual for select 2 as test from dual; + + ut.expect(v_actual).to_equal(v_expected); + end; + + procedure ut_test is + begin + ut.expect(1).to_equal(0); + end; + + procedure ut_test_no_tag is + begin + ut.expect(1).to_equal(0); + end; + +end ut_sample_test; +/ +``` + +```sql linenums="1" +select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'none')); +``` + +The above call will execute tests `ut_test_no_tag` + +```sql linenums="1" +select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'any')); +``` + +The above call will execute tests `ut_test` and `ut_refcursors1` + +```sql linenums="1" +select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'none|simple')); +``` + +The above call will execute tests `ut_test_no_tag` and `ut_test` + +```sql linenums="1" +select * from table(ut.run(a_tags => 'none|!simple')); +``` + +The above call will execute tests `ut_test_no_tag` and `ut_refcursors1` + +## Keeping uncommitted data after test-run utPLSQL by default runs tests in autonomous transaction and performs automatic rollback to assure that tests do not impact one-another and do not have impact on the current session in your IDE. @@ -293,7 +561,7 @@ Setting this flag to true has following side-effects: - automatic rollback is forced to be disabled in test-run even if it was explicitly enabled by using annotation `--%rollback(manual) Example invocation: -```sql +```sql linenums="1" set serveroutput on begin ut.run('hr.test_apply_bonus', a_force_manual_rollback => true); @@ -303,7 +571,23 @@ end; **Note:** >This option is not available when running tests using `ut.run` as a table function. -# Reports character-set encoding +## Switching off the support line + +Some of the reporters include a short line about [utPLSQL support and sponsorship](reporters.md#support-line). +To leave it out, set `a_support_info` to `false` when calling `ut.run` procedures or `ut_runner.run`, or to `0` when calling `ut.run` functions. + +```sql linenums="1" +set serveroutput on +begin + ut.run('hr.test_apply_bonus', a_support_info => false); +end; +``` + +```sql linenums="1" +select * from table(ut.run('hr.test_apply_bonus', a_support_info => 0)); +``` + +## Reports character-set encoding To get properly encoded reports, when running utPLSQL with HTML/XML reports on data containing national characters you need to provide your client character set when calling `ut.run` functions and procedures. @@ -312,8 +596,8 @@ If you run your tests using `utPLSQL-cli`, this is done automatically and no act To make sure that the reports will display your national characters properly when running from IDE like SQLDeveloper/TOAD/SQLPlus or sqlcl you need to provide the charaterset manualy to `ut.run`. Example call with characterset provided: -```sql +```sql linenums="1" begin ut.run('hr.test_apply_bonus', ut_junit_reporter(), a_client_character_set => 'Windows-1251'); end; -``` \ No newline at end of file +``` diff --git a/docs/userguide/upgrade.md b/docs/userguide/upgrade.md index f11bcb48c..28421a1e9 100644 --- a/docs/userguide/upgrade.md +++ b/docs/userguide/upgrade.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.8.3169--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) # Upgrading from version 2 diff --git a/examples/RunAllExamples.sql b/examples/RunAllExamples.sql index 75ac59a9d..f5f42b7f3 100644 --- a/examples/RunAllExamples.sql +++ b/examples/RunAllExamples.sql @@ -1,24 +1,10 @@ PROMPT Run all examples -set echo off -set feedback off +set echo on +set feedback on set linesize 1000 -declare - l_run_number binary_integer; -begin - dbms_profiler.start_profiler( run_number => l_run_number); -end; -/ - -- Examples for users @@RunUserExamples.sql -- Framework developer examples @@RunDeveloperExamples.sql - -declare - l_return_code binary_integer; -begin - l_return_code := dbms_profiler.stop_profiler(); -end; -/ diff --git a/examples/RunAllExamplesAsTests.sql b/examples/RunAllExamplesAsTests.sql index 458f11091..d089ba447 100644 --- a/examples/RunAllExamplesAsTests.sql +++ b/examples/RunAllExamplesAsTests.sql @@ -3,3 +3,7 @@ whenever oserror exit failure rollback @@RunAllExamples.sql +prompt ******************************************************************************* +prompt All examples completed successfully +prompt ******************************************************************************* +prompt diff --git a/examples/RunCustomReportersExamples.sql b/examples/RunCustomReportersExamples.sql new file mode 100644 index 000000000..730946662 --- /dev/null +++ b/examples/RunCustomReportersExamples.sql @@ -0,0 +1,10 @@ +prompt ******************************************************************************* +prompt Running custom reporters examples +prompt ******************************************************************************* +Clear Screen +set echo off +set feedback on +set linesize 1000 + +@@custom_reporters/run_ut_custom_reporter.sql +@@custom_reporters/run_ut_expectations_reporter.sql diff --git a/examples/RunDeveloperExamples.sql b/examples/RunDeveloperExamples.sql index d34914b58..2f4ca13e3 100644 --- a/examples/RunDeveloperExamples.sql +++ b/examples/RunDeveloperExamples.sql @@ -1,13 +1,11 @@ PROMPT Run developer examples Clear Screen -set echo off -set feedback off +set echo on +set feedback on set linesize 1000 exec ut_ansiconsole_helper.color_enabled(true); --developer examples -prompt RunExampleTestSuiteWithCustomReporter -@@developer_examples/RunExampleTestSuiteWithCustomReporter.sql prompt RunExampleTestAnnotationsParsingTimeHugePackage @@developer_examples/RunExampleTestAnnotationsParsingTimeHugePackage.sql prompt RunExampleTestSuite diff --git a/examples/RunExpectations.sql b/examples/RunExpectations.sql index aeb5c40bc..eed123e72 100644 --- a/examples/RunExpectations.sql +++ b/examples/RunExpectations.sql @@ -11,7 +11,7 @@ set echo off @@demo_expectations.pck begin - ut_coverage.coverage_start(); + ut_coverage.coverage_start(sys_guid()); ut_coverage.set_develop_mode(true); ut.run(); ut_coverage.set_develop_mode(false); diff --git a/examples/RunUserExamples.sql b/examples/RunUserExamples.sql index 5323a07aa..702ccbce8 100644 --- a/examples/RunUserExamples.sql +++ b/examples/RunUserExamples.sql @@ -1,6 +1,6 @@ PROMPT Run user examples -set echo off -set feedback off +set echo on +set feedback on set linesize 1000 prompt Common examples from web diff --git a/examples/annoation_parser_testing/annotation_parser_test.sql b/examples/annoation_parser_testing/annotation_parser_test.sql new file mode 100644 index 000000000..d1ff43fcd --- /dev/null +++ b/examples/annoation_parser_testing/annotation_parser_test.sql @@ -0,0 +1,298 @@ +-- Annotation Manager Volume Benchmark +-- 1000 generated packages, cold cache per iteration + +set serveroutput on size unlimited +set timing off +set feedback off + +declare + c_packages constant pls_integer := 1000; + c_procs_per_pkg constant pls_integer := 20; + c_contexts_per_pkg constant pls_integer := 4; + c_pkg_prefix constant varchar2(20) := 'TST_GEN_PKG_'; + c_iterations constant pls_integer := 4; + c_perf_threshold constant number := 0.80; + + l_baseline_total_ms number := 0; + l_new_total_ms number := 0; + l_start timestamp; + l_elapsed interval day to second; + + -- Source holders + l_source_lines dbms_preprocessor.source_lines_t; + l_source_clob clob; + l_result ut_annotations; + + -- Correctness tracking + l_missing_from_cache pls_integer := 0; + l_count_mismatches pls_integer := 0; + l_mismatch_detail varchar2(32767); + + -- Cache check + l_cursor sys_refcursor; + l_annotated_obj ut_annotated_object; + l_name varchar2(128); + l_annotations ut_annotations; + l_cache_count pls_integer := 0; + + -- Per-package timing + l_pkg_baseline_ms number; + l_pkg_new_ms number; + l_pkg varchar2(30); + l_ratio number; + + -- Expected annotation count — mirrors generator logic exactly + function expected_annotation_count( + a_pkg_number pls_integer, + a_procs pls_integer, + a_contexts pls_integer + ) return pls_integer is + l_count pls_integer := 0; + begin + l_count := l_count + 2; -- %suite + %suitepath + l_count := l_count + 2; -- %beforeall + %afterall + l_count := l_count + 2; -- %beforeeach + %aftereach + + -- package level conditional + if mod(a_pkg_number, 3) = 0 then l_count := l_count + 1; end if; -- %displayname + if mod(a_pkg_number, 5) = 0 then l_count := l_count + 1; end if; -- %rollback + + -- contexts: each contributes %context + %endcontext + l_count := l_count + (a_contexts * 2); + + -- per procedure + for i in 1 .. a_procs loop + l_count := l_count + 1; -- %test + if mod(i, 3) = 0 then l_count := l_count + 1; end if; -- %tags + if mod(i, 6) = 0 then l_count := l_count + 1; end if; -- %throws + if mod(i, 8) = 0 then l_count := l_count + 1; end if; -- %disabled + if mod(i, 5) = 0 then l_count := l_count + 2; end if; -- %beforetest + %aftertest + end loop; + + return l_count; + end expected_annotation_count; + +begin + dbms_output.put_line('Packages : ' || c_packages); + dbms_output.put_line('Procs/pkg : ' || c_procs_per_pkg); + dbms_output.put_line('Contexts/pkg: ' || c_contexts_per_pkg); + dbms_output.put_line('Iterations : ' || c_iterations); + dbms_output.put_line('Started : ' || to_char(systimestamp,'YYYY-MM-DD HH24:MI:SS.FF3')); + + -- Phase 1: Performance benchmark (cold cache per package per iteration) + dbms_output.put_line(chr(10) || '-- Phase 1: Performance --'); + dbms_output.put_line( + rpad('package', 20) || ' | ' || + lpad('baseline_ms', 11) || ' | ' || + lpad('new_ms', 6) || ' | ' || + lpad('ratio', 5) || ' | ' || + 'status' + ); + dbms_output.put_line(rpad('-', 70, '-')); + + for p in 1 .. c_packages loop + l_pkg := c_pkg_prefix || lpad(p, 4, '0'); + + -- load source once per package + l_source_lines := dbms_preprocessor.get_post_processed_source( + object_type => 'PACKAGE', + schema_name => user, + object_name => l_pkg + ); + + dbms_lob.createtemporary(l_source_clob, true); + for i in 1 .. l_source_lines.count loop + dbms_lob.writeappend(l_source_clob, length(l_source_lines(i)), l_source_lines(i)); + end loop; + + -- baseline: clob version + l_pkg_baseline_ms := 0; + for iter in 1 .. c_iterations loop + ut_annotation_manager.purge_cache(user, 'PACKAGE'); + l_start := systimestamp; + l_result := ut_annotation_parser.parse_object_annotations(l_source_clob); + l_elapsed := systimestamp - l_start; + l_pkg_baseline_ms := l_pkg_baseline_ms + + extract(second from l_elapsed) * 1000; + end loop; + l_pkg_baseline_ms := l_pkg_baseline_ms / c_iterations; + + -- new: source_lines_t version + l_pkg_new_ms := 0; + for iter in 1 .. c_iterations loop + ut_annotation_manager.purge_cache(user, 'PACKAGE'); + l_start := systimestamp; + l_result := ut_annotation_parser.parse_object_annotations(l_source_lines); + l_elapsed := systimestamp - l_start; + l_pkg_new_ms := l_pkg_new_ms + + extract(second from l_elapsed) * 1000; + end loop; + l_pkg_new_ms := l_pkg_new_ms / c_iterations; + + -- accumulate + l_baseline_total_ms := l_baseline_total_ms + l_pkg_baseline_ms; + l_new_total_ms := l_new_total_ms + l_pkg_new_ms; + + l_ratio := round(l_pkg_new_ms / nullif(l_pkg_baseline_ms, 0), 3); + + -- print every 100 packages to avoid flooding output + if mod(p, 100) = 0 or p = 1 then + dbms_output.put_line( + rpad(l_pkg, 20) || ' | ' || + lpad(round(l_pkg_baseline_ms, 3), 11) || ' | ' || + lpad(round(l_pkg_new_ms, 3), 6) || ' | ' || + lpad(l_ratio, 5) || ' | ' || + case when l_ratio <= c_perf_threshold + then 'PASS (' || round((1-l_ratio)*100,1) || '% faster)' + else 'SLOW (ratio=' || l_ratio || ')' + end + ); + end if; + + dbms_lob.freetemporary(l_source_clob); + end loop; + + -- ------------------------------------------------------------------------- + -- Phase 1 summary + -- ------------------------------------------------------------------------- + l_ratio := round(l_new_total_ms / nullif(l_baseline_total_ms, 0), 3); + + dbms_output.put_line(rpad('-', 70, '-')); + dbms_output.put_line('Baseline total ms : ' || round(l_baseline_total_ms, 3)); + dbms_output.put_line('New total ms : ' || round(l_new_total_ms, 3)); + dbms_output.put_line('Overall ratio : ' || l_ratio); + dbms_output.put_line('Improvement : ' || round((1 - l_ratio) * 100, 1) || '%'); + + -- Phase 2: Cache presence check + dbms_output.put_line(chr(10) || '-- Phase 2: Cache presence --'); + + ut_annotation_manager.purge_cache(user, 'PACKAGE'); + ut_annotation_manager.rebuild_annotation_cache(user, 'PACKAGE'); + + -- query cache tables directly to avoid validate_annotation_cache side effects + open l_cursor for + select ut_annotated_object( + i.object_owner, i.object_name, i.object_type, i.parse_time, + cast( + collect( + ut_annotation( + c.annotation_position, c.annotation_name, + c.annotation_text, c.subobject_name + ) order by c.annotation_position + ) as ut_annotations + ) + ) + from ut_annotation_cache_info i + join ut_annotation_cache c on i.cache_id = c.cache_id + where i.object_owner = user + and i.object_type = 'PACKAGE' + and i.object_name like c_pkg_prefix || '%' + group by i.object_owner, i.object_type, i.object_name, i.parse_time; + + loop + fetch l_cursor into l_annotated_obj; + exit when l_cursor%notfound; + l_cache_count := l_cache_count + 1; + end loop; + close l_cursor; + + dbms_output.put_line('Expected in cache : ' || c_packages); + dbms_output.put_line('Found in cache : ' || l_cache_count); + dbms_output.put_line('Cache check : ' || + case when l_cache_count = c_packages + then 'PASS — all ' || c_packages || ' packages found in cache' + else 'FAIL — missing ' || (c_packages - l_cache_count) || ' packages from cache' + end + ); + + -- Phase 3: Annotation count correctness + dbms_output.put_line(chr(10) || '-- Phase 3: Annotation count correctness --'); + + -- reopen same direct cache query for correctness check + open l_cursor for + select ut_annotated_object( + i.object_owner, i.object_name, i.object_type, i.parse_time, + cast( + collect( + ut_annotation( + c.annotation_position, c.annotation_name, + c.annotation_text, c.subobject_name + ) order by c.annotation_position + ) as ut_annotations + ) + ) + from ut_annotation_cache_info i + join ut_annotation_cache c on i.cache_id = c.cache_id + where i.object_owner = user + and i.object_type = 'PACKAGE' + and i.object_name like c_pkg_prefix || '%' + group by i.object_owner, i.object_type, i.object_name, i.parse_time; + + loop + fetch l_cursor into l_annotated_obj; + exit when l_cursor%notfound; + l_name := l_annotated_obj.object_name; + l_annotations := l_annotated_obj.annotations; + + declare + l_pkg_number pls_integer; + l_expected pls_integer; + begin + l_pkg_number := to_number(substr(l_name, length(c_pkg_prefix) + 1)); + l_expected := expected_annotation_count( + l_pkg_number, + c_procs_per_pkg, + c_contexts_per_pkg + ); + + if l_annotations.count != l_expected then + l_count_mismatches := l_count_mismatches + 1; + if l_count_mismatches <= 10 then + l_mismatch_detail := l_mismatch_detail || chr(10) || + ' ' || l_name || + ': expected=' || l_expected || + ' actual=' || l_annotations.count; + end if; + end if; + end; + end loop; + close l_cursor; + + dbms_output.put_line('Packages checked : ' || c_packages); + dbms_output.put_line('Count mismatches : ' || l_count_mismatches); + if l_count_mismatches > 0 then + dbms_output.put_line('Mismatch detail (first 10):' || l_mismatch_detail); + end if; + dbms_output.put_line('Count check : ' || + case when l_count_mismatches = 0 + then 'PASS — all annotation counts match expected' + else 'FAIL — ' || l_count_mismatches || ' packages have wrong annotation count' + end + ); + + dbms_output.put_line(chr(10) || '================================================='); + dbms_output.put_line('FINAL RESULTS'); + dbms_output.put_line('================================================='); + dbms_output.put_line('Performance : ' || + case when l_ratio <= c_perf_threshold then 'PASS' else 'FAIL' end); + dbms_output.put_line('Cache : ' || + case when l_cache_count = c_packages then 'PASS' else 'FAIL' end); + dbms_output.put_line('Counts : ' || + case when l_count_mismatches = 0 then 'PASS' else 'FAIL' end); + dbms_output.put_line('Overall : ' || + case when l_ratio <= c_perf_threshold + and l_cache_count = c_packages + and l_count_mismatches = 0 + then 'PASS' + else 'FAIL' + end + ); + dbms_output.put_line('Finished : ' || + to_char(systimestamp, 'YYYY-MM-DD HH24:MI:SS.FF3')); + dbms_output.put_line('================================================='); + + -- cleanup + ut_annotation_manager.purge_cache(user, 'PACKAGE'); + +end; +/ diff --git a/examples/annoation_parser_testing/create_test_packages.sql b/examples/annoation_parser_testing/create_test_packages.sql new file mode 100644 index 000000000..94a7f3de2 --- /dev/null +++ b/examples/annoation_parser_testing/create_test_packages.sql @@ -0,0 +1,185 @@ +declare + c_packages constant pls_integer := 1000; + c_procs_per_pkg constant pls_integer := 20; + + l_spec varchar2(32767); + l_body varchar2(32767); + l_pkg varchar2(30); + l_errors pls_integer := 0; + + procedure append_to_source(a_source in out nocopy varchar2, a_text varchar2) is + begin + a_source := a_source || a_text; + end; + + procedure append_line(a_source in out nocopy varchar2, a_text varchar2 default null) is + begin + a_source := a_source || a_text || chr(10); + end; + +begin + + for r in ( + select object_name + from user_objects + where object_name like 'TST_GEN_PKG_%' + and object_type = 'PACKAGE' + order by object_name + ) loop + begin + execute immediate 'drop package ' || r.object_name; + exception + when others then + dbms_output.put_line('ERROR dropping ' || r.object_name || ': ' || sqlerrm); + end; + end loop; + dbms_output.put_line('Existing packages dropped.'); + + for p in 1 .. c_packages loop + l_pkg := 'TST_GEN_PKG_' || lpad(p, 4, '0'); + l_spec := null; + l_body := null; + + -- Package spec + append_line(l_spec, 'create or replace package ' || l_pkg || ' as'); + append_line(l_spec); + append_line(l_spec, ' --%suite(Generated suite ' || p || ')'); + append_line(l_spec, ' --%suitepath(generated.vol_test)'); + + if mod(p, 3) = 0 then + append_line(l_spec, ' --%displayname(Suite display name for pkg ' || p || ')'); + end if; + if mod(p, 5) = 0 then + append_line(l_spec, ' --%rollback(manual)'); + end if; + + append_line(l_spec); + append_line(l_spec, ' --%beforeall'); + append_line(l_spec, ' procedure setup_suite;'); + append_line(l_spec); + append_line(l_spec, ' --%afterall'); + append_line(l_spec, ' procedure teardown_suite;'); + append_line(l_spec); + append_line(l_spec, ' --%beforeeach'); + append_line(l_spec, ' procedure setup_test;'); + append_line(l_spec); + append_line(l_spec, ' --%aftereach'); + append_line(l_spec, ' procedure teardown_test;'); + append_line(l_spec); + + for i in 1 .. c_procs_per_pkg loop + declare + l_proc varchar2(30) := 'test_proc_' || lpad(i, 3, '0'); + begin + if mod(i - 1, 5) = 0 then + append_line(l_spec, ' --%context(context_' || ceil(i/5) || ')'); + append_line(l_spec); + end if; + + if mod(i, 4) = 0 then + append_line(l_spec, ' /* multi-line comment for ' || l_proc || ' */'); + end if; + + append_line(l_spec, ' --%test(Test ' || i || ' in pkg ' || p || ')'); + + if mod(i, 3) = 0 then + append_line(l_spec, ' --%tags(tag_' || mod(i,5) || ',smoke)'); + end if; + if mod(i, 6) = 0 then + append_line(l_spec, ' --%throws(-20001)'); + end if; + if mod(i, 8) = 0 then + append_line(l_spec, ' --%disabled(generated disabled test ' || i || ')'); + end if; + if mod(i, 5) = 0 then + append_line(l_spec, ' --%beforetest(setup_test)'); + append_line(l_spec, ' --%aftertest(teardown_test)'); + end if; + + append_line(l_spec, ' -- regular comment'); + append_line(l_spec, ' procedure ' || l_proc || ';'); + append_line(l_spec); + + if mod(i, 5) = 0 then + append_line(l_spec, ' --%endcontext'); + append_line(l_spec); + end if; + end; + end loop; + + append_line(l_spec, 'end ' || l_pkg || ';'); + + -- ----------------------------------------------------------------------- + -- Package body + -- ----------------------------------------------------------------------- + append_line(l_body, 'create or replace package body ' || l_pkg || ' as'); + append_line(l_body); + + for stub in ( + select column_value as proc_name + from table(ut_varchar2_list( + 'setup_suite','teardown_suite', + 'setup_test','teardown_test' + )) + ) loop + append_line(l_body, ' procedure ' || stub.proc_name || ' is'); + append_line(l_body, ' begin'); + append_line(l_body, ' null;'); + append_line(l_body, ' end ' || stub.proc_name || ';'); + append_line(l_body); + end loop; + + for i in 1 .. c_procs_per_pkg loop + declare + l_proc varchar2(30) := 'test_proc_' || lpad(i, 3, '0'); + begin + append_line(l_body, ' procedure ' || l_proc || ' is'); + append_line(l_body, ' begin'); + if mod(i, 4) = 0 then + append_line(l_body, ' ut.expect(''/* not a comment */'').to_equal(''/* not a comment */'');'); + elsif mod(i, 4) = 1 then + append_line(l_body, ' ut.expect(' || i || ').to_be_greater_than(0);'); + elsif mod(i, 4) = 2 then + append_line(l_body, ' ut.expect(q''[-- not a comment]'').to_equal(q''[-- not a comment]'');'); + else + append_line(l_body, ' ut.expect(''test_' || i || ''').not_to_be_null();'); + end if; + append_line(l_body, ' end ' || l_proc || ';'); + append_line(l_body); + end; + end loop; + + append_line(l_body, 'end ' || l_pkg || ';'); + + -- Execute DDL — with error capture so one bad package doesn't stop all + begin + execute immediate l_spec; + execute immediate l_body; + exception + when others then + l_errors := l_errors + 1; + dbms_output.put_line('ERROR on ' || l_pkg || ': ' || sqlerrm); + end; + + if mod(p, 100) = 0 then + dbms_output.put_line('Created ' || p || ' packages...'); + end if; + + end loop; + + dbms_output.put_line('----------------------------------------'); + dbms_output.put_line('Done. packages=' || c_packages || + ' errors=' || l_errors); + + -- quick sanity check + declare + l_count pls_integer; + begin + select count(*) into l_count + from user_objects + where object_name like 'TST_GEN_PKG_%' + and object_type = 'PACKAGE'; + dbms_output.put_line('Packages in user_objects: ' || l_count); + end; +end; +/ diff --git a/examples/between_string/run_betwnstr_test.sql b/examples/between_string/run_betwnstr_test.sql index 120645410..31edc52cf 100644 --- a/examples/between_string/run_betwnstr_test.sql +++ b/examples/between_string/run_betwnstr_test.sql @@ -1,5 +1,6 @@ @@betwnstr.sql -@@test_betwnstr.pkg +@@test_betwnstr.pks +@@test_betwnstr.pkb set serveroutput on size unlimited format truncated diff --git a/examples/between_string/run_betwnstr_test_coverage.sql b/examples/between_string/run_betwnstr_test_coverage.sql index efbbb20fe..098445cae 100644 --- a/examples/between_string/run_betwnstr_test_coverage.sql +++ b/examples/between_string/run_betwnstr_test_coverage.sql @@ -4,14 +4,15 @@ set pagesize 0 set long 200000000 set longchunksize 1000000 @@betwnstr.sql -@@test_betwnstr.pkg +@@test_betwnstr.pks +@@test_betwnstr.pkb set serveroutput on size unlimited format truncated set feedback off set termout off spool coverage.html -exec ut.run(user, ut_coverage_html_reporter(a_project_name=>'Demo of between string function tests', a_include_object_list=>ut_varchar2_list('ut3.betwnstr'))); +exec ut.run(user, ut_coverage_html_reporter(a_project_name=>'Demo of between string function tests', a_include_object_list=>ut_varchar2_list('betwnstr'))); spool off diff --git a/examples/between_string/test_betwnstr.pkg b/examples/between_string/test_betwnstr.pkb similarity index 52% rename from examples/between_string/test_betwnstr.pkg rename to examples/between_string/test_betwnstr.pkb index 84f153ecc..f872f6447 100644 --- a/examples/between_string/test_betwnstr.pkg +++ b/examples/between_string/test_betwnstr.pkb @@ -1,25 +1,3 @@ -create or replace package test_betwnstr as - - -- %suite(Between string function) - - -- %test(Returns substring from start position to end position) - procedure normal_case; - - -- %test(Returns substring when start position is zero) - procedure zero_start_position; - - -- %test(Returns string until end if end position is greater than string length) - procedure big_end_position; - - -- %test(Returns null for null input string value) - procedure null_string; - - -- %test(Demo of a disabled test) - -- %disabled - procedure disabled_test; - -end; -/ create or replace package body test_betwnstr as procedure normal_case is diff --git a/examples/between_string/test_betwnstr.pks b/examples/between_string/test_betwnstr.pks new file mode 100644 index 000000000..7b98d0005 --- /dev/null +++ b/examples/between_string/test_betwnstr.pks @@ -0,0 +1,22 @@ +create or replace package test_betwnstr as + + -- %suite(Between string function) + + -- %test(Returns substring from start position to end position) + procedure normal_case; + + -- %test(Returns substring when start position is zero) + procedure zero_start_position; + + -- %test(Returns string until end if end position is greater than string length) + procedure big_end_position; + + -- %test(Returns null for null input string value) + procedure null_string; + + -- %test(Demo of a disabled test) + -- %disabled + procedure disabled_test; + +end; +/ diff --git a/examples/custom_reporters/run_ut_custom_reporter.sql b/examples/custom_reporters/run_ut_custom_reporter.sql new file mode 100644 index 000000000..dbb142ce1 --- /dev/null +++ b/examples/custom_reporters/run_ut_custom_reporter.sql @@ -0,0 +1,16 @@ +prompt ******************************************************************************* +prompt Runnign tests with UT_CUSTOM_REPORTER on top of UT_DOCUMENTATION_REPROTER +prompt ******************************************************************************* + +set echo off +--install the example unit test packages +@demo_of_expectations/demo_equal_matcher.sql +@@ut_custom_reporter.tps +@@ut_custom_reporter.tpb + +set serveroutput on size unlimited format truncated + +exec ut.run('demo_equal_matcher', ut_custom_reporter()); + +@demo_of_expectations/drop_demo_equal_matcher.sql +drop type ut_custom_reporter; diff --git a/examples/custom_reporters/run_ut_expectations_reporter.sql b/examples/custom_reporters/run_ut_expectations_reporter.sql new file mode 100644 index 000000000..90b1ff9ff --- /dev/null +++ b/examples/custom_reporters/run_ut_expectations_reporter.sql @@ -0,0 +1,16 @@ +prompt ******************************************************************************* +prompt Runnign tests with UT_CUSTOM_REPORTER on top of UT_DOCUMENTATION_REPROTER +prompt ******************************************************************************* + +set echo off +--install the example unit test packages +@demo_of_expectations/demo_equal_matcher.sql +@@ut_expectations_reporter.tps +@@ut_expectations_reporter.tpb + +set serveroutput on size unlimited format truncated + +exec ut.run('demo_equal_matcher', ut_expectations_reporter()); + +@demo_of_expectations/drop_demo_equal_matcher.sql +drop type ut_expectations_reporter; diff --git a/examples/developer_examples/ut_custom_reporter.tpb b/examples/custom_reporters/ut_custom_reporter.tpb similarity index 100% rename from examples/developer_examples/ut_custom_reporter.tpb rename to examples/custom_reporters/ut_custom_reporter.tpb diff --git a/examples/developer_examples/ut_custom_reporter.tps b/examples/custom_reporters/ut_custom_reporter.tps similarity index 69% rename from examples/developer_examples/ut_custom_reporter.tps rename to examples/custom_reporters/ut_custom_reporter.tps index cc7de666e..0cc3d67ed 100644 --- a/examples/developer_examples/ut_custom_reporter.tps +++ b/examples/custom_reporters/ut_custom_reporter.tps @@ -4,6 +4,12 @@ create or replace type ut_custom_reporter under ut_documentation_reporter -- Member functions and procedures constructor function ut_custom_reporter(a_tab_size integer default 4) return self as result, + + /* The reporter is using base functions of parent type ( UT_DOCUMENTATION_REPORTER ) + It is altering the behavior of the base functions by change of the indentation. + So the custom reporter is same as documentation reporter except that the tab size is bigger. + Additionally, the reporter constructor accepts parameter to indicate the indentation size + */ overriding member function tab(self in ut_custom_reporter) return varchar2, overriding member procedure print_text(a_text varchar2, a_item_type varchar2 := null), overriding member procedure before_calling_suite(self in out nocopy ut_custom_reporter, a_suite ut_logical_suite), diff --git a/examples/custom_reporters/ut_expectations_reporter.tpb b/examples/custom_reporters/ut_expectations_reporter.tpb new file mode 100644 index 000000000..6ea5f1cda --- /dev/null +++ b/examples/custom_reporters/ut_expectations_reporter.tpb @@ -0,0 +1,149 @@ +create or replace type body ut_expectations_reporter is + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_expectations_reporter(a_report_all_expectations varchar2 := 'Y')return self as result is + begin + self.init($$plsql_unit); + self.lvl := 0; + self.report_all_expectations := substr(a_report_all_expectations,1,1); + self.failed_test_running_count := 0; + return; + end; + + /* The reporter procedure after_calling_test from ut_documentation_reporter is overriden here so that: + - the test name is printed + - the test staus is printed + - test duration is printed + - all expectation results from the test are printed (default) or only the failing ones + - error stack trace is printed + - dbms_output from test run is always printed + */ + overriding member procedure after_calling_test(a_test ut_test) as + l_message varchar2(4000); + + procedure print_expectation(a_expectation ut_expectation_result) is + l_lines ut_varchar2_list; + l_failed boolean := a_expectation.status > ut_utils.gc_success; + begin + if l_failed or self.report_all_expectations = 'Y' then + l_lines := a_expectation.get_result_lines(); + for i in 1 .. l_lines.count loop + if l_failed then + self.print_red_text(l_lines(i)); + else + self.print_green_text(l_lines(i)); + end if; + end loop; + self.print_cyan_text(a_expectation.caller_info); + self.print_text(' '); + end if; + end; + + procedure print_results_for_test(a_test ut_test) is + begin + self.lvl := self.lvl + 3; + self.print_red_text(ut_utils.table_to_clob( a_test.get_error_stack_traces() )); + for j in 1 .. a_test.all_expectations.count loop + print_expectation(a_test.all_expectations(j)); + end loop; + self.lvl := self.lvl - 3; + end; + begin + l_message := coalesce(a_test.description, a_test.name)||' ['||round(a_test.execution_time,3)||' sec]'; + --if test failed, then add it to the failures list, print failure with number + if a_test.result = ut_utils.gc_disabled then + self.print_yellow_text(l_message || ' (DISABLED)'); + elsif a_test.result = ut_utils.gc_success then + self.print_green_text(l_message); + elsif a_test.result > ut_utils.gc_success then + self.failed_test_running_count := self.failed_test_running_count + 1; + self.print_red_text(l_message || ' (FAILED - ' || failed_test_running_count || ')'); + end if; + + print_results_for_test(a_test); + -- reproduce the output from before/after procedures and the test + self.print_clob(a_test.get_serveroutputs); + end; + + overriding member procedure after_calling_run(a_run in ut_run) as + l_summary_text varchar2(4000); + l_warning_index pls_integer := 0; + -- make all warning indexes uniformly indented + c_warnings_lpad constant integer := length(to_char(a_run.results_count.warnings_count)); + + procedure print_item_warnings(a_item in ut_suite_item) is + l_items ut_suite_items; + begin + if a_item is of (ut_logical_suite) then + l_items := treat(a_item as ut_logical_suite).items; + for i in 1 .. l_items.count loop + print_item_warnings(l_items(i)); + end loop; + end if; + + if a_item.warnings is not null and a_item.warnings.count > 0 then + for i in 1 .. a_item.warnings.count loop + l_warning_index := l_warning_index + 1; + self.print_text(' ' || lpad(l_warning_index, c_warnings_lpad) || ') ' || a_item.path); + self.lvl := self.lvl + 3; + self.print_red_text(a_item.warnings(i)); + self.lvl := self.lvl - 3; + end loop; + self.print_text(' '); + end if; + end; + + procedure print_warnings(a_run in ut_run) is + begin + if a_run.results_count.warnings_count > 0 then + self.print_text(' '); + self.print_text('Warnings:'); + self.print_text(' '); + for i in 1 .. a_run.items.count loop + print_item_warnings(treat(a_run.items(i) as ut_suite_item)); + end loop; + end if; + end; + + begin + print_warnings(a_run); + self.print_text('Finished in ' || a_run.execution_time || ' seconds'); + + l_summary_text := + a_run.results_count.total_count || ' tests, ' + || a_run.results_count.failure_count || ' failed, ' || a_run.results_count.errored_count || ' errored, ' + || a_run.results_count.disabled_count ||' disabled, ' || a_run.results_count.warnings_count || ' warning(s)'; + if a_run.results_count.failure_count + a_run.results_count.errored_count + a_run.results_count.warnings_count > 0 then + self.print_red_text(l_summary_text); + else + self.print_green_text(l_summary_text); + end if; + if a_run.random_test_order_seed is not null then + self.print_text('Tests were executed with random order seed '''||a_run.random_test_order_seed||'''.'); + end if; + self.print_text(' '); + (self as ut_reporter_base).after_calling_run(a_run); + end; + + overriding member function get_description return varchar2 as + begin + return 'A custom reporter for pretty-printing all expectation results directly under the test'; + end; + +end; +/ diff --git a/source/reporters/ut_coveralls_reporter.tps b/examples/custom_reporters/ut_expectations_reporter.tps similarity index 51% rename from source/reporters/ut_coveralls_reporter.tps rename to examples/custom_reporters/ut_expectations_reporter.tps index 53e86338e..9095051cd 100644 --- a/source/reporters/ut_coveralls_reporter.tps +++ b/examples/custom_reporters/ut_expectations_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_coveralls_reporter under ut_coverage_reporter_base( +create or replace type ut_expectations_reporter under ut_documentation_reporter( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,17 +15,16 @@ create or replace type ut_coveralls_reporter under ut_coverage_reporter_base( See the License for the specific language governing permissions and limitations under the License. */ + report_all_expectations varchar2(1), - /** - * Builds a coverage XML report that follows rules described in - * https://docs.sonarqube.org/display/SONAR/Generic+Test+Data - */ - constructor function ut_coveralls_reporter( - self in out nocopy ut_coveralls_reporter - ) return self as result, - overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run), + constructor function ut_expectations_reporter(a_report_all_expectations varchar2 := 'Y') return self as result, + + overriding member procedure after_calling_test(a_test ut_test), + overriding member procedure after_calling_run(a_run in ut_run), overriding member function get_description return varchar2 + ) +not final / diff --git a/examples/demo_of_expectations/demo_equal_matcher.sql b/examples/demo_of_expectations/demo_equal_matcher.sql index 0836eeb52..f7b20581f 100644 --- a/examples/demo_of_expectations/demo_equal_matcher.sql +++ b/examples/demo_of_expectations/demo_equal_matcher.sql @@ -18,7 +18,7 @@ create or replace package demo_equal_matcher as -- %suitepath(org.utplsql.v3.demo.matchers) -- TODO this should go into context(compare_objects, Comparing objects) - -- %context(compare_objects, Comparing objects) + -- %context(Comparing objects) -- %test -- %displayname(Gives success when comparing identical objects containing identical data) @@ -48,7 +48,7 @@ create or replace package demo_equal_matcher as -- %displayname(Gives failure when comparing different objects containing identical data) procedure object_compare_different_type; - -- %end_context + -- %endcontext end; / diff --git a/examples/demo_of_expectations/drop_demo_equal_matcher.sql b/examples/demo_of_expectations/drop_demo_equal_matcher.sql new file mode 100644 index 000000000..8ec8cfa83 --- /dev/null +++ b/examples/demo_of_expectations/drop_demo_equal_matcher.sql @@ -0,0 +1,5 @@ +drop package demo_equal_matcher; +drop type demo_departments; +drop type demo_department_new; +drop type demo_department; + diff --git a/examples/demo_of_expectations/run.sql b/examples/demo_of_expectations/run.sql index a5f93a05f..42a43400c 100644 --- a/examples/demo_of_expectations/run.sql +++ b/examples/demo_of_expectations/run.sql @@ -4,8 +4,5 @@ set serveroutput on size unlimited format truncated exec ut.run(user||'.demo_equal_matcher'); -drop package demo_equal_matcher; -drop type demo_departments; -drop type demo_department_new; -drop type demo_department; +@@drop_demo_equal_matcher.sql diff --git a/examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql b/examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql index 468d176ed..e713fa02d 100644 --- a/examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql +++ b/examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql @@ -20,6 +20,7 @@ begin ut_event_manager.initialize(); ut_event_manager.add_listener(l_doc_reporter); ut_event_manager.add_listener(l_tc_reporter); + ut_event_manager.trigger_event(ut_event_manager.gc_initialize, l_run); l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1); l_suite.description := 'Test Suite Name'; diff --git a/examples/developer_examples/RunExampleTestSuiteWithCustomReporter.sql b/examples/developer_examples/RunExampleTestSuiteWithCustomReporter.sql deleted file mode 100644 index 285cbf9a1..000000000 --- a/examples/developer_examples/RunExampleTestSuiteWithCustomReporter.sql +++ /dev/null @@ -1,56 +0,0 @@ ---Shows how to create a test suite with the default reporter which is dbms_output ---No tables are used for this. ---Suite Management packages are when developed will make this easier. ---Clear Screen ---http://stackoverflow.com/questions/2584492/how-to-prevent-dbms-output-put-line-from-trimming-leading-whitespace -Set Serveroutput On Size Unlimited format truncated -set echo off ---install the example unit test packages -@@ut_exampletest.pks -@@ut_exampletest.pkb -@@ut_exampletest2.pks -@@ut_exampletest2.pkb -@@ut_custom_reporter.tps -@@ut_custom_reporter.tpb - -declare - l_suite ut_logical_suite; - l_test ut_test; - l_reporter ut_output_reporter_base; - l_run ut_run; -begin - ut_event_manager.initialize(); - -- Install ut_custom_reporter first from example folder - - l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1); - - l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest',a_line_no=>3); - l_test.description := 'Example test1'; - l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test)); - l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := l_test; - - l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest',a_line_no=>6); - l_test.description := 'Another example test'; - l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','SETUP',ut_utils.gc_before_test)); - l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','TEARDOWN',ut_utils.gc_after_test)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := l_test; - - -- provide a reporter to process results tabbing each hierarcy level by tab_size - l_reporter := ut_custom_reporter(a_tab_size => 2); - ut_event_manager.add_listener(l_reporter); - l_run := ut_run(ut_suite_items(l_suite)); - l_run.do_execute(); - ut_event_manager.trigger_event(ut_event_manager.gc_finalize, l_run); - l_reporter.lines_to_dbms_output(0,0); -end; -/ - - ---FIXME this drop is causing issues when executing script several times within single session -drop type ut_custom_reporter; -drop package ut_exampletest; -drop package ut_exampletest2; -exec dbms_session.reset_package; diff --git a/mkdocs.yml b/mkdocs.yml index f9a2687a8..08e75ac97 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,17 +1,136 @@ # Format documented here # http://www.mkdocs.org/user-guide/configuration/ +# https://squidfunk.github.io/mkdocs-material/getting-started/ +# See this document for list of plugins to disable for offline (local) documentation +# https://squidfunk.github.io/mkdocs-material/setup/building-for-offline-usage/ +edit_uri: "" +site_url: https://www.utplsql.org/ site_name: utPLSQL -site_description: utPLSQL Ultimate Unit Testing Framework for Oracle PL/SQL -copyright: Copyright © 2016 - 2018 utPLSQL Team +site_description: utPLSQL Ultimate Testing Framework for Oracle PL/SQL +copyright: > + Copyright © 2016 - 2026 utPLSQL Project. + Stewarded by utPLSQL Development Labs Ltd. + ♡ SponsorutPLSQL + Change cookie settings repo_url: https://github.com/utPLSQL/utPLSQL -theme: mkdocs +extra_css: + - stylesheets/extra.css +theme: + name: material + custom_dir: docs/overrides + palette: + # Palette toggle for light mode + - media: "(prefers-color-scheme: light)" + scheme: default + toggle: + icon: material/lightbulb-outline + name: Switch to dark mode + # Palette toggle for dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + toggle: + icon: material/lightbulb + name: Switch to light mode + logo: assets/icon-transparent.png + favicon: assets/favicon.png + features: + - navigation.instant # disable for offline docs +# - navigation.indexes + - navigation.tabs + - navigation.tracking + - navigation.top + - toc.follow + - toc.integrate + - search.suggest + - search.highlight + - content.code.copy + - content.code.annotate + - content.code.select + +extra: +# homepage: https://www.utPLSQL.org/ + # sets scope of cookies to use a common path (root) + scope: "/" + analytics: + provider: google + property: G-WMFVR98J0Q + feedback: + title: Was this page helpful? + ratings: + - icon: material/emoticon-happy-outline + name: This page was helpful + data: 1 + note: >- + Thanks for your feedback! + - icon: material/emoticon-sad-outline + name: This page could be improved + data: 0 + note: >- + Thanks for your feedback! Help us improve this page by + using our GitHub Discussions. + consent: + title: Cookie consent + description: >- + We use cookies to recognize your repeated visits and preferences, as well + as to measure the effectiveness of our documentation and whether users + find what they're searching for. With your consent, you're helping us to + make our documentation better. + # the cookie: utplsql-consent allows for shred cookie across all documentation versions and the global site + cookie: utplsql-consent + social: + - icon: fontawesome/brands/x-twitter + link: https://x.com/utPLSQL + name: utPLSQL on X + - icon: fontawesome/brands/linkedin + link: https://www.linkedin.com/company/utplsql/ + name: utPLSQL on LinkedIn + - icon: fontawesome/brands/bluesky + link: https://bsky.app/profile/utplsql.org + name: utPLSQL on Bluesky + - icon: fontawesome/regular/comment + link: https://github.com/utPLSQL/utPLSQL/discussions + - icon: fontawesome/brands/github + link: https://github.com/utPLSQL + - icon: fontawesome/solid/envelope + link: mailto:info@utPLSQL.org + version: # disable for offline docs + provider: mike # disable for offline docs +markdown_extensions: + - admonition + - pymdownx.details + - pymdownx.highlight: + anchor_linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite + - pymdownx.snippets + - pymdownx.superfences + - pymdownx.caret + - pymdownx.mark + - pymdownx.tilde + - toc: + permalink: true use_directory_urls: false strict: true +plugins: + - search + - git-committers: + repository: utPLSQL/utPLSQL + branch: develop + token: !ENV ["API_TOKEN_GITHUB"] + exclude_committers: + - github-actions[bot] + - web-flow + - mike + - git-revision-date-localized: # disable for offline docs + enable_creation_date: true # disable for offline docs + type: datetime # disable for offline docs + nav: - - Home: index.md - User Guide: + - index.md - Installation: userguide/install.md - Getting Started: userguide/getting-started.md - Annotations: userguide/annotations.md @@ -19,14 +138,9 @@ nav: - Advanced data comparison: userguide/advanced_data_comparison.md - Running unit tests: userguide/running-unit-tests.md - Querying for test suites: userguide/querying_suites.md - - Testing best pracitces: userguide/best-practices.md + - Testing best practices: userguide/best-practices.md - Upgrade utPLSQL: userguide/upgrade.md - Reporting: - Using reporters: userguide/reporters.md - - Reporting errors: userguide/exception-reporting.md - Code coverage: userguide/coverage.md - - About: - - Project Details: about/project-details.md - - License: about/license.md - - Support: about/support.md - - Authors: about/authors.md + - Error handling and reporting: userguide/exception-reporting.md diff --git a/mkdocs_offline.yml b/mkdocs_offline.yml new file mode 100644 index 000000000..8c0ab8fa5 --- /dev/null +++ b/mkdocs_offline.yml @@ -0,0 +1,106 @@ +# Format documented here +# http://www.mkdocs.org/user-guide/configuration/ +# https://squidfunk.github.io/mkdocs-material/getting-started/ +# See this document for list of plugins to disable for offline (local) documentation +# https://squidfunk.github.io/mkdocs-material/setup/building-for-offline-usage/ + +edit_uri: "" +site_url: https://www.utplsql.org/ +site_name: utPLSQL-framework +site_description: utPLSQL Ultimate Testing Framework for Oracle PL/SQL & SQL +copyright: Copyright © 2016 - 2026 utPLSQL Project. utPLSQL is stewarded by utPLSQL Development Labs Ltd. +#repo_url: https://github.com/utPLSQL/utPLSQL # disable for offline docs +extra_css: + - stylesheets/extra.css +theme: + name: material + palette: + # Palette toggle for light mode + - media: "(prefers-color-scheme: light)" + scheme: default + toggle: + icon: material/lightbulb-outline + name: Switch to dark mode + # Palette toggle for dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + toggle: + icon: material/lightbulb + name: Switch to light mode + logo: assets/icon-transparent.png + favicon: assets/favicon.png + features: +# - navigation.instant # disable for offline docs +# - navigation.indexes + - navigation.tabs + - navigation.tracking + - toc.follow + - toc.integrate + - search.suggest + - search.highlight +extra: +# homepage: https://www.utPLSQL.org/ + social: + - icon: fontawesome/brands/x-twitter + link: https://x.com/utPLSQL + name: utPLSQL on X + - icon: fontawesome/brands/linkedin + link: https://www.linkedin.com/company/utplsql/ + name: utPLSQL on LinkedIn + - icon: fontawesome/brands/bluesky + link: https://bsky.app/profile/utplsql.org + name: utPLSQL on Bluesky + - icon: fontawesome/regular/comment + link: https://github.com/utPLSQL/utPLSQL/discussions + - icon: fontawesome/brands/github + link: https://github.com/utPLSQL + - icon: fontawesome/solid/envelope + link: mailto:info@utPLSQL.org + consent: + title: Cookie consent + description: >- + We use cookies to recognize your repeated visits and preferences, as well + as to measure the effectiveness of our documentation and whether users + find what they're searching for. With your consent, you're helping us to + make our documentation better. +# version: # disable for offline docs +# provider: mike # disable for offline docs +markdown_extensions: + - admonition + - pymdownx.details + - pymdownx.superfences + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.inlinehilite + - pymdownx.snippets + - pymdownx.caret + - pymdownx.mark + - pymdownx.tilde + - toc: + permalink: true +use_directory_urls: false +strict: true + +plugins: +# - search # disable for offline docs + - mike +# - git-revision-date-localized: # disable for offline docs +# enable_creation_date: true # disable for offline docs +# type: datetime # disable for offline docs + +nav: + - User Guide: + - index.md + - Installation: userguide/install.md + - Getting Started: userguide/getting-started.md + - Annotations: userguide/annotations.md + - Expectations: userguide/expectations.md + - Advanced data comparison: userguide/advanced_data_comparison.md + - Running unit tests: userguide/running-unit-tests.md + - Querying for test suites: userguide/querying_suites.md + - Testing best practices: userguide/best-practices.md + - Upgrade utPLSQL: userguide/upgrade.md + - Reporting: + - Using reporters: userguide/reporters.md + - Code coverage: userguide/coverage.md + - Error handling and reporting: userguide/exception-reporting.md diff --git a/readme.md b/readme.md index 315124db6..f0843b511 100644 --- a/readme.md +++ b/readme.md @@ -1,102 +1,50 @@ ![utPLSQL v3 | Testing Framework for PL/SQL](docs/images/utPLSQL-testing-framework-transparent_120.png) ----------- - [![latest-release](https://img.shields.io/github/release/utPLSQL/utPLSQL.svg)](https://github.com/utPLSQL/utPLSQL/releases) [![license](https://img.shields.io/github/license/utPLSQL/utPLSQL.svg)](https://www.apache.org/licenses/LICENSE-2.0) -[![chat](http://img.shields.io/badge/slack-team--chat-blue.svg)](http://utplsql-slack-invite.herokuapp.com/) -[![twitter](https://img.shields.io/twitter/follow/utPLSQL.svg?style=social&label=Follow)](https://twitter.com/utPLSQL) - -[![build](https://img.shields.io/travis/utPLSQL/utPLSQL/master.svg?label=master%20branch)](https://travis-ci.org/utPLSQL/utPLSQL) -[![build](https://img.shields.io/travis/utPLSQL/utPLSQL/develop.svg?label=develop%20branch)](https://travis-ci.org/utPLSQL/utPLSQL) -[![sonar](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL&metric=sqale_rating)](https://sonarcloud.io/dashboard/index?id=utPLSQL) -[![Coveralls coverage](https://coveralls.io/repos/github/utPLSQL/utPLSQL/badge.svg?branch=develop)](https://coveralls.io/github/utPLSQL/utPLSQL?branch=develop) - ----------- -utPLSQL version 3 is a complete rewrite of utPLSQL v2 from scratch. -Version 2 still supports older versions of Oracle that are no longer available. -The community that had developed on GitHub decided that a new internal architecture was needed, from that version 3 was born. - -# Introduction -utPLSQL is a Unit Testing framework for Oracle PL/SQL and SQL. -The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](http://junit.org/junit4/) and [RSpec](http://rspec.info/) - - -# Key features - -- multiple ways to compare data with [matchers](docs/userguide/expectations.md) -- native comparison of complex types (objects/collections/cursors) -- in-depth and consistent reporting of failures and errors for tests -- tests identified and configured by [annotations](docs/userguide/annotations.md) -- hierarchies of test suites configured with annotations -- automatic (configurable) transaction control -- Build-in [coverage](docs/userguide/coverage.md) reporting -- Integration with SonarQube, Coveralls, Jenkins and Teamcity with [reporters](docs/userguide/reporters.md) -- plugin architecture for reporters and matchers -- flexible and simple test invocation -- multi-reporting from test-run from [command line](https://github.com/utPLSQL/utPLSQL-cli) - -Requirements: - - Version of Oracle under [extended support](http://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf) (Currently 11.2 and above) - -# Download - -Published releases are available for download on the [utPLSQL GitHub Releases Page.](https://github.com/utPLSQL/utPLSQL/releases) +[![GitHub Discussions](https://img.shields.io/github/discussions/utPLSQL/utPLSQL)](https://github.com/utPLSQL/utPLSQL/discussions) +[![X](https://img.shields.io/badge/X-utPLSQL-000000?logo=x)](https://x.com/utPLSQL) +[![Bluesky](https://img.shields.io/badge/Bluesky-utplsql.org-0285FF?logo=bluesky&logoColor=white)](https://bsky.app/profile/utplsql.org) +[![LinkedIn](https://img.shields.io/badge/in-utPLSQL-0A66C2)](https://www.linkedin.com/company/utplsql/) +[![Sponsor](https://img.shields.io/badge/Sponsor-utPLSQL-ea4aaa?logo=githubsponsors)](https://www.utplsql.org/sponsorship.html) +[![build](https://github.com/utPLSQL/utPLSQL/actions/workflows/build.yml/badge.svg)](https://github.com/utPLSQL/utPLSQL/actions/workflows/build.yml) +[![QualityGate](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL_utPLSQL&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=utPLSQL_utPLSQL) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL_utPLSQL&metric=coverage)](https://sonarcloud.io/summary/new_code?id=utPLSQL_utPLSQL) -# Documentation +utPLSQL is a unit testing framework for Oracle PL/SQL and SQL, following industry standards and best practices of modern testing frameworks like [JUnit](https://junit.org/) and [RSpec](https://rspec.info/). -Full documentation of the project is automatically published on [utPLSQL github pages](https://utplsql.github.io/utPLSQL/) - -[Cheat-sheets](https://www.cheatography.com/jgebal/lists/utplsql-v3-cheat-sheets/) - -# Installation - -To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql`. -This will create a new user `UT3`, grant all required privileges to that user and create PUBLIC synonyms needed. - -For detailed instructions on other install options see the [Install Guide](docs/userguide/install.md) - - -# Running tests - -To execute using development IDE (TOAD/SQLDeveloper/PLSQLDeveloper/other) use one of following commands. -```sql -begin - ut.run(); -end; -/ -``` -```sql -exec ut.run(); -``` -```sql -select * from table(ut.run()); -``` +## Key Features -The above commands will run all the suites in the current schema and provide report to dbms_output or as a select statement. +- Multiple ways to compare data with [matchers](docs/userguide/expectations.md) +- Native comparison of complex types (objects, collections, cursors) +- In-depth and consistent reporting of failures and errors +- Tests identified and configured by [annotations](docs/userguide/annotations.md) +- Hierarchies of test suites configured with annotations +- Automatic (configurable) transaction control +- Built-in [coverage](docs/userguide/coverage.md) reporting +- Integration with SonarQube, Jenkins and TeamCity via [reporters](docs/userguide/reporters.md) +- Plugin architecture for reporters and matchers +- Flexible and simple test invocation +- Multi-format reporting from the [command line client](https://github.com/utPLSQL/utPLSQL-cli) -# Command line client +## Requirements -You can use the utPLSQL command line client [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) to run tests without the need for Oracle Client or any IDE like SQLDeveloper/TOAD etc. +- Oracle Database 19c with Release Update 19.20 or later, or any newer version (we are testing on 19.20, 21 XE and 23 free ) -Amongst many benefits it provides ability to: -* see the progress of test execution for long-running tests - real-time reporting -* use many reporting formats simultaneously and save reports to files (publish) -* map your project source files and test files into database objects +## Installation -Just download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest), download Oracle jdbc driver you are good to go. -See [project readme](https://github.com/utPLSQL/utPLSQL-cli/blob/develop/README.md) for details. +Published releases are available for download on the [utPLSQL GitHub Releases page](https://github.com/utPLSQL/utPLSQL/releases). +To install utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql`. +This creates a new user `UT3`, grants all required privileges, and creates PUBLIC synonyms. -# Example unit test packages +For all install options see the [Install Guide](docs/userguide/install.md). -**For examples of using Continuous Integration Server & SonarCloud with utPLSQL see the [utPLSQL demo project](https://github.com/utPLSQL/utPLSQL-demo-project/).** +## Quick Start +**1. Write a test package** -The below test package is a fully-functional Unit Test package for testing a [`betwnstr` function](examples/between_string/betwnstr.sql). -The package specification is [annotated](docs/userguide/annotations.md) with special comments. -The annotations define that a package is a unit test suite, they also allow defining a description for the suite as well as the test itself. -The package body consists of procedures containing unit test code. To validate [an expectation](docs/userguide/expectations.md) in test, use `ut.expect( actual_data ).to_( ... )` syntax. +Annotate a package specification to define a test suite and its tests, then implement each test procedure in the package body: ```sql create or replace package test_between_string as @@ -106,12 +54,6 @@ create or replace package test_between_string as -- %test(Returns substring from start position to end position) procedure normal_case; - -- %test(Returns substring when start position is zero) - procedure zero_start_position; - - -- %test(Returns string until end if end position is greater than string length) - procedure big_end_position; - -- %test(Returns null for null input string value) procedure null_string; end; @@ -124,16 +66,6 @@ create or replace package body test_between_string as ut.expect( betwnstr( '1234567', 2, 5 ) ).to_( equal('2345') ); end; - procedure zero_start_position is - begin - ut.expect( betwnstr( '1234567', 0, 5 ) ).to_( equal('12345') ); - end; - - procedure big_end_position is - begin - ut.expect( betwnstr( '1234567', 0, 500 ) ).to_( equal('1234567') ); - end; - procedure null_string is begin ut.expect( betwnstr( null, 2, 5 ) ).to_( be_null ); @@ -143,109 +75,86 @@ end; / ``` -Outputs from running the above tests +**2. Run your tests** + +```sql +exec ut.run(); +``` + +**3. See the results** + ``` Between string function Returns substring from start position to end position - Returns substring when start position is zero - Returns string until end if end position is greater than string length Returns null for null input string value Finished in .036027 seconds -4 tests, 0 failures +2 tests, 0 failures ``` +For complete working examples see [examples/](examples/). + +## Running Tests + +From any Oracle-compatible IDE (SQL Developer, TOAD, PL/SQL Developer): + +```sql +begin + ut.run(); +end; +/ +``` +```sql +exec ut.run(); +``` +```sql +select * from table(ut.run()); +``` + +These commands run all suites in the current schema and report test results to `DBMS_OUTPUT` or as a result set. + +## Command Line Client + +[utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) lets you run tests without an Oracle Client or IDE. It provides: + +- Real-time test reporting +- Simultaneous output of multiple report formats into different files +- Source files and test files mapping for coverage reports + +Download the [latest release](https://github.com/utPLSQL/utPLSQL-cli/releases/latest) and see the [CLI readme](https://github.com/utPLSQL/utPLSQL-cli/blob/develop/README.md) for details. + +## Documentation + +Full documentation is published at [https://www.utplsql.org/utPLSQL/](https://www.utplsql.org/utPLSQL/). + +[Cheat-sheets](https://www.cheatography.com/jgebal/lists/utplsql-v3-cheat-sheets/) are available for quick reference. + +See the [Changelog](CHANGELOG.md) for the full version history. + +Migrating from legacy utPLSQL v2? See the [version 2 to version 3 comparison](docs/compare_version2_to_3.md). + +## Contributing + +We welcome contributions of all kinds. Please read the [contributing guide](CONTRIBUTING.md) and the [code of conduct](https://github.com/utPLSQL/utPLSQL?tab=coc-ov-file) before getting started. + +[GitHub Discussions](https://github.com/utPLSQL/utPLSQL/discussions) is the place to ask questions and connect with the team. + +The list of **authors** and **significant contributors** is available on the [About](https://www.utplsql.org/about.html) page. For a full list of contributors, see [contributors](https://github.com/utPLSQL/utPLSQL/graphs/contributors?all=1) on GitHub. + +## Sponsorship + +utPLSQL is free and open source (Apache 2.0). Sponsorship funds development of new features and tools, maintaining compatibility with new Oracle versions and platforms, documentation. +See [Sponsorship](https://www.utplsql.org/sponsorship.html) for organization tiers, commercial support and individual sponsorship. All current and past sponsors are listed in [SPONSORS.md](SPONSORS.md). + + + + +## License + +utPLSQL is free and open source, licensed under the [Apache 2.0 license](LICENSE). + +## Stewardship -# Contributing to the project - -We welcome new developers to join our community and contribute to the utPLSQL project. -If you are interested in helping please read our [guide to contributing](CONTRIBUTING.md) -The best place to start is to read the documentation and get familiar with the existing code base. -A [slack chat](https://utplsql.slack.com/) is the place to go if you want to talk with team members. -To sign up to the chat use [this link](http://utplsql-slack-invite.herokuapp.com/) - - ----------- -[__Authors__](docs/about/authors.md) - ----------- -__Version 2 to Version 3 Comparison__ - -If you have a great feature in mind, that you would like to see in utPLSQL v3 please create an [issue on GitHub](https://github.com/utPLSQL/utPLSQL/issues) or discuss it with us in the [Slack chat rooms](http://utplsql-slack-invite.herokuapp.com/). - - -| Feature | Version 2 | Version 3 | -| -------------------------------------- | ---------------------- | ---------------------- | -| Easy to install | Yes | Yes | -| Documentation | Yes | Yes | -| License | GPL v2 | Apache 2.0 | -| **Tests Creation** | | | -| Declarative test configuration | No | Yes - Annotations1| -| Tests as Packages | Yes | Yes | -| Multiple Tests in a single Package | Yes | Yes | -| Optional Setup/Teardown | No | Yes | -| Different Setup/Teardown
For Each Test in a Single Package| No | Yes - Annotations1 | -| Suite Definition Storage | Tables | Package - Annotations1 | -| Multiple Suites | Yes | Yes | -| Suites can contain Suites | No | Yes | -| Automatic Test detection | No | Yes - Annotations1| -| Unconstrained naming of Test packages | No - prefixes | Yes - name not relevant| -| Require Prefix on Test procedures | No - prefixes | Yes - name not relevant| -| Auto Compilation of Tests | Yes | No (Let us know if you use this) | -| Assertion Library | 30 assertions2 | 26 matchers (13 + 13 negated) | -| Extendable assertions | No | Yes - custom matchers | -| PLSQL Record Assertions | generated code through **utRecEq** Package | [possible on Oracle 12c+](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1) using [cursor matchers](docs/userguide/expectations.md#comparing-cursors)| -| Test Skeleton Generation | Yes | No (Let us know if you use this) | -| **Test Execution3** | | | -| Single Test Package Execution | Yes | Yes | -| Single Test Procedure Execution | No | Yes | -| Test Suite Execution | Yes | Yes | -| Subset of Suite Execution | No | Yes | -| Multiple Suite Execution | No | Yes | -| Organizing Suites into hierarchies | No | Yes | -| **Code Coverage Reporting** | No | Yes | -| Html Coverage Report | No | Yes | -| Sonar XML Coverage Report | No | Yes | -| Coveralls Json Coverage Report | No | Yes | -| Framework Transaction Control | No | Yes - Annotations1 | -| **Test Output** | | | -| Real-time test execution progress reporting | No | Yes | -| Multiple Output Reporters can be used during test execution | No| Yes | -| DBMS_OUTPUT | Yes | Yes (clean formatting) | -| File | Yes (to db server only)| Yes (on client side) | -| Stored in Table | Yes | No (can be added as custom reporter) | -| XUnit format support | No | Yes | -| HTML Format | Yes | No | -| Custom Output reporter | Yes-needs configuration| Yes - no config needed | - -1 Annotations are specially formatted comments in your package specification. This enables *declarative* test configuration that is coupled with the source code. See Documentation for more details. - -2 **utAssert2** package - Contains 59 Assertions - 2 Not implemented = 57, 28 are duplicated only change on outcome_in parameter 57-28 = 29, **utPipe** package - Contains 1 Assertion 29 + 1 = 30 - -3 Test execution comparison is in a single call so the results are combined. We know it was always possible to group in any way with multiple calls. But that may not be desired under a CI system where you want a single JUnit XML Output. - - ----------- -__Project Directories__ - -* .travis - contains files needed for travis-ci integration -* client_source - Sources to be used on the client-side. Developer workstation or CI platform to run the tests. -* development - Set of useful scripts and utilities for development and debugging of utPLSQL -* docs - Documentation of the project -* examples - Example source code and unit tests -* source - The installation code for utPLSQL -* tests - Tests for utPLSQL framework - ------------ -# Supporters - -The utPLSQL project is community-driven and is not commercially motivated. Nonetheless, donations and other contributions are always welcome, and are detailed below. - - - - - - - - -
supported_by_redgateutPLSQL has been supported by Redgate in the form of sponsored stickers and t-shirts. Thank you for helping us spreading the word!
+utPLSQL is stewarded by utPLSQL Development Labs Ltd, which holds the utPLSQL name, branding and project assets, and manages sponsorships and funded development. +Contributors retain copyright of their contributions, which are licensed under the Apache 2.0 license. +See the [announcement](https://www.utplsql.org/announcements/incorporation-of-utplsql-development-labs-ltd.html) for details. diff --git a/sonar-project.properties b/sonar-project.properties index c627c45e0..0a835a2f3 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,8 +1,9 @@ # must be unique in a given SonarQube instance -sonar.projectKey=utPLSQL +sonar.organization=utplsql +sonar.projectKey=utPLSQL_utPLSQL # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=utPLSQL -sonar.projectVersion=v3.1.8-develop +sonar.projectVersion=v3.2.4-develop # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # Since SonarQube 4.2, this property is optional if sonar.modules is set. @@ -14,7 +15,7 @@ sonar.coverage.exclusions=**/*.sql,**/*.pks sonar.tests=./test sonar.testExecutionReportPaths=./test_results.xml sonar.links.issue=https://github.com/utPLSQL/utPLSQL/issues -sonar.links.ci=https://travis-ci.org/utPLSQL/utPLSQL +sonar.links.ci=https://github.com/utPLSQL/utPLSQL/actions sonar.links.homepage=https://github.com/utPLSQL/utPLSQL sonar.projectDescription=PL/SQL Unit Testing Framework sonar.plsql.file.suffixes=sql,tab,pkb,tpb @@ -28,10 +29,9 @@ sonar.pullrequest.github.endpoint=https://api.github.com/ sonar.pullrequest.github.repository=utPLSQL/utPLSQL sonar.plsql.jdbc.driver.class=oracle.jdbc.OracleDriver -sonar.plsql.jdbc.user=UT3 +sonar.plsql.jdbc.user=UT3_DEVELOP sonar.plsql.jdbc.password=ut3 -sonar.plsql.defaultSchema=UT3 - +sonar.plsql.defaultSchema=UT3_DEVELOP # Encoding of the source code. Default is default system encoding diff --git a/source/api/be_between.syn b/source/api/be_between.syn index c0972595d..233dd65bf 100644 --- a/source/api/be_between.syn +++ b/source/api/be_between.syn @@ -1 +1 @@ -create synonym be_between for ut_be_between; +create noneditionable synonym be_between for ut_be_between; diff --git a/source/api/be_empty.syn b/source/api/be_empty.syn index a8e28de6e..f63366fa3 100644 --- a/source/api/be_empty.syn +++ b/source/api/be_empty.syn @@ -1 +1 @@ -create synonym be_empty for ut_be_empty; +create noneditionable synonym be_empty for ut_be_empty; diff --git a/source/api/be_false.syn b/source/api/be_false.syn index c2665bbcb..cdf497235 100644 --- a/source/api/be_false.syn +++ b/source/api/be_false.syn @@ -1 +1 @@ -create synonym be_false for ut_be_false; +create noneditionable synonym be_false for ut_be_false; diff --git a/source/api/be_greater_or_equal.syn b/source/api/be_greater_or_equal.syn index 386fe7f32..67616dc1d 100644 --- a/source/api/be_greater_or_equal.syn +++ b/source/api/be_greater_or_equal.syn @@ -1 +1 @@ -create synonym be_greater_or_equal for ut_be_greater_or_equal; +create noneditionable synonym be_greater_or_equal for ut_be_greater_or_equal; diff --git a/source/api/be_greater_than.syn b/source/api/be_greater_than.syn index 6f97b7d22..c180f3d43 100644 --- a/source/api/be_greater_than.syn +++ b/source/api/be_greater_than.syn @@ -1 +1 @@ -create synonym be_greater_than for ut_be_greater_than; +create noneditionable synonym be_greater_than for ut_be_greater_than; diff --git a/source/api/be_less_or_equal.syn b/source/api/be_less_or_equal.syn index b2f836144..0069f52ba 100644 --- a/source/api/be_less_or_equal.syn +++ b/source/api/be_less_or_equal.syn @@ -1 +1 @@ -create synonym be_less_or_equal for ut_be_less_or_equal; +create noneditionable synonym be_less_or_equal for ut_be_less_or_equal; diff --git a/source/api/be_less_than.syn b/source/api/be_less_than.syn index fbef3b4c3..5d2766d05 100644 --- a/source/api/be_less_than.syn +++ b/source/api/be_less_than.syn @@ -1 +1 @@ -create synonym be_less_than for ut_be_less_than; +create noneditionable synonym be_less_than for ut_be_less_than; diff --git a/source/api/be_like.syn b/source/api/be_like.syn index a8be1de71..6f62f21a0 100644 --- a/source/api/be_like.syn +++ b/source/api/be_like.syn @@ -1 +1 @@ -create synonym be_like for ut_be_like; +create noneditionable synonym be_like for ut_be_like; diff --git a/source/api/be_not_null.syn b/source/api/be_not_null.syn index d6458683a..a9e02b94d 100644 --- a/source/api/be_not_null.syn +++ b/source/api/be_not_null.syn @@ -1 +1 @@ -create synonym be_not_null for ut_be_not_null; +create noneditionable synonym be_not_null for ut_be_not_null; diff --git a/source/api/be_null.syn b/source/api/be_null.syn index 42f6516c3..4fe3fb9dd 100644 --- a/source/api/be_null.syn +++ b/source/api/be_null.syn @@ -1 +1 @@ -create synonym be_null for ut_be_null; +create noneditionable synonym be_null for ut_be_null; diff --git a/source/api/be_true.syn b/source/api/be_true.syn index bf7392a62..1aa348c7e 100644 --- a/source/api/be_true.syn +++ b/source/api/be_true.syn @@ -1 +1 @@ -create synonym be_true for ut_be_true; +create noneditionable synonym be_true for ut_be_true; diff --git a/source/api/be_within.syn b/source/api/be_within.syn new file mode 100644 index 000000000..4f4f77606 --- /dev/null +++ b/source/api/be_within.syn @@ -0,0 +1 @@ +create noneditionable synonym be_within for ut_be_within; diff --git a/source/api/be_within_pct.syn b/source/api/be_within_pct.syn new file mode 100644 index 000000000..b9fc1cd53 --- /dev/null +++ b/source/api/be_within_pct.syn @@ -0,0 +1 @@ +create noneditionable synonym be_within_pct for ut_be_within_pct; diff --git a/source/api/contain.syn b/source/api/contain.syn index 5bce7d1d2..5b4158635 100644 --- a/source/api/contain.syn +++ b/source/api/contain.syn @@ -1 +1 @@ -create synonym contain for ut_contain; +create noneditionable synonym contain for ut_contain; diff --git a/source/api/equal.syn b/source/api/equal.syn index 71ba58b53..0d81fcf6f 100644 --- a/source/api/equal.syn +++ b/source/api/equal.syn @@ -1 +1 @@ -create synonym equal for ut_equal; +create noneditionable synonym equal for ut_equal; diff --git a/source/api/have_count.syn b/source/api/have_count.syn index a406d47ec..9cbf8ebf2 100644 --- a/source/api/have_count.syn +++ b/source/api/have_count.syn @@ -1 +1 @@ -create synonym have_count for ut_have_count; +create noneditionable synonym have_count for ut_have_count; diff --git a/source/api/match.syn b/source/api/match.syn index ffbda35b1..13e8cc97d 100644 --- a/source/api/match.syn +++ b/source/api/match.syn @@ -1 +1 @@ -create synonym match for ut_match; +create noneditionable synonym match for ut_match; diff --git a/source/api/ut.pkb b/source/api/ut.pkb index 3b94a2bf7..4515900d7 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -1,11 +1,11 @@ -create or replace package body ut is +create or replace noneditionable package body ut is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -98,6 +98,11 @@ create or replace package body ut is return ut_expectation_json(ut_data_value_json(a_actual), a_message); end; + function expect(a_actual in json , a_message varchar2 := null) return ut_expectation_json is + begin + return ut_expectation_json(ut_data_value_json(a_actual), a_message); + end; + procedure fail(a_message in varchar2) is begin ut_expectation_processor.report_failure(a_message); @@ -126,7 +131,12 @@ create or replace package body ut is a_client_character_set varchar2, a_random_test_order integer, a_random_test_order_seed positive, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) is pragma autonomous_transaction; begin @@ -145,7 +155,12 @@ create or replace package body ut is false, ut_utils.int_to_boolean(a_random_test_order), a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + ut_utils.int_to_boolean(a_support_info) ); rollback; end; @@ -162,10 +177,16 @@ create or replace package body ut is a_client_character_set varchar2, a_random_test_order integer, a_random_test_order_seed positive, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) is pragma autonomous_transaction; begin + a_reporter := coalesce(a_reporter,ut_documentation_reporter()); ut_runner.run( a_paths, @@ -181,7 +202,12 @@ create or replace package body ut is false, ut_utils.int_to_boolean(a_random_test_order), a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + ut_utils.int_to_boolean(a_support_info) ); rollback; end; @@ -200,10 +226,15 @@ create or replace package body ut is raise_if_packages_invalidated(); raise no_data_found; end if; - g_result_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len); - g_result_line_no := g_result_lines.first; + if l_clob is not null and l_clob != empty_clob() then + if length(l_clob) > ut_utils.gc_max_storage_varchar2_len then + g_result_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len); + else + g_result_lines := ut_varchar2_list(l_clob); + end if; + g_result_line_no := g_result_lines.first; + end if; end if; - if g_result_line_no is not null then l_result := g_result_lines(g_result_line_no); g_result_line_no := g_result_lines.next(g_result_line_no); @@ -222,7 +253,12 @@ create or replace package body ut is a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -239,10 +275,16 @@ create or replace package body ut is a_client_character_set, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); + g_result_lines := ut_varchar2_list(); loop pipe row( get_report_outputs( l_results ) ); end loop; @@ -261,7 +303,12 @@ create or replace package body ut is a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -278,10 +325,16 @@ create or replace package body ut is a_client_character_set, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); + g_result_lines := ut_varchar2_list(); loop pipe row( get_report_outputs( l_results ) ); end loop; @@ -301,7 +354,12 @@ create or replace package body ut is a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -318,10 +376,16 @@ create or replace package body ut is a_client_character_set, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); + g_result_lines := ut_varchar2_list(); loop pipe row( get_report_outputs( l_results ) ); end loop; @@ -341,7 +405,12 @@ create or replace package body ut is a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -358,10 +427,16 @@ create or replace package body ut is a_client_character_set, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); + g_result_lines := ut_varchar2_list(); loop pipe row( get_report_outputs( l_results ) ); end loop; @@ -381,7 +456,12 @@ create or replace package body ut is a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -398,10 +478,16 @@ create or replace package body ut is a_client_character_set, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); + g_result_lines := ut_varchar2_list(); loop pipe row( get_report_outputs( l_results ) ); end loop; @@ -421,7 +507,12 @@ create or replace package body ut is a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -438,10 +529,16 @@ create or replace package body ut is a_client_character_set, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); + g_result_lines := ut_varchar2_list(); loop pipe row( get_report_outputs( l_results ) ); end loop; @@ -462,7 +559,12 @@ create or replace package body ut is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is l_reporter ut_reporter_base := a_reporter; begin @@ -482,7 +584,12 @@ create or replace package body ut is a_force_manual_rollback, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); else run_autonomous( @@ -497,7 +604,12 @@ create or replace package body ut is a_client_character_set, ut_utils.boolean_to_int(a_random_test_order), a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + ut_utils.boolean_to_int(a_support_info) ); end if; if l_reporter is of (ut_output_reporter_base) then @@ -519,7 +631,12 @@ create or replace package body ut is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is l_reporter ut_reporter_base := a_reporter; begin @@ -536,7 +653,12 @@ create or replace package body ut is a_force_manual_rollback, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); end; @@ -552,7 +674,12 @@ create or replace package body ut is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -568,7 +695,12 @@ create or replace package body ut is a_force_manual_rollback, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); end; @@ -584,7 +716,12 @@ create or replace package body ut is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -600,7 +737,12 @@ create or replace package body ut is a_force_manual_rollback, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); end; @@ -617,7 +759,12 @@ create or replace package body ut is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -633,7 +780,12 @@ create or replace package body ut is a_force_manual_rollback, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); end; @@ -650,7 +802,12 @@ create or replace package body ut is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -666,7 +823,12 @@ create or replace package body ut is a_force_manual_rollback, a_random_test_order, a_random_test_order_seed, - a_tags + a_tags, + a_include_schema_expr, + a_include_object_expr, + a_exclude_schema_expr, + a_exclude_object_expr, + a_support_info ); end; @@ -674,7 +836,7 @@ create or replace package body ut is procedure set_nls is begin if g_nls_date_format is null then - select nsp.value + select /*+ no_parallel */ nsp.value into g_nls_date_format from nls_session_parameters nsp where parameter = 'NLS_DATE_FORMAT'; diff --git a/source/api/ut.pks b/source/api/ut.pks index ff75179b0..0324a164c 100644 --- a/source/api/ut.pks +++ b/source/api/ut.pks @@ -1,11 +1,11 @@ -create or replace package ut authid current_user as +create or replace noneditionable package ut authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -47,6 +47,8 @@ create or replace package ut authid current_user as function expect(a_actual in json_element_t , a_message varchar2 := null) return ut_expectation_json; + function expect(a_actual in json , a_message varchar2 := null) return ut_expectation_json; + procedure fail(a_message in varchar2); function run( @@ -60,7 +62,12 @@ create or replace package ut authid current_user as a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -74,7 +81,12 @@ create or replace package ut authid current_user as a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -89,7 +101,12 @@ create or replace package ut authid current_user as a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -104,7 +121,12 @@ create or replace package ut authid current_user as a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -119,7 +141,12 @@ create or replace package ut authid current_user as a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -134,7 +161,12 @@ create or replace package ut authid current_user as a_client_character_set varchar2 := null, a_random_test_order integer := 0, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; procedure run( @@ -149,7 +181,12 @@ create or replace package ut authid current_user as a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -164,7 +201,12 @@ create or replace package ut authid current_user as a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -180,7 +222,12 @@ create or replace package ut authid current_user as a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -196,7 +243,12 @@ create or replace package ut authid current_user as a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -212,7 +264,12 @@ create or replace package ut authid current_user as a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -228,7 +285,12 @@ create or replace package ut authid current_user as a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); /** diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index 2f523e1dd..9c64ffdba 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -1,11 +1,11 @@ -create or replace package body ut_runner is +create or replace noneditionable package body ut_runner is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,27 +20,6 @@ create or replace package body ut_runner is /** * Private functions */ - function to_ut_object_list(a_names ut_varchar2_list, a_schema_names ut_varchar2_rows) return ut_object_names is - l_result ut_object_names; - l_object_name ut_object_name; - begin - if a_names is not empty then - l_result := ut_object_names(); - for i in 1 .. a_names.count loop - l_object_name := ut_object_name(a_names(i)); - if l_object_name.owner is null then - for i in 1 .. cardinality(a_schema_names) loop - l_result.extend; - l_result(l_result.last) := ut_object_name(a_schema_names(i)||'.'||l_object_name.name); - end loop; - else - l_result.extend; - l_result(l_result.last) := l_object_name; - end if; - end loop; - end if; - return l_result; - end; procedure finish_run(a_run ut_run, a_force_manual_rollback boolean) is begin @@ -51,7 +30,6 @@ create or replace package body ut_runner is ut_compound_data_helper.cleanup_diff(); if not a_force_manual_rollback then rollback; - ut_utils.cleanup_session_temp_tables; end if; end; @@ -91,15 +69,17 @@ create or replace package body ut_runner is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is l_run ut_run; l_coverage_schema_names ut_varchar2_rows; - l_exclude_object_names ut_object_names := ut_object_names(); - l_include_object_names ut_object_names; - l_paths ut_varchar2_list := ut_varchar2_list(); - l_random_test_order_seed positive; - l_tags ut_varchar2_rows := ut_varchar2_rows(); + l_paths ut_varchar2_list; + l_random_test_order_seed positive; begin ut_event_manager.initialize(); if a_reporters is not empty then @@ -113,18 +93,17 @@ create or replace package body ut_runner is ut_event_manager.trigger_event(ut_event_manager.gc_initialize); ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_run_info()); + if a_random_test_order_seed is not null then l_random_test_order_seed := a_random_test_order_seed; elsif a_random_test_order then dbms_random.seed( to_char(systimestamp,'yyyyddmmhh24missffff') ); l_random_test_order_seed := trunc(dbms_random.value(1, 1000000000)); end if; - if a_paths is null or a_paths is empty or a_paths.count = 1 and a_paths(1) is null then + + l_paths := ut_utils.filter_list(ut_utils.string_table_to_table(a_paths,','), '.+'); + if l_paths is null or l_paths is empty then l_paths := ut_varchar2_list(sys_context('userenv', 'current_schema')); - else - for i in 1..a_paths.count loop - l_paths := l_paths multiset union ut_utils.string_to_table(a_string => a_paths(i),a_delimiter => ','); - end loop; end if; begin @@ -132,45 +111,39 @@ create or replace package body ut_runner is ut_utils.save_dbms_output_to_cache(); ut_console_reporter_base.set_color_enabled(a_color_console); + if a_coverage_schemes is not empty then l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes); else l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths); end if; - if a_exclude_objects is not empty then - l_exclude_object_names := to_ut_object_list(a_exclude_objects, l_coverage_schema_names); - end if; - - if a_tags is not null then - l_tags := l_tags multiset union distinct ut_utils.convert_collection( - ut_utils.trim_list_elements(ut_utils.filter_list(ut_utils.string_to_table(a_tags,','),ut_utils.gc_word_no_space)) - ); - end if; - l_exclude_object_names := l_exclude_object_names multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names); - - l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names); - l_run := ut_run( - null, - l_paths, - l_coverage_schema_names, - l_exclude_object_names, - l_include_object_names, - set(a_source_file_mappings), - set(a_test_file_mappings), - a_client_character_set, - l_random_test_order_seed, - l_tags + a_run_paths => l_paths, + a_coverage_options => ut_coverage_options( + coverage_run_id => ut_coverage.get_coverage_run_id(), + schema_names => l_coverage_schema_names, + exclude_objects => ut_utils.convert_collection(a_exclude_objects), + include_objects => ut_utils.convert_collection(a_include_objects), + file_mappings => set(a_source_file_mappings), + include_schema_expr => a_include_schema_expr, + include_object_expr => a_include_object_expr, + exclude_schema_expr => a_exclude_schema_expr, + exclude_object_expr => a_exclude_object_expr + ), + a_test_file_mappings => set(a_test_file_mappings), + a_client_character_set => a_client_character_set, + a_random_test_order_seed => l_random_test_order_seed, + a_run_tags => a_tags, + a_support_info => a_support_info ); - ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, l_tags); + ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, a_tags); if a_force_manual_rollback then l_run.set_rollback_type( a_rollback_type => ut_utils.gc_rollback_manual, a_force => true ); end if; l_run.do_execute(); - finish_run(l_run, a_force_manual_rollback); exception when others then @@ -194,12 +167,14 @@ create or replace package body ut_runner is ut_annotation_manager.purge_cache(a_object_owner, a_object_type); end; - function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined is + function get_suites_info(a_owner varchar2, a_package_name varchar2) return ut_suite_items_info pipelined is l_cursor sys_refcursor; l_results ut_suite_items_info; c_bulk_limit constant integer := 100; + l_path varchar2(4000) := nvl(a_owner,sys_context('userenv', 'current_schema'))||'.'||nvl(a_package_name,'*'); begin - l_cursor := ut_suite_manager.get_suites_info( nvl(a_owner,sys_context('userenv', 'current_schema')), a_package_name ); + + l_cursor := ut_suite_manager.get_suites_info(ut_varchar2_list(l_path)); loop fetch l_cursor bulk collect into l_results limit c_bulk_limit; for i in 1 .. l_results.count loop @@ -211,6 +186,26 @@ create or replace package body ut_runner is return; end; + function get_suites_info(a_path varchar2 := null) return ut_suite_items_info pipelined is + l_cursor sys_refcursor; + l_results ut_suite_items_info; + c_bulk_limit constant integer := 100; + i pls_integer; + begin + l_cursor := ut_suite_manager.get_suites_info(ut_varchar2_list(nvl(a_path,sys_context('userenv', 'current_schema')))); + loop + fetch l_cursor bulk collect into l_results limit c_bulk_limit; + i := l_results.first; + while (i is not null) loop + pipe row (l_results(i)); + i := l_results.next(i); + end loop; + exit when l_cursor%notfound; + end loop; + close l_cursor; + return; + end; + function is_test(a_owner varchar2, a_package_name varchar2, a_procedure_name varchar2) return boolean is l_result boolean := false; begin @@ -265,35 +260,14 @@ create or replace package body ut_runner is end loop; end; - function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is - l_start_pos pls_integer := 1; - l_end_pos pls_integer := 1; - l_result varchar2(4000); - l_item varchar2(4000); - l_at_end boolean := false; + procedure coverage_start(a_coverage_run_id raw) is begin - if a_random_seed is null then - l_result := a_path; - end if; - if a_path is not null then - loop - l_end_pos := instr(a_path,'.',l_start_pos); - if l_end_pos = 0 then - l_end_pos := length(a_path)+1; - l_at_end := true; - end if; - l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos); - if l_item is not null then - l_result := - l_result || - ut_utils.get_hash( to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ) ); - end if; - exit when l_at_end; - l_result := l_result || chr(0); - l_start_pos := l_end_pos + 1; - end loop; - end if; - return l_result; + ut_coverage.coverage_start(a_coverage_run_id); + end; + + procedure coverage_stop is + begin + ut_coverage.coverage_stop; end; end ut_runner; diff --git a/source/api/ut_runner.pks b/source/api/ut_runner.pks index 38167ac57..7ef938f45 100644 --- a/source/api/ut_runner.pks +++ b/source/api/ut_runner.pks @@ -1,11 +1,11 @@ -create or replace package ut_runner authid current_user is +create or replace noneditionable package ut_runner authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -45,6 +45,7 @@ create or replace package ut_runner authid current_user is * @param a_fail_on_errors true/false - should an exception be thrown when tests are completed with failures/errors * @param a_client_character_set if provided, affects some of reporters by setting specific character set for XML/HTML reports * @param a_force_manual_rollback true/false - should the transaction control be forced to --%rollback(manual) and no rollback issued at the end of the run + * @param a_support_info true/false - should the reporters print the utPLSQL support line * * @example * Parameter `a_paths` accepts values of the following formats: @@ -71,7 +72,12 @@ create or replace package ut_runner authid current_user is a_force_manual_rollback boolean := false, a_random_test_order boolean := false, a_random_test_order_seed positive := null, - a_tags varchar2 := null + a_tags varchar2 := null, + a_include_schema_expr varchar2 := null, + a_include_object_expr varchar2 := null, + a_exclude_schema_expr varchar2 := null, + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); /** @@ -100,7 +106,14 @@ create or replace package ut_runner authid current_user is * @param a_package_name name of unit test package to retrieve (optional), if NULL all unit test packages are returned * @return ut_suite_items_info table of objects */ - function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined; + function get_suites_info(a_owner varchar2, a_package_name varchar2) return ut_suite_items_info pipelined; + + /** + * Returns a pipelined collection containing information about unit test suites and the tests contained in them + * + * @param a_path a path from which we lookg for object or suite + */ + function get_suites_info(a_path varchar2 := null) return ut_suite_items_info pipelined; /** @@ -140,10 +153,9 @@ create or replace package ut_runner authid current_user is */ function get_reporters_list return tt_reporters_info pipelined; - /* - * Returns a hash value of suitepath based on input path and random seed - */ - function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2; + procedure coverage_start(a_coverage_run_id raw); + + procedure coverage_stop; end ut_runner; / diff --git a/source/api/ut_suite_item_info.tpb b/source/api/ut_suite_item_info.tpb index 9b142acb0..7005ded37 100644 --- a/source/api/ut_suite_item_info.tpb +++ b/source/api/ut_suite_item_info.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite_item_info is +create or replace noneditionable type body ut_suite_item_info is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -17,7 +17,7 @@ create or replace type body ut_suite_item_info is */ constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2, a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer, - a_tags ut_varchar2_rows) return self as result is + a_disabled_reason varchar2, a_tags ut_varchar2_rows) return self as result is begin self.object_owner := a_object_owner; self.object_name := a_object_name; @@ -27,6 +27,10 @@ create or replace type body ut_suite_item_info is self.item_line_no := a_item_line_no; self.path := a_path; self.disabled_flag := a_disabled_flag; + self.disabled_reason := case when + a_disabled_flag = 1 then a_disabled_reason + else null + end; self.tags := case when a_tags is null then null when a_tags.count = 0 then null diff --git a/source/api/ut_suite_item_info.tps b/source/api/ut_suite_item_info.tps index 807635d1b..c6fdbeb72 100644 --- a/source/api/ut_suite_item_info.tps +++ b/source/api/ut_suite_item_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_item_info as object ( +create or replace noneditionable type ut_suite_item_info as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -23,9 +23,10 @@ create or replace type ut_suite_item_info as object ( item_line_no integer, -- line_number where annotation identifying the item exists path varchar2( 4000 ),-- suitepath of the item disabled_flag integer, -- 0 (zero) if item is not disabled, 1 if item is disabled by --%disabled annotation + disabled_reason varchar2(4000), -- if disable flag is set then you can pass reason tags varchar2(4000), constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2, a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer, - a_tags ut_varchar2_rows) return self as result + a_disabled_reason varchar2, a_tags ut_varchar2_rows) return self as result ) / diff --git a/source/api/ut_suite_items_info.tps b/source/api/ut_suite_items_info.tps index 7c9ac33c3..ac0d52a93 100644 --- a/source/api/ut_suite_items_info.tps +++ b/source/api/ut_suite_items_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_items_info as +create or replace noneditionable type ut_suite_items_info as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/check_object_grants.sql b/source/check_object_grants.sql index d499ced9c..87e821003 100644 --- a/source/check_object_grants.sql +++ b/source/check_object_grants.sql @@ -1,9 +1,22 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + declare - $if dbms_db_version.version >= 18 $then - c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_CRYPTO'); - $else - c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_LOCK','DBMS_CRYPTO'); - $end + c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_CRYPTO'); l_missing_grants varchar2(4000); l_target_table varchar2(128); l_owner_column varchar2(128); @@ -24,7 +37,7 @@ begin l_target_table := get_view('dba_tab_privs'); l_owner_column := case when l_target_table like 'dba%' then 'owner' else 'table_schema' end; execute immediate q'[ - select listagg(' - '||object_name,CHR(10)) within group(order by object_name) + select /*+ no_parallel */ listagg(' - '||object_name,CHR(10)) within group(order by object_name) from ( select column_value as object_name from table(:l_expected_grants) diff --git a/source/check_sys_grants.sql b/source/check_sys_grants.sql index a31e9a9e1..9e1a64e0b 100644 --- a/source/check_sys_grants.sql +++ b/source/check_sys_grants.sql @@ -1,3 +1,20 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + define expected_grants = "&1" declare c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray( &expected_grants ); @@ -12,18 +29,29 @@ begin end if; end loop; end if; + + with + x as ( + select '' as remove from dual + union all + select ' ANY' as remove from dual + ) select listagg(' - '||privilege,CHR(10)) within group(order by privilege) - into l_missing_grants - from ( - select column_value as privilege - from table(l_expected_grants) - minus - (select privilege - from user_sys_privs - union all - select replace(privilege,' ANY ') privilege - from user_sys_privs) - ); + into l_missing_grants + from ( + select column_value as privilege + from table(l_expected_grants) + minus ( + select replace(p.privilege, x.remove) as privilege + from role_sys_privs p + join session_roles r using (role) + cross join x + union all + select replace(p.privilege, x.remove) as privilege + from user_sys_privs p + cross join x + ) + ); if l_missing_grants is not null then raise_application_error( -20000 diff --git a/source/core/annotations/ut_annotated_object.tps b/source/core/annotations/ut_annotated_object.tps index 06a0f4a36..a8b767212 100644 --- a/source/core/annotations/ut_annotated_object.tps +++ b/source/core/annotations/ut_annotated_object.tps @@ -1,10 +1,10 @@ -create type ut_annotated_object as object( +create or replace noneditionable type ut_annotated_object as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotated_objects.tps b/source/core/annotations/ut_annotated_objects.tps index c7b142a32..fe8fc62f7 100644 --- a/source/core/annotations/ut_annotated_objects.tps +++ b/source/core/annotations/ut_annotated_objects.tps @@ -1,10 +1,10 @@ -create type ut_annotated_objects as +create or replace noneditionable type ut_annotated_objects as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation.tps b/source/core/annotations/ut_annotation.tps index 982c0348c..5b8208b8a 100644 --- a/source/core/annotations/ut_annotation.tps +++ b/source/core/annotations/ut_annotation.tps @@ -1,10 +1,10 @@ -create type ut_annotation as object( +create or replace noneditionable type ut_annotation as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_cache.sql b/source/core/annotations/ut_annotation_cache.sql index 8baa6e75c..2ebcb245f 100644 --- a/source/core/annotations/ut_annotation_cache.sql +++ b/source/core/annotations/ut_annotation_cache.sql @@ -1,9 +1,9 @@ create table ut_annotation_cache ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/annotations/ut_annotation_cache_info.sql b/source/core/annotations/ut_annotation_cache_info.sql index e8dc2bfdb..4600af793 100644 --- a/source/core/annotations/ut_annotation_cache_info.sql +++ b/source/core/annotations/ut_annotation_cache_info.sql @@ -1,9 +1,9 @@ create table ut_annotation_cache_info ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -17,7 +17,8 @@ create table ut_annotation_cache_info ( object_name varchar2(250) not null, object_type varchar2(250) not null, parse_time timestamp not null, - constraint ut_annotation_cache_info_pk primary key(cache_id), - constraint ut_annotation_cache_info_uk unique (object_owner, object_type, object_name) + constraint ut_annotation_cache_info_pk primary key(object_owner, object_type, object_name) using index, + constraint ut_annotation_cache_info_uk unique (cache_id) using index, + constraint ut_annotation_cache_info_fk foreign key(object_owner, object_type) references ut_annotation_cache_schema(object_owner, object_type) on delete cascade ) organization index; diff --git a/source/core/annotations/ut_annotation_cache_macros.pkb b/source/core/annotations/ut_annotation_cache_macros.pkb new file mode 100644 index 000000000..b03b7529f --- /dev/null +++ b/source/core/annotations/ut_annotation_cache_macros.pkb @@ -0,0 +1,29 @@ +create or replace noneditionable package body ut_annotation_cache_macros as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + function get_cached_objects(a_object_owner varchar2, a_object_type varchar2) return varchar2 sql_macro is + begin + return q'[ + select /*+ NO_UNNEST NO_EXPAND */ i.object_owner, i.object_name, i.object_type, i.parse_time + from &&ut3_owner..ut_annotation_cache_info i + where i.object_owner = a_object_owner + and i.object_type = a_object_type]'; + end; + +end; +/ diff --git a/source/core/annotations/ut_annotation_cache_macros.pks b/source/core/annotations/ut_annotation_cache_macros.pks new file mode 100644 index 000000000..fa3f43765 --- /dev/null +++ b/source/core/annotations/ut_annotation_cache_macros.pks @@ -0,0 +1,39 @@ +create or replace noneditionable package ut_annotation_cache_macros authid definer as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /* + * SQL macros over the annotation cache tables. + * + * A package containing SQL macros cannot be an invoker rights package, so the macros are kept apart from ut_annotation_cache_manager. + * A macro only returns SQL text. The text is expanded into the calling SQL statement and runs with the privileges of the caller, + * so the macros can only be used by framework code that has the _cbac_modify_objects_role. + * Callers reference the macros qualified with the framework owner, as unqualified names in invoker rights SQL resolve in the invoker's schema. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. + */ + + /** + * Table SQL macro returning objects stored in annotation cache + * Columns: object_owner, object_name, object_type, parse_time + * + * @param a_object_owner owner of cached objects + * @param a_object_type type of cached objects + */ + function get_cached_objects(a_object_owner varchar2, a_object_type varchar2) return varchar2 sql_macro; + +end; +/ diff --git a/source/core/annotations/ut_annotation_cache_manager.pkb b/source/core/annotations/ut_annotation_cache_manager.pkb index eb60ac3dd..10be118f5 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pkb +++ b/source/core/annotations/ut_annotation_cache_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_annotation_cache_manager as +create or replace noneditionable package body ut_annotation_cache_manager as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -17,104 +17,113 @@ create or replace package body ut_annotation_cache_manager as */ procedure update_cache(a_object ut_annotated_object) is - l_cache_id integer; - l_new_objects_count integer := 0; + l_cache_id integer; + l_timestamp timestamp := systimestamp; pragma autonomous_transaction; begin + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_schema s + set s.max_parse_time = l_timestamp + where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner; + + if sql%rowcount = 0 then + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache_schema s + (object_owner, object_type, max_parse_time) + values (a_object.object_owner, a_object.object_type, l_timestamp); + end if; + -- if not in trigger, or object has annotations - if ora_sysevent is null or a_object.annotations is not null and a_object.annotations.count > 0 then + if a_object.annotations is not null and a_object.annotations.count > 0 then - update ut_annotation_cache_info i - set i.parse_time = systimestamp + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_info i + set i.parse_time = l_timestamp where (i.object_owner, i.object_name, i.object_type) in ((a_object.object_owner, a_object.object_name, a_object.object_type)) returning cache_id into l_cache_id; if sql%rowcount = 0 then - insert into ut_annotation_cache_info + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache_info (cache_id, object_owner, object_name, object_type, parse_time) - values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, systimestamp) + values (&&ut3_owner..ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, l_timestamp) returning cache_id into l_cache_id; - l_new_objects_count := 1; end if; - end if; - - update ut_annotation_cache_schema s - set s.object_count = s.object_count + l_new_objects_count, s.max_parse_time = systimestamp - where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner; + delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache c where cache_id = l_cache_id; - if sql%rowcount = 0 then - insert into ut_annotation_cache_schema s - (object_owner, object_type, object_count, max_parse_time) - values (a_object.object_owner, a_object.object_type, l_new_objects_count, systimestamp); - end if; - - delete from ut_annotation_cache c where cache_id = l_cache_id; - - if a_object.annotations is not null and a_object.annotations.count > 0 then - insert into ut_annotation_cache + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache (cache_id, annotation_position, annotation_name, annotation_text, subobject_name) - select l_cache_id, a.position, a.name, a.text, a.subobject_name + select /*+ no_parallel */ l_cache_id, a.position, a.name, a.text, a.subobject_name from table(a_object.annotations) a; + elsif a_object.annotations is null or a_object.annotations.count = 0 then + ut_annotation_cache_manager.remove_from_cache( + ut_annotation_objs_cache_info( + ut_annotation_obj_cache_info(a_object.object_owner, a_object.object_name, a_object.object_type, 'Y', null) + ) + ); end if; commit; end; - procedure cleanup_cache(a_objects ut_annotation_objs_cache_info) is + procedure reset_objects_cache(a_objects ut_annotation_objs_cache_info) is + l_timestamp timestamp := systimestamp; pragma autonomous_transaction; begin - delete from ut_annotation_cache c + delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache c where c.cache_id - in (select i.cache_id - from ut_annotation_cache_info i + in (select /*+ no_parallel */ i.cache_id + from &&ut3_owner..ut_annotation_cache_info i join table (a_objects) o on o.object_name = i.object_name and o.object_type = i.object_type and o.object_owner = i.object_owner + and o.needs_refresh = 'Y' ); - merge into ut_annotation_cache_info i - using (select o.object_name, o.object_type, o.object_owner - from table(a_objects) o ) o + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_schema s + set s.max_parse_time = l_timestamp + where (s.object_owner, s.object_type) + in ( + select /*+ no_parallel */ o.object_owner, o.object_type + from table(a_objects) o + where o.needs_refresh = 'Y' + ); + + if sql%rowcount = 0 then + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache_schema s + (object_owner, object_type, max_parse_time) + select /*+ no_parallel */ distinct o.object_owner, o.object_type, l_timestamp + from table(a_objects) o + where o.needs_refresh = 'Y'; + end if; + + merge /*+ no_parallel */ + into &&ut3_owner..ut_annotation_cache_info i + using (select /*+ no_parallel */ o.object_name, o.object_type, o.object_owner + from table(a_objects) o + where o.needs_refresh = 'Y' + ) o on (o.object_name = i.object_name and o.object_type = i.object_type and o.object_owner = i.object_owner) - when matched then update set parse_time = systimestamp + when matched then + update + set parse_time = l_timestamp when not matched then insert - (cache_id, object_owner, object_name, object_type, parse_time) - values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, systimestamp); + (cache_id, object_owner, object_name, object_type, parse_time) + values (&&ut3_owner..ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, l_timestamp); commit; end; - function get_annotations_objects_info(a_object_owner varchar2, a_object_type varchar2) return ut_annotation_objs_cache_info is - l_result ut_annotation_objs_cache_info; - begin - select ut_annotation_obj_cache_info( - object_owner => i.object_owner, - object_name => i.object_name, - object_type => i.object_type, - needs_refresh => 'N', - parse_time => i.parse_time - ) - bulk collect into l_result - from ut_annotation_cache_info i - where i.object_owner = a_object_owner - and i.object_type = a_object_type; - return l_result; - end; - function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info is l_result t_cache_schema_info; begin begin - select * + select /*+ no_parallel */ * into l_result - from ut_annotation_cache_schema s + from &&ut3_owner..ut_annotation_cache_schema s where s.object_type = a_object_type and s.object_owner = a_object_owner; exception when no_data_found then @@ -123,13 +132,23 @@ create or replace package body ut_annotation_cache_manager as return l_result; end; + procedure set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2) is + pragma autonomous_transaction; + begin + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_schema s + set s.full_refresh_time = s.max_parse_time + where s.object_owner = a_object_owner + and s.object_type = a_object_type; + commit; + end; + procedure remove_from_cache(a_objects ut_annotation_objs_cache_info) is pragma autonomous_transaction; begin - delete from ut_annotation_cache_info i + delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache_info i where exists ( - select 1 from table (a_objects) o + select /*+ no_parallel */ 1 from table (a_objects) o where o.object_name = i.object_name and o.object_type = i.object_type and o.object_owner = i.object_owner @@ -138,27 +157,28 @@ create or replace package body ut_annotation_cache_manager as commit; end; - function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_time timestamp) return sys_refcursor is - l_results sys_refcursor; + function get_annotations_parsed_since(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp) return sys_refcursor is + l_results sys_refcursor; begin - open l_results for q'[ - select ut_annotated_object( + --cast(collect(...)) does not use privileges of code based access control roles (ORA-00902), cast(multiset(...)) does + open l_results for + select /*+ no_parallel */ &&ut3_owner..ut_annotated_object( i.object_owner, i.object_name, i.object_type, i.parse_time, cast( - collect( - ut_annotation( - c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name - ) order by c.annotation_position - ) as ut_annotations + multiset( + select /*+ no_parallel */ &&ut3_owner..ut_annotation( + c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name + ) + from &&ut3_owner..ut_annotation_cache c + where c.cache_id = i.cache_id + order by c.annotation_position + ) as &&ut3_owner..ut_annotations ) - ) - from table(:a_cached_objects) o - join ut_annotation_cache_info i - on o.object_owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type - join ut_annotation_cache c on i.cache_id = c.cache_id - where ]'|| case when a_parse_time is null then ':a_parse_date is null' else 'i.parse_time > :a_parse_time' end ||q'[ - group by i.object_owner, i.object_name, i.object_type, i.parse_time]' - using a_cached_objects, a_parse_time; + ) as annotated_object + from &&ut3_owner..ut_annotation_cache_info i + where i.object_owner = a_object_owner and i.object_type = a_object_type + and (i.parse_time > a_parsed_after or a_parsed_after is null) + and exists (select /*+ no_parallel */ 1 from &&ut3_owner..ut_annotation_cache c where c.cache_id = i.cache_id); return l_results; end; @@ -168,35 +188,24 @@ create or replace package body ut_annotation_cache_manager as pragma autonomous_transaction; begin if a_object_owner is null and a_object_type is null then - l_cache_filter := ':a_object_owner is null and :a_object_type is null'; - l_filter := l_cache_filter; + l_filter := ':a_object_owner is null and :a_object_type is null'; + l_cache_filter := l_filter; else - l_filter := - case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end || ' - and '||case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end; - l_cache_filter := ' c.cache_id - in (select i.cache_id - from ut_annotation_cache_info i - where '|| l_filter || ' - )'; + l_filter := case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end; + l_filter := l_filter || ' and ' || case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end; + l_cache_filter := ' c.cache_id in (select /*+ no_parallel */ i.cache_id from &&ut3_owner..ut_annotation_cache_info i where ' || l_filter || ' )'; end if; - execute immediate ' - delete from ut_annotation_cache c - where '||l_cache_filter + execute immediate 'delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache c where ' || l_cache_filter using a_object_owner, a_object_type; - execute immediate ' - delete from ut_annotation_cache_info i - where ' || l_filter + execute immediate ' delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache_info i where ' || l_filter using a_object_owner, a_object_type; - execute immediate ' - delete from ut_annotation_cache_schema s - where ' || l_filter + execute immediate ' delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache_schema s where ' || l_filter using a_object_owner, a_object_type; commit; end; -end ut_annotation_cache_manager; +end; / diff --git a/source/core/annotations/ut_annotation_cache_manager.pks b/source/core/annotations/ut_annotation_cache_manager.pks index 2a1d60f1e..a07f56e66 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pks +++ b/source/core/annotations/ut_annotation_cache_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_annotation_cache_manager authid definer as +create or replace noneditionable package ut_annotation_cache_manager authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,7 +15,15 @@ create or replace package ut_annotation_cache_manager authid definer as See the License for the specific language governing permissions and limitations under the License. */ + + /* + * The package runs with invoker rights. It accesses the annotation cache tables of the framework owner + * through the code based access control role _cbac_modify_objects_role granted to the package, + * so all references to those tables in SQL statements are qualified with the framework owner. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. + */ subtype t_cache_schema_info is ut_annotation_cache_schema%rowtype; + /** * Populates cache with information about object and it's annotations * Cache information for individual object is modified by this code @@ -30,21 +38,22 @@ create or replace package ut_annotation_cache_manager authid definer as * Returns a ref_cursor containing `ut_annotated_object` as result * Range of data returned is limited by the input collection o cache object info * - * @param a_cached_objects a `ut_annotation_objs_cache_info` list with information about objects to get from cache + * @param a_cached_objects - list of `ut_annotation_objs_cache_info` containing objects to get from cache + * @param a_min_parse_time - limit results to annotations parsed after specified time only, + * if null - all cached annotations for given objects are returned */ - function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_time timestamp) return sys_refcursor; - + function get_annotations_parsed_since(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp) return sys_refcursor; - function get_annotations_objects_info(a_object_owner varchar2, a_object_type varchar2) return ut_annotation_objs_cache_info; + procedure set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2); function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info; /** - * Removes cached information about annotations for objects on the list and updates parse_time in cache info table. + * Resets cached information about annotations for objects on the list and updates parse_time in cache info table. * * @param a_objects a `ut_annotation_objs_cache_info` list with information about objects to remove annotations for */ - procedure cleanup_cache(a_objects ut_annotation_objs_cache_info); + procedure reset_objects_cache(a_objects ut_annotation_objs_cache_info); /** * Removes information about objects on the list diff --git a/source/core/annotations/ut_annotation_cache_schema.sql b/source/core/annotations/ut_annotation_cache_schema.sql index abab7385e..46c49739d 100644 --- a/source/core/annotations/ut_annotation_cache_schema.sql +++ b/source/core/annotations/ut_annotation_cache_schema.sql @@ -1,9 +1,9 @@ create table ut_annotation_cache_schema ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -12,10 +12,10 @@ create table ut_annotation_cache_schema ( See the License for the specific language governing permissions and limitations under the License. */ - object_owner varchar2(250) not null, - object_type varchar2(250) not null, - object_count integer not null, - max_parse_time date not null, + object_owner varchar2(250) not null, + object_type varchar2(250) not null, + max_parse_time date not null, + full_refresh_time timestamp, constraint ut_annotation_cache_schema_pk primary key(object_owner, object_type) ) organization index; diff --git a/source/core/annotations/ut_annotation_cache_seq.sql b/source/core/annotations/ut_annotation_cache_seq.sql index 0a898e98e..0313abde5 100644 --- a/source/core/annotations/ut_annotation_cache_seq.sql +++ b/source/core/annotations/ut_annotation_cache_seq.sql @@ -1,9 +1,9 @@ create sequence ut_annotation_cache_seq /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/annotations/ut_annotation_manager.pkb b/source/core/annotations/ut_annotation_manager.pkb index fd2997632..59bc54530 100644 --- a/source/core/annotations/ut_annotation_manager.pkb +++ b/source/core/annotations/ut_annotation_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_annotation_manager as +create or replace noneditionable package body ut_annotation_manager as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -19,86 +19,83 @@ create or replace package body ut_annotation_manager as ------------------------------ --private definitions - function get_missing_objects(a_object_owner varchar2, a_object_type varchar2) return ut_annotation_objs_cache_info is - l_rows sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); - l_cursor_text varchar2(32767); - l_data ut_annotation_objs_cache_info; - l_result ut_annotation_objs_cache_info; - l_card natural; + function user_can_see_whole_schema( a_schema_name varchar2 ) return boolean is begin - l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, a_object_type); - l_card := ut_utils.scale_cardinality(cardinality(l_data)); - - l_cursor_text := - 'select /*+ cardinality(i '||l_card||') */ - value(i) - from table( cast( :l_data as '||l_ut_owner||'.ut_annotation_objs_cache_info ) ) i - where - not exists ( - select 1 from '||l_objects_view||q'[ o - where o.owner = i.object_owner + return sys_context('userenv','current_user') = a_schema_name + or ut_metadata.user_has_execute_any_proc() + or ut_metadata.is_object_visible('dba_objects'); + end; + + function get_non_existing_objects( a_object_owner varchar2, a_object_type varchar2 ) return ut_annotation_objs_cache_info is + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); + l_object_to_delete ut_annotation_objs_cache_info; + begin + execute immediate + 'select /*+ no_parallel */ + '||l_ut_owner||q'[.ut_annotation_obj_cache_info( + object_owner => i.object_owner, + object_name => i.object_name, + object_type => i.object_type, + needs_refresh => 'N', + parse_time => i.parse_time + ) + from (]'||l_ut_owner||q'[.ut_annotation_cache_macros.get_cached_objects( :a_object_owner, :a_object_type )) i + where not exists ( + select 1 from ]'||l_objects_view||q'[ o + where o.owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - )]'; - open l_rows for l_cursor_text using l_data; - fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit; - close l_rows; - return l_result; + )]' + bulk collect into l_object_to_delete + using a_object_owner, a_object_type; + return l_object_to_delete; end; - function get_annotation_objs_info( - a_object_owner varchar2, - a_object_type varchar2, - a_parse_date timestamp := null, - a_full_scan boolean := true + function get_objects_to_refresh( + a_object_owner varchar2, + a_object_type varchar2, + a_modified_after timestamp ) return ut_annotation_objs_cache_info is - l_rows sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); - l_cursor_text varchar2(32767); - l_data ut_annotation_objs_cache_info; - l_result ut_annotation_objs_cache_info; + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_refresh_needed boolean; + l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); + l_result ut_annotation_objs_cache_info := ut_annotation_objs_cache_info(); begin - ut_event_manager.trigger_event( - 'get_annotation_objs_info - start ( a_full_scan = ' || ut_utils.to_string(a_full_scan) || ' )' - ); - - l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, a_object_type); - - if not a_full_scan then - l_result := l_data; - else - l_cursor_text := - 'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_data))||') */ - '||l_ut_owner||q'[.ut_annotation_obj_cache_info( - object_owner => o.owner, - object_name => o.object_name, - object_type => o.object_type, - needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end, - parse_time => i.parse_time - ) - from ]'||l_objects_view||' o - left join table( cast(:l_data as '||l_ut_owner||q'[.ut_annotation_objs_cache_info ) ) i - on o.owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = i.object_type - where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' - and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - and ]' + ut_event_manager.trigger_event( 'get_objects_to_refresh - start', ut_key_anyvalues().put('ut_trigger_check.is_alive()',ut_trigger_check.is_alive()) ); + + l_refresh_needed := ( ut_trigger_check.is_alive() = false ) or a_modified_after is null; + if l_refresh_needed then + --limit the list to objects that exist and are visible to the invoking user + --enrich the list by info about cache validity + execute immediate + 'select /*+ no_parallel */ + '||l_ut_owner||q'[.ut_annotation_obj_cache_info( + object_owner => o.owner, + object_name => o.object_name, + object_type => o.object_type, + needs_refresh => 'Y', + parse_time => c.parse_time + ) + from ]'||l_objects_view||' o + left join '||l_ut_owner||q'[.ut_annotation_cache_macros.get_cached_objects( :a_object_owner, :a_object_type ) c + on o.owner = c.object_owner + and o.object_name = c.object_name + and o.object_type = c.object_type + where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' + and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' + and (c.parse_time is null or o.last_ddl_time >= cast(c.parse_time as date)) + and ]' || case - when a_parse_date is null - then ':a_parse_date is null' - else 'o.last_ddl_time >= cast(:a_parse_date as date)' - end; - open l_rows for l_cursor_text using l_data, a_parse_date; - fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit; - close l_rows; + when a_modified_after is null + then ':a_modified_after is null' + else 'o.last_ddl_time >= cast(:a_modified_after as date)' + end + bulk collect into l_result using a_object_owner, a_object_type, a_modified_after; end if; - ut_event_manager.trigger_event('get_annotation_objs_info - end (count='||l_result.count||')'); + ut_event_manager.trigger_event('get_objects_to_refresh - end (count='||l_result.count||')'); return l_result; end; @@ -109,24 +106,25 @@ create or replace package body ut_annotation_manager as begin l_card := ut_utils.scale_cardinality(cardinality(a_objects_to_refresh)); open l_result for - q'[select s.name, s.text + q'[select /*+ no_parallel */ x.name, x.text from (select /*+ cardinality( r ]'||l_card||q'[ )*/ s.name, s.text, s.line, max(case when s.text like '%--%\%%' escape '\' - and regexp_like(s.text,'--\s*%') + and regexp_like(s.text,'^\s*--\s*%') then 'Y' else 'N' end ) over(partition by s.name) is_annotated from table(:a_objects_to_refresh) r join ]'||l_sources_view||q'[ s - on s.name = r.object_name + on s.name = r.object_name and s.owner = r.object_owner - and s.type = r.object_type - where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' - and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - ) s - where s.is_annotated = 'Y' - order by s.name, s.line]' + and s.type = r.object_type + where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' + and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' + and s.origin_con_id = sys_context('userenv', 'con_id') + ) x + where x.is_annotated = 'Y' + order by x.name, x.line]' using a_objects_to_refresh; return l_result; @@ -146,75 +144,88 @@ create or replace package body ut_annotation_manager as l_parse_time date := sysdate; pragma autonomous_transaction; begin - loop - fetch a_sources_cursor bulk collect into l_names, l_lines limit c_lines_fetch_limit; - for i in 1 .. l_names.count loop - if l_names(i) != l_name then - l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type); - ut_annotation_cache_manager.update_cache( - ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations) - ); - l_object_lines.delete; - end if; - - l_name := l_names(i); - l_object_lines(l_object_lines.count+1) := l_lines(i); - end loop; - exit when a_sources_cursor%notfound; + begin + loop + fetch a_sources_cursor bulk collect into l_names, l_lines limit c_lines_fetch_limit; + for i in 1 .. l_names.count loop + if l_names(i) != l_name then + l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type); + ut_annotation_cache_manager.update_cache( + ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations) + ); + l_object_lines.delete; + end if; - end loop; - if a_sources_cursor%rowcount > 0 then - l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type); - ut_annotation_cache_manager.update_cache( - ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations) - ); - l_object_lines.delete; + l_name := l_names(i); + l_object_lines(l_object_lines.count+1) := l_lines(i); + end loop; + exit when a_sources_cursor%notfound; + + end loop; + if a_sources_cursor%rowcount > 0 then + l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type); + ut_annotation_cache_manager.update_cache( + ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations) + ); + l_object_lines.delete; + end if; + end; + if a_sources_cursor%isopen then + close a_sources_cursor; end if; - close a_sources_cursor; end; - - procedure refresh_annotation_cache( - a_object_owner varchar2, - a_object_type varchar2, - a_info_rows ut_annotation_objs_cache_info + procedure validate_annotation_cache( + a_object_owner varchar2, + a_object_type varchar2, + a_modified_after timestamp := null ) is - l_objects_to_parse ut_annotation_objs_cache_info; + l_objects_to_refresh ut_annotation_objs_cache_info; + l_modified_after timestamp := a_modified_after; begin - select value(x) - bulk collect into l_objects_to_parse - from table(a_info_rows) x where x.needs_refresh = 'Y'; + if ut_annotation_cache_manager.get_cache_schema_info(a_object_owner, a_object_type).full_refresh_time is null then + l_modified_after := null; + end if; - ut_event_manager.trigger_event('rebuild_annotation_cache - start (l_objects_to_parse.count = '||l_objects_to_parse.count||')'); - ut_annotation_cache_manager.cleanup_cache(l_objects_to_parse); + l_objects_to_refresh := get_objects_to_refresh(a_object_owner, a_object_type, l_modified_after); - if sys_context('userenv','current_schema') = a_object_owner - or ut_metadata.user_has_execute_any_proc() - or ut_metadata.is_object_visible('dba_objects') - then - ut_annotation_cache_manager.remove_from_cache( - get_missing_objects(a_object_owner, a_object_type) - ); + ut_event_manager.trigger_event('validate_annotation_cache - start (l_objects_to_refresh.count = '||l_objects_to_refresh.count||')'); + + + if user_can_see_whole_schema( a_object_owner ) then + --Remove non existing objects from cache only when user can see whole schema + ut_annotation_cache_manager.remove_from_cache( get_non_existing_objects( a_object_owner, a_object_type ) ); end if; --if some source needs parsing and putting into cache - if l_objects_to_parse.count > 0 then + if l_objects_to_refresh.count > 0 then + --Delete annotations for objects that are to be refreshed + ut_annotation_cache_manager.reset_objects_cache(l_objects_to_refresh); + --Rebuild cache from objects source build_annot_cache_for_sources( a_object_owner, a_object_type, - get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_parse) + get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_refresh) ); end if; - ut_event_manager.trigger_event('rebuild_annotation_cache - end'); + + if l_modified_after is null then + if user_can_see_whole_schema( a_object_owner ) then + ut_annotation_cache_manager.set_fully_refreshed( a_object_owner, a_object_type ); + else + -- if user cannot see full schema - we dont mark it as fully refreshed + -- it will get refreshed each time until someone with proper privs will refresh it + null; + end if; + end if; + ut_event_manager.trigger_event('validate_annotation_cache - end'); end; ------------------------------------------------------------ --public definitions ------------------------------------------------------------ procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2) is - l_annotation_objs_info ut_annotation_objs_cache_info; begin - l_annotation_objs_info := get_annotation_objs_info(a_object_owner, a_object_type, null, true); - refresh_annotation_cache( a_object_owner, a_object_type, l_annotation_objs_info ); + validate_annotation_cache( a_object_owner, a_object_type ); end; procedure trigger_obj_annotation_rebuild is @@ -224,23 +235,27 @@ create or replace package body ut_annotation_manager as function get_source_from_sql_text(a_object_name varchar2, a_sql_text ora_name_list_t, a_parts binary_integer) return sys_refcursor is l_sql_clob clob; - l_sql_lines ut_varchar2_rows := ut_varchar2_rows(); + l_sql_lines dbms_preprocessor.source_lines_t := dbms_preprocessor.source_lines_t(); + l_sql_lines_clob ut_varchar2_list := ut_varchar2_list(); l_result sys_refcursor; begin if a_parts > 0 then for i in 1..a_parts loop ut_utils.append_to_clob(l_sql_clob, a_sql_text(i)); end loop; - l_sql_clob := ut_utils.replace_multiline_comments(l_sql_clob); - -- replace comment lines that contain "-- create or replace" - l_sql_clob := regexp_replace(l_sql_clob, '^.*[-]{2,}\s*create(\s+or\s+replace).*$', modifier => 'mi'); - -- remove the "create [or replace] [[non]editionable] " so that we have only "type|package" for parsing - -- needed for dbms_preprocessor - l_sql_clob := regexp_replace(l_sql_clob, '^(.*?\s*create(\s+or\s+replace)?(\s+(editionable|noneditionable))?\s+?)((package|type).*)', '\5', 1, 1, 'ni'); - l_sql_lines := ut_utils.convert_collection( ut_utils.clob_to_table(l_sql_clob) ); + + l_sql_lines_clob := ut_utils.clob_to_table(l_sql_clob); + for i in 1..l_sql_lines_clob.count loop + l_sql_lines(i) := l_sql_lines_clob(i); + end loop; + + -- replace multiline comments that contain "-- create or replace" with single line comment to avoid parsing issues with dbms_preprocessor + l_sql_lines := ut_utils.replace_multiline_comments(l_sql_lines); + -- strip CREATE header (possibly split across lines) while preserving line numbers + l_sql_lines := ut_utils.strip_create_header_lines(l_sql_lines); end if; open l_result for - select a_object_name as name, column_value||chr(10) as text from table(l_sql_lines); + select /*+ no_parallel */ a_object_name as name, column_value||chr(10) as text from table(l_sql_lines); return l_result; end; @@ -249,11 +264,12 @@ create or replace package body ut_annotation_manager as l_sources_view varchar2(200) := ut_metadata.get_source_view_name(); begin open l_result for - q'[select :a_object_name, s.text + q'[select /*+ no_parallel */ :a_object_name, s.text from ]'||l_sources_view||q'[ s where s.type = :a_object_type and s.owner = :a_object_owner and s.name = :a_object_name + and s.origin_con_id = sys_context('userenv', 'con_id') order by s.line]' using a_object_name, a_object_type, a_object_owner, a_object_name; return l_result; @@ -261,15 +277,8 @@ create or replace package body ut_annotation_manager as begin if ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') then - $if dbms_db_version.version < 12 $then - l_restricted_users := ora_name_list_t( - 'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL', - 'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF', - 'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL'); - $else - select username bulk collect into l_restricted_users - from all_users where oracle_maintained = 'Y'; - $end + select /*+ no_parallel */ username bulk collect into l_restricted_users + from all_users where oracle_maintained = 'Y'; if ora_dict_obj_owner member of l_restricted_users then return; end if; @@ -295,17 +304,14 @@ create or replace package body ut_annotation_manager as end if; end; - function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return sys_refcursor is - l_annotation_objs_info ut_annotation_objs_cache_info; + function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_modified_after timestamp) return sys_refcursor is l_cursor sys_refcursor; - l_full_scan_needed boolean := not ut_trigger_check.is_alive(); begin - ut_event_manager.trigger_event('get_annotated_objects - start'); - l_annotation_objs_info := get_annotation_objs_info(a_object_owner, a_object_type, a_parse_date, l_full_scan_needed); - refresh_annotation_cache(a_object_owner, a_object_type, l_annotation_objs_info); + ut_event_manager.trigger_event('get_annotated_objects - start: a_modified_after='||ut_utils.to_string(a_modified_after)); + validate_annotation_cache(a_object_owner, a_object_type, a_modified_after); --pipe annotations from cache - l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_annotation_objs_info, a_parse_date); + l_cursor := ut_annotation_cache_manager.get_annotations_parsed_since(a_object_owner, a_object_type, a_modified_after); ut_event_manager.trigger_event('get_annotated_objects - end'); return l_cursor; end; @@ -315,5 +321,5 @@ create or replace package body ut_annotation_manager as ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type); end; -end ut_annotation_manager; +end; / diff --git a/source/core/annotations/ut_annotation_manager.pks b/source/core/annotations/ut_annotation_manager.pks index 1d6bd3d71..37809e88c 100644 --- a/source/core/annotations/ut_annotation_manager.pks +++ b/source/core/annotations/ut_annotation_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_annotation_manager authid current_user as +create or replace noneditionable package ut_annotation_manager authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -23,18 +23,17 @@ create or replace package ut_annotation_manager authid current_user as /** * Gets annotations for all objects of a specified type for database schema. * Annotations that are stale or missing are parsed and placed in persistent cache. - * After placing in cache, annotation data is returned as pipelined table data. + * After placing in cache, annotation data is returned as ref_cursor. * - * @param a_object_owner owner of objects to get annotations for - * @param a_object_type type of objects to get annotations for - * @param a_parse_date date when object was last parsed - * @return array containing annotated objects along with annotations for each object (nested) + * @param a_object_owner owner of objects to get annotations for + * @param a_object_type type of objects to get annotations for + * @param a_modified_after return only objects modified after thr timestamp + * @return cursor containing annotated objects along with annotations for each object (nested) */ - function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return sys_refcursor; + function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_modified_after timestamp) return sys_refcursor; /** * Rebuilds annotation cache for a specified schema and object type. - * The procedure is called internally by `get_annotated_objects` function. * It can be used to speedup initial execution of utPLSQL on a given schema * if it is executed before any call is made to `ut.run` or `ut_runner.run` procedure. * @@ -57,5 +56,5 @@ create or replace package ut_annotation_manager authid current_user as procedure purge_cache(a_object_owner varchar2, a_object_type varchar2); -end ut_annotation_manager; +end; / diff --git a/source/core/annotations/ut_annotation_obj_cache_info.tps b/source/core/annotations/ut_annotation_obj_cache_info.tps index 4b8178a9d..1e2d9d265 100644 --- a/source/core/annotations/ut_annotation_obj_cache_info.tps +++ b/source/core/annotations/ut_annotation_obj_cache_info.tps @@ -1,10 +1,10 @@ -create type ut_annotation_obj_cache_info as object( +create or replace noneditionable type ut_annotation_obj_cache_info as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_objs_cache_info.tps b/source/core/annotations/ut_annotation_objs_cache_info.tps index bab33a9d3..1e1d730b6 100644 --- a/source/core/annotations/ut_annotation_objs_cache_info.tps +++ b/source/core/annotations/ut_annotation_objs_cache_info.tps @@ -1,10 +1,10 @@ -create type ut_annotation_objs_cache_info as +create or replace noneditionable type ut_annotation_objs_cache_info as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_parser.pkb b/source/core/annotations/ut_annotation_parser.pkb index bbe58a667..f7314c2a0 100644 --- a/source/core/annotations/ut_annotation_parser.pkb +++ b/source/core/annotations/ut_annotation_parser.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_annotation_parser as +create or replace noneditionable package body ut_annotation_parser as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,12 +22,10 @@ create or replace package body ut_annotation_parser as type tt_comment_list is table of varchar2(32767) index by binary_integer; gc_annotation_qualifier constant varchar2(1) := '%'; - gc_annot_comment_pattern constant varchar2(30) := '^( |'||chr(09)||')*-- *('||gc_annotation_qualifier||'.*?)$'; -- chr(09) is a tab character gc_comment_replacer_patter constant varchar2(50) := '{COMMENT#%N%}'; gc_comment_replacer_regex_ptrn constant varchar2(25) := '{COMMENT#(\d+)}'; - gc_regexp_identifier constant varchar2(50) := '[a-zA-Z][a-zA-Z0-9#_$]*'; - gc_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' || - gc_regexp_identifier || ')'; + gc_regexp_identifier constant varchar2(50) := '[[:alpha:]][[:alnum:]$#_]*'; + gc_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || gc_regexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?'; @@ -72,133 +70,144 @@ create or replace package body ut_annotation_parser as a_subobject_name varchar2 := null ) is l_loop_index binary_integer := 1; - l_annotation_index binary_integer; + l_annotation_index binary_integer := 1; begin - -- loop while there are unprocessed comment blocks - while 0 != nvl(regexp_instr(srcstr => a_source - ,pattern => gc_comment_replacer_regex_ptrn - ,occurrence => l_loop_index - ,subexpression => 1) - ,0) loop + -- loop while there are unprocessed comment blocks + while l_annotation_index is not null loop -- define index of the comment block and get it's content from cache l_annotation_index := regexp_substr( a_source ,gc_comment_replacer_regex_ptrn ,1 ,l_loop_index ,subexpression => 1); - add_annotation( a_annotations, l_annotation_index, a_comments( l_annotation_index ), a_subobject_name ); - l_loop_index := l_loop_index + 1; + if l_annotation_index is not null then + add_annotation( a_annotations, l_annotation_index, a_comments( l_annotation_index ), a_subobject_name ); + l_loop_index := l_loop_index + 1; + end if; end loop; end add_annotations; - procedure add_procedure_annotations(a_annotations in out nocopy ut_annotations, a_source clob, a_comments in out nocopy tt_comment_list) is - l_proc_comments varchar2(32767); - l_proc_name varchar2(250); - l_annot_proc_ind number; - l_annot_proc_block varchar2(32767); + procedure add_procedure_annotations( + a_annotations in out nocopy ut_annotations, + a_source in dbms_preprocessor.source_lines_t, + a_comments in out nocopy tt_comment_list + ) is + l_proc_comments varchar2(32767); + l_proc_name varchar2(250); + l_line varchar2(32767); + l_in_comment_block boolean := false; + l_i binary_integer; begin - -- loop through procedures and functions of the package and get all the comment blocks just before it's declaration - l_annot_proc_ind := 1; - loop - --find annotated procedure index - l_annot_proc_ind := regexp_instr(srcstr => a_source - ,pattern => gc_annotation_block_pattern - ,occurrence => 1 - ,modifier => 'i' - ,position => l_annot_proc_ind); - exit when l_annot_proc_ind = 0; - - --get the annotations with procedure name - l_annot_proc_block := regexp_substr(srcstr => a_source - ,pattern => gc_annotation_block_pattern - ,position => l_annot_proc_ind - ,occurrence => 1 - ,modifier => 'i'); - - --extract the annotations - l_proc_comments := trim(regexp_substr(srcstr => l_annot_proc_block - ,pattern => gc_annotation_block_pattern - ,modifier => 'i' - ,subexpression => 1)); - --extract the procedure name - l_proc_name := trim(regexp_substr(srcstr => l_annot_proc_block - ,pattern => gc_annotation_block_pattern - ,modifier => 'i' - ,subexpression => 5)); - - -- parse the comment block for the syntactically correct annotations and store them as an array - add_annotations(a_annotations, l_proc_comments, a_comments, l_proc_name); - - l_annot_proc_ind := instr(a_source, ';', l_annot_proc_ind + length(l_annot_proc_block) ); + l_i := 1; + while l_i <= a_source.count loop + l_line := a_source(l_i); + -- Comment placeholder line: start/continue accumulating a block + if instr(l_line, chr(123) ||'COMMENT#') > 0 then + if l_in_comment_block then + l_proc_comments := l_proc_comments || l_line || chr(10); + else + l_in_comment_block := true; + l_proc_comments := l_line || chr(10); + end if; + l_i := l_i + 1; + -- Whitespace-only line: allowed between comment block and proc decl + elsif l_in_comment_block and trim(replace(l_line, chr(9))) is null then + l_i := l_i + 1; + -- procedure/function declaration following a comment block + elsif l_in_comment_block + and regexp_like(l_line, '^\s*(procedure|function)\s+', 'i') + then + -- extract just the identifier name (subexpression 2) + l_proc_name := trim(regexp_substr(srcstr =>l_line + ,pattern => '^\s*(procedure|function)\s+('||gc_regexp_identifier||')' + ,modifier => 'i' + ,subexpression => 2)); + + -- pass accumulated comment placeholders + proc name to add_annotations + add_annotations(a_annotations, l_proc_comments, a_comments, l_proc_name); + + -- reset comment block state + l_in_comment_block := false; + l_proc_comments := null; + + -- advance past proc header to the terminating ';' + -- the header may span multiple lines e.g. with multi-line parameter lists + while l_i <= a_source.count loop + exit when instr(a_source(l_i), ';') > 0; + l_i := l_i + 1; + end loop; + l_i := l_i + 1; -- step past the ';' line itself + -- Any other line: reset comment block accumulator + else + l_in_comment_block := false; + l_proc_comments := null; + l_i := l_i + 1; + end if; end loop; end add_procedure_annotations; - function extract_and_replace_comments(a_source in out nocopy clob) return tt_comment_list is - l_comments tt_comment_list; - l_comment_pos binary_integer; - l_comment_line binary_integer; + function extract_and_replace_comments( + a_source in out nocopy dbms_preprocessor.source_lines_t + ) return tt_comment_list is + l_comments tt_comment_list; + l_line varchar2(32767); + l_comment_pos binary_integer; l_comment_replacer varchar2(50); - l_source clob := a_source; begin - l_comment_pos := 1; - loop - - l_comment_pos := regexp_instr(srcstr => a_source - ,pattern => gc_annot_comment_pattern - ,occurrence => 1 - ,modifier => 'm' - ,position => l_comment_pos); - - exit when l_comment_pos = 0; - - -- position index is shifted by 1 because gc_annot_comment_pattern contains ^ as first sign - -- but after instr index already points to the char on that line - l_comment_pos := l_comment_pos-1; - l_comment_line := length(substr(a_source,1,l_comment_pos))-length(replace(substr(a_source,1,l_comment_pos),chr(10)))+1; - l_comments(l_comment_line) := trim(regexp_substr(srcstr => a_source - ,pattern => gc_annot_comment_pattern - ,occurrence => 1 - ,position => l_comment_pos - ,modifier => 'm' - ,subexpression => 2)); - - l_comment_replacer := replace(gc_comment_replacer_patter, '%N%', l_comment_line); - - l_source := regexp_replace(srcstr => a_source - ,pattern => gc_annot_comment_pattern - ,replacestr => l_comment_replacer - ,position => l_comment_pos - ,occurrence => 1 - ,modifier => 'm'); - dbms_lob.freetemporary(a_source); - a_source := l_source; - dbms_lob.freetemporary(l_source); - l_comment_pos := l_comment_pos + length(l_comment_replacer); + for i in 1 .. a_source.count loop + l_line := a_source(i); + + -- fast path: skip lines that can't possibly match + -- must contain '--' and '%' to be an annotation comment + if instr(l_line, '--') = 0 or instr(l_line, gc_annotation_qualifier) = 0 then + continue; + end if; + + -- find '--' on the line + l_comment_pos := instr(l_line, '--'); + + -- verify everything before '--' is only spaces/tabs (matches ^ *( |\t)*--) + if trim(replace(substr(l_line, 1, l_comment_pos - 1), chr(9))) is not null then + continue; + end if; + + -- skip '--' and any spaces after it, then check for annotation qualifier '%' + l_comment_pos := l_comment_pos + 2; + -- skip optional spaces between -- and % + while l_comment_pos <= length(l_line) + and substr(l_line, l_comment_pos, 1) = ' ' + loop + l_comment_pos := l_comment_pos + 1; + end loop; + + -- must start with annotation qualifier at this position + if substr(l_line, l_comment_pos, 1) != gc_annotation_qualifier then + continue; + end if; + + -- extract annotation text (from % to end of line, trimmed) + l_comments(i) := trim(substr(l_line, l_comment_pos)); + + -- replace line with placeholder, preserving line number in token + l_comment_replacer := replace(gc_comment_replacer_patter, '%N%', i); + a_source(i) := l_comment_replacer; end loop; - ut_utils.debug_log(a_source); return l_comments; end extract_and_replace_comments; ------------------------------------------------------------ --public definitions ------------------------------------------------------------ - - function parse_object_annotations(a_source clob) return ut_annotations is - l_source clob := a_source; + function parse_object_annotations(a_source dbms_preprocessor.source_lines_t) return ut_annotations is + l_source dbms_preprocessor.source_lines_t := a_source; l_comments tt_comment_list; l_annotations ut_annotations := ut_annotations(); l_result ut_annotations; l_comment_index positive; begin - - l_source := ut_utils.replace_multiline_comments(l_source); - - -- replace all single line comments with {COMMENT#12} element and store it's content for easier processing - -- this call modifies l_source + l_source := ut_utils.replace_multiline_comments(l_source); l_comments := extract_and_replace_comments(l_source); - add_procedure_annotations(l_annotations, l_source, l_comments); - delete_processed_comments(l_comments, l_annotations); --at this point, only the comments not related to procedures are left, so we process them all as top-level @@ -208,28 +217,20 @@ create or replace package body ut_annotation_parser as l_comment_index := l_comments.next(l_comment_index); end loop; - dbms_lob.freetemporary(l_source); - - select value(x) bulk collect into l_result from table(l_annotations) x order by x.position; + select /*+ no_parallel */ value(x) bulk collect into l_result from table(l_annotations) x order by x.position asc; - -- printing out parsed structure for debugging - $if $$ut_trace $then - print_parse_results(l_result); - dbms_output.put_line('Annotations count: ' || l_result.count); - for i in 1 .. l_result.count loop - dbms_output.put_line(xmltype(l_result(i)).getclobval()); - end loop; - $end return l_result; + end parse_object_annotations; function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations is l_processed_lines dbms_preprocessor.source_lines_t; - l_source clob; + l_source dbms_preprocessor.source_lines_t; l_annotations ut_annotations := ut_annotations(); ex_package_is_wrapped exception; pragma exception_init(ex_package_is_wrapped, -24241); - + source_text_is_empty exception; + pragma exception_init(source_text_is_empty, -24236); begin if a_source_lines.count > 0 then --convert to post-processed source clob @@ -240,20 +241,18 @@ create or replace package body ut_annotation_parser as else l_processed_lines := sys.dbms_preprocessor.get_post_processed_source(a_source_lines); end if; - --convert to clob for i in 1..l_processed_lines.count loop - ut_utils.append_to_clob(l_source, replace(l_processed_lines(i), chr(13)||chr(10), chr(10))); + l_source(i) := replace(l_processed_lines(i), chr(13)||chr(10), chr(10)); end loop; --parse annotations l_annotations := parse_object_annotations(l_source); - dbms_lob.freetemporary(l_source); exception - when ex_package_is_wrapped then + when ex_package_is_wrapped or source_text_is_empty then null; end; end if; return l_annotations; end; -end ut_annotation_parser; +end; / diff --git a/source/core/annotations/ut_annotation_parser.pks b/source/core/annotations/ut_annotation_parser.pks index b0a61e576..84d54df81 100644 --- a/source/core/annotations/ut_annotation_parser.pks +++ b/source/core/annotations/ut_annotation_parser.pks @@ -1,10 +1,10 @@ -create or replace package ut_annotation_parser authid current_user as +create or replace noneditionable package ut_annotation_parser authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -29,16 +29,5 @@ create or replace package ut_annotation_parser authid current_user as */ function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations; - - /** - * - * @private - * Parses source code and converts it to annotations - * - * @param a_source_lines ordered lines of source code to be parsed - * @return array containing annotations - */ - function parse_object_annotations(a_source clob) return ut_annotations; - -end ut_annotation_parser; +end; / diff --git a/source/core/annotations/ut_annotations.tps b/source/core/annotations/ut_annotations.tps index 85be05e72..2295dc797 100644 --- a/source/core/annotations/ut_annotations.tps +++ b/source/core/annotations/ut_annotations.tps @@ -1,10 +1,10 @@ -create type ut_annotations +create or replace noneditionable type ut_annotations /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_trigger_annotation_parsing.trg b/source/core/annotations/ut_trigger_annotation_parsing.trg index 437b7742d..60d1fec16 100644 --- a/source/core/annotations/ut_trigger_annotation_parsing.trg +++ b/source/core/annotations/ut_trigger_annotation_parsing.trg @@ -2,6 +2,22 @@ create or replace trigger ut_trigger_annotation_parsing after create or alter or drop on database begin + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ if (ora_dict_obj_owner = UPPER('&&UT3_OWNER') and ora_dict_obj_name = 'UT3_TRIGGER_ALIVE' and ora_dict_obj_type = 'SYNONYM') diff --git a/source/core/annotations/ut_trigger_check.pkb b/source/core/annotations/ut_trigger_check.pkb index e07acd3b2..c9b5172f7 100644 --- a/source/core/annotations/ut_trigger_check.pkb +++ b/source/core/annotations/ut_trigger_check.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_trigger_check is +create or replace noneditionable package body ut_trigger_check is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,9 +22,7 @@ create or replace package body ut_trigger_check is function is_alive return boolean is pragma autonomous_transaction; begin - if not g_is_trigger_live then - execute immediate 'create or replace synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object'; - end if; + execute immediate 'create or replace noneditionable synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object'; return g_is_trigger_live; end; diff --git a/source/core/annotations/ut_trigger_check.pks b/source/core/annotations/ut_trigger_check.pks index c4c27c596..a473c859b 100644 --- a/source/core/annotations/ut_trigger_check.pks +++ b/source/core/annotations/ut_trigger_check.pks @@ -1,10 +1,10 @@ -create or replace package ut_trigger_check authid definer is +create or replace noneditionable package ut_trigger_check authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/dbms_plssqlcode.sql b/source/core/coverage/dbms_plssqlcode.sql index 4bba7780c..1ae287207 100644 --- a/source/core/coverage/dbms_plssqlcode.sql +++ b/source/core/coverage/dbms_plssqlcode.sql @@ -7,7 +7,7 @@ begin select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_BLOCKS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[ - create global temporary table dbmspcc_blocks ( + create table dbmspcc_blocks ( run_id number(38, 0), object_id number(38, 0), block number(38, 0), @@ -21,7 +21,7 @@ begin constraint dbmspcc_blocks_covered_ck check ( covered in ( 0, 1 ) ) enable, constraint dbmspcc_blocks_not_feasible_ck check ( not_feasible in ( 0, 1 ) ) enable, constraint dbmspcc_blocks_pk primary key ( run_id, object_id, block ) using index - ) on commit preserve rows]'; + )]'; end if; end; / @@ -34,13 +34,13 @@ begin select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[ - create global temporary table dbmspcc_runs ( + create table dbmspcc_runs ( run_id number(38, 0), run_comment varchar2(4000 byte), run_owner varchar2(128 byte) constraint dbmspcc_runs_run_owner_nn not null enable, run_timestamp date constraint dbmspcc_runs_run_timestamp_nn not null enable, constraint dbmspcc_runs_pk primary key ( run_id ) using index enable - ) on commit preserve rows]'; + )]'; end if; end; / @@ -53,7 +53,7 @@ begin select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[ - create global temporary table dbmspcc_units ( + create table dbmspcc_units ( run_id number(38, 0), object_id number(38, 0), owner varchar2(128 byte) constraint dbmspcc_units_owner_nn not null enable, @@ -61,7 +61,7 @@ begin type varchar2(12 byte) constraint dbmspcc_units_type_nn not null enable, last_ddl_time date constraint dbmspcc_units_last_ddl_time_nn not null enable, constraint dbmspcc_units_pk primary key ( run_id, object_id ) using index enable - ) on commit preserve rows]'; + )]'; end if; end; / diff --git a/source/core/coverage/ut_coverage.pkb b/source/core/coverage/ut_coverage.pkb index caa75ae51..257d809ed 100644 --- a/source/core/coverage/ut_coverage.pkb +++ b/source/core/coverage/ut_coverage.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage is +create or replace noneditionable package body ut_coverage is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,55 +16,56 @@ create or replace package body ut_coverage is limitations under the License. */ - g_coverage_id tt_coverage_id_arr; - g_develop_mode boolean not null := false; - g_is_started boolean not null := false; + g_develop_mode boolean not null := false; + g_is_started boolean not null := false; + g_coverage_run_id raw(32); procedure set_develop_mode(a_develop_mode in boolean) is - begin - g_develop_mode := a_develop_mode; - end; - - function get_coverage_id(a_coverage_type in varchar2) return integer is - begin - return g_coverage_id(a_coverage_type); - end; + begin + g_develop_mode := a_develop_mode; + end; function is_develop_mode return boolean is - begin - return g_develop_mode; - end; + begin + return g_develop_mode; + end; - function get_cov_sources_sql(a_coverage_options ut_coverage_options, a_skip_objects ut_object_names) return varchar2 is + function get_cov_sources_sql(a_coverage_options ut_coverage_options, a_skip_objects ut_object_names) return varchar2 is l_result varchar2(32767); l_full_name varchar2(32767); l_join_mappings varchar2(32767); l_filters varchar2(32767); l_mappings_cardinality integer := 0; + l_regex_exc_filters varchar2(32767); begin l_result := q'[ with - trigger_source_offsets as ( - select min(s.line) - 1 offset, s.owner, s.name, s.type - from {sources_view} s - where s.type = 'TRIGGER' - {filters} - and (lower(s.text) like '%begin%' or lower(s.text) like '%declare%' or lower(s.text) like '%compound%') - group by s.owner, s.name, s.type - ), sources as ( select /*+ cardinality(f {mappings_cardinality}) */ - {l_full_name} as full_name, s.owner, s.name, - s.line - case when s.type = 'TRIGGER' then o.offset else 0 end as line, + {l_full_name} as full_name, s.owner, s.name, s.type, + s.line + - case + when s.type = 'TRIGGER' + then + /* calculate offset of line number for trigger source in coverage reporting */ + min(case when lower(s.text) like '%begin%' or lower(s.text) like '%declare%' or lower(s.text) like '%compound%' then s.line-1 end) + over (partition by s.owner, s.type, s.name) + else 0 + end as line, s.text from {sources_view} s {join_file_mappings} - left join trigger_source_offsets o - on (s.owner = o.owner and s.name = o.name and s.type = o.type) where s.type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER') + and s.origin_con_id = sys_context('userenv', 'con_id') {filters} + {regex_exc_filters} + and not exists ( + select /*+ cardinality(el {excluded_objects_cardinality})*/ 1 + from table(:l_excluded_objects) el + where s.owner = el.owner and s.name = el.name + ) ), coverage_sources as ( - select full_name, owner, name, line, text, + select full_name, owner, name, type, line, text, case when -- to avoid execution of regexp_like on every line @@ -83,13 +84,17 @@ create or replace package body ut_coverage is end as to_be_skipped from sources s ) - select full_name, owner, name, line, to_be_skipped, text + select /*+ no_parallel */ full_name, owner, name, type, line, to_be_skipped, text from coverage_sources s -- Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter - where (s.owner, s.name) not in ( select /*+ cardinality(el {skipped_objects_cardinality})*/el.owner, el.name from table(:l_skipped_objects) el ) + where not exists ( + select /*+ cardinality(el {skipped_objects_cardinality})*/ 1 + from table(:l_skipped_objects) el + where s.owner = el.owner and s.name = el.name + ) and line > 0 ]'; - + if a_coverage_options.file_mappings is not empty then l_mappings_cardinality := ut_utils.scale_cardinality(cardinality(a_coverage_options.file_mappings)); l_full_name := 'f.file_name'; @@ -98,8 +103,20 @@ create or replace package body ut_coverage is on s.name = f.object_name and s.type = f.object_type and s.owner = f.object_owner'; + elsif coalesce(a_coverage_options.include_schema_expr,a_coverage_options.include_object_expr) is not null then + l_full_name := q'[lower(s.type||' '||s.owner||'.'||s.name)]'; + if a_coverage_options.include_schema_expr is not null then + l_filters := q'[and regexp_like(s.owner,:a_include_schema_expr,'i')]'; + else + l_filters := 'and :a_include_schema_expr is null'; + end if; + if a_coverage_options.include_object_expr is not null then + l_filters := l_filters|| q'[ and regexp_like(s.name,:a_include_object_expr,'i')]'; + else + l_filters := l_filters|| 'and :a_include_object_expr is null'; + end if; else - l_full_name := q'[lower(s.owner||'.'||s.name)]'; + l_full_name := q'[lower(s.type||' '||s.owner||'.'||s.name)]'; l_filters := case when a_coverage_options.include_objects is not empty then ' and (s.owner, s.name) in ( @@ -115,37 +132,67 @@ create or replace package body ut_coverage is end; end if; + + if a_coverage_options.exclude_schema_expr is not null then + l_regex_exc_filters := q'[ and not regexp_like(s.owner,:a_exclude_schema_expr,'i')]'; + else + l_regex_exc_filters := ' and :a_exclude_schema_expr is null '; + end if; + + if a_coverage_options.exclude_object_expr is not null then + l_regex_exc_filters := l_regex_exc_filters||q'[ and not regexp_like(s.name,:a_exclude_obj_expr,'i')]'; + else + l_regex_exc_filters := l_regex_exc_filters||'and :a_exclude_obj_expr is null '; + end if; + + + l_result := replace(l_result, '{sources_view}', ut_metadata.get_source_view_name()); l_result := replace(l_result, '{l_full_name}', l_full_name); l_result := replace(l_result, '{join_file_mappings}', l_join_mappings); l_result := replace(l_result, '{filters}', l_filters); l_result := replace(l_result, '{mappings_cardinality}', l_mappings_cardinality); l_result := replace(l_result, '{skipped_objects_cardinality}', ut_utils.scale_cardinality(cardinality(a_skip_objects))); + l_result := replace(l_result, '{excluded_objects_cardinality}', ut_utils.scale_cardinality(cardinality(coalesce(a_coverage_options.exclude_objects, ut_object_names())))); + l_result := replace(l_result, '{regex_exc_filters}', l_regex_exc_filters); return l_result; end; function get_cov_sources_cursor(a_coverage_options in ut_coverage_options) return sys_refcursor is - l_cursor sys_refcursor; - l_skip_objects ut_object_names; - l_sql varchar2(32767); + l_cursor sys_refcursor; + l_skip_objects ut_object_names; + l_excluded_objects ut_object_names; + l_sql varchar2(32767); begin if not is_develop_mode() then --skip all the utplsql framework objects and all the unit test packages that could potentially be reported by coverage. - l_skip_objects := ut_utils.get_utplsql_objects_list() multiset union all coalesce(a_coverage_options.exclude_objects, ut_object_names()); + l_skip_objects := coalesce( ut_utils.get_utplsql_objects_list() multiset union all ut_suite_manager.get_schema_ut_packages(a_coverage_options.schema_names, a_coverage_options.include_schema_expr) , ut_object_names() ); end if; + --Regex exclusion override the standard exclusion objects. + if a_coverage_options.exclude_schema_expr is null and a_coverage_options.exclude_object_expr is null then + l_excluded_objects := coalesce(a_coverage_options.exclude_objects, ut_object_names()); + end if; + l_sql := get_cov_sources_sql(a_coverage_options, l_skip_objects); ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) ); if a_coverage_options.file_mappings is not empty then - open l_cursor for l_sql using a_coverage_options.file_mappings, l_skip_objects; + open l_cursor for l_sql using a_coverage_options.file_mappings, a_coverage_options.exclude_schema_expr, + a_coverage_options.exclude_object_expr, l_excluded_objects, l_skip_objects; + elsif coalesce(a_coverage_options.include_schema_expr,a_coverage_options.include_object_expr) is not null then + open l_cursor for l_sql using a_coverage_options.include_schema_expr, a_coverage_options.include_object_expr, + a_coverage_options.exclude_schema_expr, a_coverage_options.exclude_object_expr, + l_excluded_objects, l_skip_objects; elsif a_coverage_options.include_objects is not empty then - open l_cursor for l_sql using a_coverage_options.include_objects, a_coverage_options.include_objects, l_skip_objects; + open l_cursor for l_sql using a_coverage_options.include_objects, a_coverage_options.exclude_schema_expr, + a_coverage_options.exclude_object_expr, l_excluded_objects, l_skip_objects; else - open l_cursor for l_sql using a_coverage_options.schema_names, a_coverage_options.schema_names, l_skip_objects; + open l_cursor for l_sql using a_coverage_options.schema_names, a_coverage_options.exclude_schema_expr, + a_coverage_options.exclude_object_expr, l_excluded_objects, l_skip_objects; end if; return l_cursor; end; @@ -177,14 +224,17 @@ create or replace package body ut_coverage is /** * Public functions */ - procedure coverage_start(a_coverage_options ut_coverage_options default null) is + procedure coverage_start(a_coverage_run_id t_coverage_run_id) is l_run_comment varchar2(200) := 'utPLSQL Code coverage run '||ut_utils.to_string(systimestamp); + l_line_coverage_id integer; + l_block_coverage_id integer; begin if not is_develop_mode() and not g_is_started then - ut_coverage_helper_block.coverage_start( l_run_comment, g_coverage_id(gc_block_coverage) ); - ut_coverage_helper_profiler.coverage_start( l_run_comment, g_coverage_id(gc_proftab_coverage) ); - coverage_pause(); + g_coverage_run_id := a_coverage_run_id; + l_line_coverage_id := ut_coverage_helper_profiler.coverage_start( l_run_comment ); + l_block_coverage_id := ut_coverage_helper_block.coverage_start( l_run_comment ); g_is_started := true; + ut_coverage_helper.set_coverage_run_ids(a_coverage_run_id, l_line_coverage_id, l_block_coverage_id); end if; end; @@ -200,84 +250,76 @@ create or replace package body ut_coverage is ut_coverage_helper_profiler.coverage_resume(); end; - procedure mock_coverage_id(a_coverage_id integer,a_coverage_type in varchar2) is - begin - g_develop_mode := true; - g_is_started := true; - g_coverage_id(a_coverage_type) := a_coverage_id; - end; - - procedure mock_coverage_id(a_coverage_id tt_coverage_id_arr) is - begin - g_develop_mode := true; - g_is_started := true; - g_coverage_id := a_coverage_id; - end; - procedure coverage_stop is begin if not is_develop_mode() then g_is_started := false; + g_coverage_run_id := null; ut_coverage_helper_block.coverage_stop(); ut_coverage_helper_profiler.coverage_stop(); - g_is_started := false; end if; end; function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage is l_result_block ut_coverage.t_coverage; l_result_profiler_enrich ut_coverage.t_coverage; - l_object ut_coverage.t_full_name; + l_object ut_coverage.t_object_name; l_line_no binary_integer; + l_coverage_options ut_coverage_options := a_coverage_options; begin --prepare global temp table with sources ut_event_manager.trigger_event('about to populate coverage temp table'); - populate_tmp_table(a_coverage_options); + populate_tmp_table(l_coverage_options); ut_event_manager.trigger_event('coverage temp table populated'); -- Get raw data for both reporters, order is important as tmp table will skip headers and dont populate -- tmp table for block again. - l_result_profiler_enrich:= ut_coverage_profiler.get_coverage_data( a_coverage_options, get_coverage_id(gc_proftab_coverage) ); + l_result_profiler_enrich := ut_coverage_profiler.get_coverage_data( l_coverage_options ); ut_event_manager.trigger_event('profiler coverage data retrieved'); - -- If block coverage available we will use it. - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_result_block := ut_coverage_block.get_coverage_data( a_coverage_options, get_coverage_id(gc_block_coverage) ); - ut_event_manager.trigger_event('block coverage data retrieved'); - - -- Enrich profiler results with some of the block results - l_object := l_result_profiler_enrich.objects.first; - while (l_object is not null) loop - - l_line_no := l_result_profiler_enrich.objects(l_object).lines.first; - - -- to avoid no data found check if we got object in profiler - if l_result_block.objects.exists(l_object) then - while (l_line_no is not null) loop - -- To avoid no data check for object line - if l_result_block.objects(l_object).lines.exists(l_line_no) then - -- enrich line level stats - l_result_profiler_enrich.objects(l_object).lines(l_line_no).partcove := l_result_block.objects(l_object).lines(l_line_no).partcove; - l_result_profiler_enrich.objects(l_object).lines(l_line_no).covered_blocks := l_result_block.objects(l_object).lines(l_line_no).covered_blocks; - l_result_profiler_enrich.objects(l_object).lines(l_line_no).no_blocks := l_result_block.objects(l_object).lines(l_line_no).no_blocks; - -- enrich object level stats - l_result_profiler_enrich.objects(l_object).partcovered_lines := nvl(l_result_profiler_enrich.objects(l_object).partcovered_lines,0) + l_result_block.objects(l_object).lines(l_line_no).partcove; - end if; - --At the end go to next line - l_line_no := l_result_profiler_enrich.objects(l_object).lines.next(l_line_no); - end loop; - --total level stats enrich - l_result_profiler_enrich.partcovered_lines := nvl(l_result_profiler_enrich.partcovered_lines,0) + l_result_profiler_enrich.objects(l_object).partcovered_lines; - -- At the end go to next object - end if; - - l_object := l_result_profiler_enrich.objects.next(l_object); - end loop; - ut_event_manager.trigger_event('coverage data combined'); - $end + l_result_block := ut_coverage_block.get_coverage_data( l_coverage_options ); + ut_event_manager.trigger_event('block coverage data retrieved'); + + -- Enrich profiler results with some of the block results + l_object := l_result_profiler_enrich.objects.first; + while (l_object is not null) loop + + l_line_no := l_result_profiler_enrich.objects(l_object).lines.first; + + -- to avoid no data found check if we got object in profiler + if l_result_block.objects.exists(l_object) then + while (l_line_no is not null) loop + -- To avoid no data check for object line + if l_result_block.objects(l_object).lines.exists(l_line_no) then + -- enrich line level stats + l_result_profiler_enrich.objects(l_object).lines(l_line_no).partcove := l_result_block.objects(l_object).lines(l_line_no).partcove; + l_result_profiler_enrich.objects(l_object).lines(l_line_no).covered_blocks := l_result_block.objects(l_object).lines(l_line_no).covered_blocks; + l_result_profiler_enrich.objects(l_object).lines(l_line_no).no_blocks := l_result_block.objects(l_object).lines(l_line_no).no_blocks; + -- enrich object level stats + l_result_profiler_enrich.objects(l_object).partcovered_lines := nvl(l_result_profiler_enrich.objects(l_object).partcovered_lines,0) + l_result_block.objects(l_object).lines(l_line_no).partcove; + end if; + --At the end go to next line + l_line_no := l_result_profiler_enrich.objects(l_object).lines.next(l_line_no); + end loop; + --total level stats enrich + l_result_profiler_enrich.partcovered_lines := nvl(l_result_profiler_enrich.partcovered_lines,0) + l_result_profiler_enrich.objects(l_object).partcovered_lines; + -- At the end go to next object + end if; + + l_object := l_result_profiler_enrich.objects.next(l_object); + end loop; + ut_event_manager.trigger_event('coverage data combined'); return l_result_profiler_enrich; - end get_coverage_data; + end get_coverage_data; + + function get_coverage_run_id return raw is + begin + if g_coverage_run_id is null then + g_coverage_run_id := sys_guid(); + end if; + return g_coverage_run_id; + end; end; / diff --git a/source/core/coverage/ut_coverage.pks b/source/core/coverage/ut_coverage.pks index 1d87d50c9..f777fde4e 100644 --- a/source/core/coverage/ut_coverage.pks +++ b/source/core/coverage/ut_coverage.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage authid current_user is +create or replace noneditionable package ut_coverage authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,25 +16,21 @@ create or replace package ut_coverage authid current_user is limitations under the License. */ - gc_proftab_coverage constant varchar2(32) := 'proftab'; - gc_block_coverage constant varchar2(32) := 'block'; - - type tt_coverage_id_arr is table of integer index by varchar2(30); + subtype t_coverage_run_id is raw(32) not null; -- total run coverage information - subtype t_full_name is varchar2(4000); - subtype t_object_name is varchar2(250); - - --subtype t_line_executions is binary_integer; + subtype t_object_name is varchar2(257); + subtype t_line_no is binary_integer; type t_line_executions is record( - executions binary_integer - ,partcove binary_integer - ,no_blocks binary_integer + executions binary_integer + ,partcove binary_integer + ,no_blocks binary_integer ,covered_blocks binary_integer); + -- line coverage information indexed by line no. - --type tt_lines is table of t_line_executions index by binary_integer; - type tt_lines is table of t_line_executions index by binary_integer; + type tt_lines is table of t_line_executions index by t_line_no; + --unit coverage information record type t_unit_coverage is record( owner varchar2(128) @@ -50,7 +46,7 @@ create or replace package ut_coverage authid current_user is ,lines tt_lines); -- coverage information indexed by full object name (schema.object) - type tt_program_units is table of t_unit_coverage index by t_full_name; + type tt_program_units is table of t_unit_coverage index by t_object_name; -- total run coverage information type t_coverage is record( @@ -64,21 +60,11 @@ create or replace package ut_coverage authid current_user is ,executions number(38, 0) := 0 ,objects tt_program_units); - function get_coverage_id(a_coverage_type in varchar2) return integer; - procedure set_develop_mode(a_develop_mode in boolean); function is_develop_mode return boolean; - /*** - * Allows overwriting of private global variable g_coverage_id - * Used internally, only for unit testing of the framework only - */ - procedure mock_coverage_id(a_coverage_id integer, a_coverage_type in varchar2); - - procedure mock_coverage_id(a_coverage_id tt_coverage_id_arr); - - procedure coverage_start(a_coverage_options ut_coverage_options default null); + procedure coverage_start(a_coverage_run_id t_coverage_run_id); procedure coverage_stop; @@ -88,5 +74,7 @@ create or replace package ut_coverage authid current_user is function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage; + function get_coverage_run_id return raw; + end; / diff --git a/source/core/coverage/ut_coverage_block.pkb b/source/core/coverage/ut_coverage_block.pkb index c6d0f409d..d6f52d9db 100644 --- a/source/core/coverage/ut_coverage_block.pkb +++ b/source/core/coverage/ut_coverage_block.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_block is +create or replace noneditionable package body ut_coverage_block is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -23,7 +23,7 @@ create or replace package body ut_coverage_block is * Public functions */ - function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage is + function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage is l_line_calls ut_coverage_helper.t_unit_line_calls; l_result ut_coverage.t_coverage; l_new_unit ut_coverage.t_unit_coverage; @@ -32,7 +32,6 @@ create or replace package body ut_coverage_block is l_source_object ut_coverage_helper.t_tmp_table_object; begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor(); loop fetch l_source_objects_crsr @@ -40,7 +39,7 @@ create or replace package body ut_coverage_block is exit when l_source_objects_crsr%notfound; --get coverage data - l_line_calls := ut_coverage_helper_block.get_raw_coverage_data(l_source_object.owner, l_source_object.name, a_coverage_id); + l_line_calls := ut_coverage_helper_block.get_raw_coverage_data(l_source_object, a_coverage_options.coverage_run_id); --if there is coverage, we need to filter out the garbage (badly indicated data) if l_line_calls.count > 0 then --remove lines that should not be indicted as meaningful @@ -151,7 +150,6 @@ create or replace package body ut_coverage_block is end loop; close l_source_objects_crsr; - $end return l_result; end get_coverage_data; diff --git a/source/core/coverage/ut_coverage_block.pks b/source/core/coverage/ut_coverage_block.pks index 26c79317e..68451e1ed 100644 --- a/source/core/coverage/ut_coverage_block.pks +++ b/source/core/coverage/ut_coverage_block.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_block authid current_user is +create or replace noneditionable package ut_coverage_block authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,7 +16,7 @@ create or replace package ut_coverage_block authid current_user is limitations under the License. */ - function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage; + function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage; end; / diff --git a/source/core/coverage/ut_coverage_helper.pkb b/source/core/coverage/ut_coverage_helper.pkb index 12ee9e1f7..555c12fa4 100644 --- a/source/core/coverage/ut_coverage_helper.pkb +++ b/source/core/coverage/ut_coverage_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_helper is +create or replace noneditionable package body ut_coverage_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -35,9 +35,9 @@ create or replace package body ut_coverage_helper is procedure insert_into_tmp_table(a_data t_coverage_sources_tmp_rows) is begin forall i in 1 .. a_data.count - insert into ut_coverage_sources_tmp - (full_name,owner,name,line,text, to_be_skipped) - values(a_data(i).full_name,a_data(i).owner,a_data(i).name,a_data(i).line,a_data(i).text,a_data(i).to_be_skipped); + insert /*+ no_parallel */ into ut_coverage_sources_tmp + (full_name,owner,name,type,line,text,to_be_skipped) + values(a_data(i).full_name,a_data(i).owner,a_data(i).name,a_data(i).type,a_data(i).line,a_data(i).text,a_data(i).to_be_skipped); end; procedure cleanup_tmp_table is @@ -49,7 +49,7 @@ create or replace package body ut_coverage_helper is function is_tmp_table_populated return boolean is l_result integer; begin - select 1 into l_result from ut_coverage_sources_tmp where rownum = 1; + select /*+ no_parallel */ 1 into l_result from ut_coverage_sources_tmp where rownum = 1; return (l_result = 1); exception when no_data_found then @@ -60,12 +60,12 @@ create or replace package body ut_coverage_helper is l_result t_tmp_table_objects_crsr; begin open l_result for - select o.owner, o.name, o.full_name, max(o.line) lines_count, + select /*+ no_parallel */ o.owner, o.name, o.type, o.full_name, max(o.line) as lines_count, cast( collect(decode(to_be_skipped, 'Y', to_char(line))) as ut_varchar2_list - ) to_be_skipped_list + ) as to_be_skipped_list from ut_coverage_sources_tmp o - group by o.owner, o.name, o.full_name; + group by o.owner, o.name, o.type, o.full_name; return l_result; end; @@ -73,7 +73,7 @@ create or replace package body ut_coverage_helper is function get_tmp_table_object_lines(a_owner varchar2, a_object_name varchar2) return ut_varchar2_list is l_result ut_varchar2_list; begin - select rtrim(s.text,chr(10)) text + select /*+ no_parallel */ rtrim(s.text,chr(10)) as text bulk collect into l_result from ut_coverage_sources_tmp s where s.owner = a_owner @@ -83,5 +83,15 @@ create or replace package body ut_coverage_helper is return l_result; end; + procedure set_coverage_run_ids( a_coverage_run_id raw, a_line_coverage_id integer, a_block_coverage_id integer ) is + pragma autonomous_transaction; + begin + insert /*+ no_parallel */ into ut_coverage_runs + ( coverage_run_id, line_coverage_id, block_coverage_id ) + values + ( a_coverage_run_id, a_line_coverage_id, a_block_coverage_id ); + commit; + end; + end; / diff --git a/source/core/coverage/ut_coverage_helper.pks b/source/core/coverage/ut_coverage_helper.pks index 85a54a7ca..3b51bddb3 100644 --- a/source/core/coverage/ut_coverage_helper.pks +++ b/source/core/coverage/ut_coverage_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_helper authid definer is +create or replace noneditionable package ut_coverage_helper authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -32,6 +32,7 @@ create or replace package ut_coverage_helper authid definer is full_name ut_coverage_sources_tmp.full_name%type, owner ut_coverage_sources_tmp.owner%type, name ut_coverage_sources_tmp.name%type, + type ut_coverage_sources_tmp.type%type, line ut_coverage_sources_tmp.line%type, to_be_skipped ut_coverage_sources_tmp.to_be_skipped%type, text ut_coverage_sources_tmp.text%type @@ -42,6 +43,7 @@ create or replace package ut_coverage_helper authid definer is type t_tmp_table_object is record( owner ut_coverage_sources_tmp.owner%type, name ut_coverage_sources_tmp.name%type, + type ut_coverage_sources_tmp.type%type, full_name ut_coverage_sources_tmp.full_name%type, lines_count integer, to_be_skipped_list ut_varchar2_list @@ -59,5 +61,7 @@ create or replace package ut_coverage_helper authid definer is function get_tmp_table_object_lines(a_owner varchar2, a_object_name varchar2) return ut_varchar2_list; + procedure set_coverage_run_ids( a_coverage_run_id raw, a_line_coverage_id integer, a_block_coverage_id integer ); + end; / diff --git a/source/core/coverage/ut_coverage_helper_block.pkb b/source/core/coverage/ut_coverage_helper_block.pkb index fc64c507f..6aa9f6912 100644 --- a/source/core/coverage/ut_coverage_helper_block.pkb +++ b/source/core/coverage/ut_coverage_helper_block.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_helper_block is +create or replace noneditionable package body ut_coverage_helper_block is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,13 +16,6 @@ create or replace package body ut_coverage_helper_block is limitations under the License. */ - type t_proftab_row is record ( - line binary_integer, - calls number(38,0) - ); - - type t_proftab_rows is table of t_proftab_row; - type t_block_row is record( line binary_integer ,blocks binary_integer @@ -30,65 +23,77 @@ create or replace package body ut_coverage_helper_block is type t_block_rows is table of t_block_row; - procedure coverage_start(a_run_comment varchar2, a_coverage_id out integer) is + function coverage_start(a_run_comment varchar2) return integer is begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - a_coverage_id := dbms_plsql_code_coverage.start_coverage(run_comment => a_run_comment); - $else - null; - $end + return dbms_plsql_code_coverage.start_coverage(run_comment => a_run_comment); end; procedure coverage_stop is begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - dbms_plsql_code_coverage.stop_coverage(); - $else - null; - $end + dbms_plsql_code_coverage.stop_coverage(); + exception + when others then + if sqlcode = -08402 then + dbms_output.put_line('Unable to finish gathering coverage with DBMS_PLSQL_CODE_COVERAGE. '); + dbms_output.put_line('Encountered exception `ORA-08402` when calling procedure `DBMS_PLSQL_CODE_COVERAGE.STOP_COVERAGE()`.'); + dbms_output.put_line('Coverage report will only include line-level code-coverage (without branches).'); + dbms_output.put_line('Please reference following issue for details on possible causes: https://github.com/utPLSQL/utPLSQL/issues/1097 '); + end if; end; - function block_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_block_rows is + function block_results(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return t_block_rows is l_coverage_rows t_block_rows; + l_ut_owner varchar2(250) := ut_utils.ut_owner; begin - - select ccb.line as line, - count(ccb.block) as blocks, - sum(ccb.covered) as covered_blocks - bulk collect into l_coverage_rows - from dbmspcc_units ccu - left outer join dbmspcc_blocks ccb - on ccu.run_id = ccb.run_id - and ccu.object_id = ccb.object_id - where ccu.run_id = a_coverage_id - and ccu.owner = a_object_owner - and ccu.name = a_object_name - group by ccb.line - order by 1; - - return l_coverage_rows; + execute immediate q'[ + select /*+ no_parallel */ + line as line, + count(block) as blocks, + sum(covered) as covered_blocks + from (select line, + block, + max(covered) as covered + from dbmspcc_units ccu + join ]'||l_ut_owner||q'[.ut_coverage_runs r + on r.block_coverage_id = ccu.run_id + left join dbmspcc_blocks ccb + on ccu.run_id = ccb.run_id + and ccu.object_id = ccb.object_id + where r.coverage_run_id = :a_coverage_run_id + and ccu.owner = :a_object_owner + and ccu.name = :a_object_name + and ccu.type = :a_object_type + group by ccb.line, ccb.block + ) + group by line + having count(block) > 1 + order by line]' + bulk collect into l_coverage_rows + using + a_coverage_run_id, a_object.owner, + a_object.name, a_object.type; + + return l_coverage_rows; end; - function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is + function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls is l_tmp_data t_block_rows; l_results ut_coverage_helper.t_unit_line_calls; begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_tmp_data := block_results(a_object_owner, a_object_name, a_coverage_id); + l_tmp_data := block_results(a_object, a_coverage_run_id); - for i in 1 .. l_tmp_data.count loop - l_results(l_tmp_data(i).line).blocks := l_tmp_data(i).blocks; - l_results(l_tmp_data(i).line).covered_blocks := l_tmp_data(i).covered_blocks; - l_results(l_tmp_data(i).line).partcovered := case - when (l_tmp_data(i).covered_blocks > 0) and - (l_tmp_data(i).blocks > l_tmp_data(i).covered_blocks) then - 1 - else - 0 - end; - end loop; - $end + for i in 1 .. l_tmp_data.count loop + l_results(l_tmp_data(i).line).blocks := l_tmp_data(i).blocks; + l_results(l_tmp_data(i).line).covered_blocks := l_tmp_data(i).covered_blocks; + l_results(l_tmp_data(i).line).partcovered := + case + when (l_tmp_data(i).covered_blocks > 0) + and (l_tmp_data(i).blocks > l_tmp_data(i).covered_blocks) + then 1 + else 0 + end; + end loop; return l_results; end; end; diff --git a/source/core/coverage/ut_coverage_helper_block.pks b/source/core/coverage/ut_coverage_helper_block.pks index 0afa3ab15..0bef1ebce 100644 --- a/source/core/coverage/ut_coverage_helper_block.pks +++ b/source/core/coverage/ut_coverage_helper_block.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_helper_block authid current_user is +create or replace noneditionable package ut_coverage_helper_block authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,11 +16,11 @@ create or replace package ut_coverage_helper_block authid current_user is limitations under the License. */ - procedure coverage_start(a_run_comment in varchar2,a_coverage_id out integer); + function coverage_start(a_run_comment in varchar2) return integer; procedure coverage_stop; - function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls; + function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls; end; / diff --git a/source/core/coverage/ut_coverage_helper_profiler.pkb b/source/core/coverage/ut_coverage_helper_profiler.pkb index c90a5b36a..f1c9ab921 100644 --- a/source/core/coverage/ut_coverage_helper_profiler.pkb +++ b/source/core/coverage/ut_coverage_helper_profiler.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_helper_profiler is +create or replace noneditionable package body ut_coverage_helper_profiler is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -31,9 +31,11 @@ create or replace package body ut_coverage_helper_profiler is type t_block_rows is table of t_block_row; - procedure coverage_start(a_run_comment varchar2,a_coverage_id out integer) is + function coverage_start(a_run_comment varchar2) return integer is + l_coverage_id integer; begin - dbms_profiler.start_profiler(run_comment => a_run_comment, run_number => a_coverage_id); + dbms_profiler.start_profiler(run_comment => a_run_comment, run_number => l_coverage_id); + return l_coverage_id; end; procedure coverage_pause is @@ -53,10 +55,10 @@ create or replace package body ut_coverage_helper_profiler is dbms_profiler.stop_profiler(); end; - function proftab_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_proftab_rows is + function proftab_results(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return t_proftab_rows is l_coverage_rows t_proftab_rows; begin - select + select /*+ no_parallel */ d.line#, case when sum(d.total_occur) = 0 and sum(d.total_time) > 0 then 1 else sum(d.total_occur) end total_occur bulk collect into l_coverage_rows @@ -64,20 +66,22 @@ create or replace package body ut_coverage_helper_profiler is join plsql_profiler_data d on u.runid = d.runid and u.unit_number = d.unit_number - where u.runid = a_coverage_id - and u.unit_owner = a_object_owner - and u.unit_name = a_object_name - and u.unit_type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER') + join ut_coverage_runs r + on r.line_coverage_id = u.runid + where r.coverage_run_id = a_coverage_run_id + and u.unit_owner = a_object.owner + and u.unit_name = a_object.name + and u.unit_type = a_object.type group by d.line#; - + return l_coverage_rows; end; - function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is + function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls is l_tmp_data t_proftab_rows; l_results ut_coverage_helper.t_unit_line_calls; begin - l_tmp_data := proftab_results(a_object_owner, a_object_name, a_coverage_id); + l_tmp_data := proftab_results(a_object, a_coverage_run_id); for i in 1 .. l_tmp_data.count loop l_results(l_tmp_data(i).line).calls := l_tmp_data(i).calls; diff --git a/source/core/coverage/ut_coverage_helper_profiler.pks b/source/core/coverage/ut_coverage_helper_profiler.pks index 9345f4b88..841235080 100644 --- a/source/core/coverage/ut_coverage_helper_profiler.pks +++ b/source/core/coverage/ut_coverage_helper_profiler.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_helper_profiler authid definer is +create or replace noneditionable package ut_coverage_helper_profiler authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,7 +16,7 @@ create or replace package ut_coverage_helper_profiler authid definer is limitations under the License. */ - procedure coverage_start(a_run_comment in varchar2,a_coverage_id out integer); + function coverage_start(a_run_comment in varchar2) return integer; procedure coverage_stop; @@ -24,7 +24,7 @@ create or replace package ut_coverage_helper_profiler authid definer is procedure coverage_resume; - function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls; + function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls; end; / diff --git a/source/core/coverage/ut_coverage_profiler.pkb b/source/core/coverage/ut_coverage_profiler.pkb index 160e2dd41..1bd037083 100644 --- a/source/core/coverage/ut_coverage_profiler.pkb +++ b/source/core/coverage/ut_coverage_profiler.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_profiler is +create or replace noneditionable package body ut_coverage_profiler is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -19,7 +19,7 @@ create or replace package body ut_coverage_profiler is /** * Public functions */ - function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage is + function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage is l_line_calls ut_coverage_helper.t_unit_line_calls; l_result ut_coverage.t_coverage; l_new_unit ut_coverage.t_unit_coverage; @@ -34,7 +34,7 @@ create or replace package body ut_coverage_profiler is exit when l_source_objects_crsr%notfound; --get coverage data - l_line_calls := ut_coverage_helper_profiler.get_raw_coverage_data( l_source_object.owner, l_source_object.name, a_coverage_id); + l_line_calls := ut_coverage_helper_profiler.get_raw_coverage_data( l_source_object, a_coverage_options.coverage_run_id); --if there is coverage, we need to filter out the garbage (badly indicated data from dbms_profiler) if l_line_calls.count > 0 then diff --git a/source/core/coverage/ut_coverage_profiler.pks b/source/core/coverage/ut_coverage_profiler.pks index 8e671f899..4cdab2ae1 100644 --- a/source/core/coverage/ut_coverage_profiler.pks +++ b/source/core/coverage/ut_coverage_profiler.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_profiler authid current_user is +create or replace noneditionable package ut_coverage_profiler authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,7 +16,7 @@ create or replace package ut_coverage_profiler authid current_user is limitations under the License. */ - function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage; + function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage; end; / diff --git a/source/core/coverage/ut_coverage_reporter_base.tpb b/source/core/coverage/ut_coverage_reporter_base.tpb index 5067f9221..70d27afc3 100644 --- a/source/core/coverage/ut_coverage_reporter_base.tpb +++ b/source/core/coverage/ut_coverage_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_reporter_base is +create or replace noneditionable type body ut_coverage_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -19,7 +19,8 @@ create or replace type body ut_coverage_reporter_base is overriding final member procedure before_calling_run(self in out nocopy ut_coverage_reporter_base, a_run ut_run) as begin (self as ut_output_reporter_base).before_calling_run(a_run); - ut_coverage.coverage_start(a_coverage_options => a_run.coverage_options); + ut_coverage.coverage_start(a_coverage_run_id => a_run.coverage_options.coverage_run_id); + ut_coverage.coverage_pause(); end; overriding final member procedure before_calling_before_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is @@ -85,5 +86,28 @@ create or replace type body ut_coverage_reporter_base is ut_coverage.coverage_pause(); end; + final member function get_report( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is + l_reporter ut_coverage_reporter_base := self; + begin + ut_coverage_helper.cleanup_tmp_table(); + (l_reporter as ut_output_reporter_base).before_calling_run(null); + l_reporter.after_calling_run( ut_run( a_coverage_options => a_coverage_options, a_client_character_set => a_client_character_set ) ); + for i in (select /*+ no_parallel */ x.text from table(l_reporter.get_lines(1, 1)) x ) loop + pipe row (i.text); + end loop; + return; + end; + + final member function get_report_cursor( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return sys_refcursor is + l_reporter ut_coverage_reporter_base := self; + l_result sys_refcursor; + begin + ut_coverage_helper.cleanup_tmp_table(); + (l_reporter as ut_output_reporter_base).before_calling_run(null); + l_reporter.after_calling_run( ut_run( a_coverage_options => a_coverage_options, a_client_character_set => a_client_character_set ) ); + open l_result for select /*+ no_parallel */ x.text from table(l_reporter.get_lines(1, 1)) x; + return l_result; + end; + end; / diff --git a/source/core/coverage/ut_coverage_reporter_base.tps b/source/core/coverage/ut_coverage_reporter_base.tps index 2b9d1c625..3de89e8bb 100644 --- a/source/core/coverage/ut_coverage_reporter_base.tps +++ b/source/core/coverage/ut_coverage_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_reporter_base under ut_output_reporter_base( +create or replace noneditionable type ut_coverage_reporter_base under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -36,8 +36,9 @@ create or replace type ut_coverage_reporter_base under ut_output_reporter_base( overriding final member procedure after_calling_after_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), overriding final member procedure before_calling_after_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_after_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) - + overriding final member procedure after_calling_after_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), + final member function get_report( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined, + final member function get_report_cursor( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return sys_refcursor ) not final not instantiable / diff --git a/source/core/coverage/ut_coverage_runs.sql b/source/core/coverage/ut_coverage_runs.sql new file mode 100644 index 000000000..78230240d --- /dev/null +++ b/source/core/coverage/ut_coverage_runs.sql @@ -0,0 +1,20 @@ +declare + l_tab_exist number; +begin + select count(*) into l_tab_exist + from all_tables + where table_name = 'UT_COVERAGE_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA'); + if l_tab_exist = 0 then + execute immediate q'[create table ut_coverage_runs + ( + coverage_run_id raw(32) not null, + line_coverage_id number(38,0) unique not null, + block_coverage_id number(38,0) unique, + constraint ut_coverage_runs primary key (coverage_run_id, line_coverage_id) + ) organization index ]'; + execute immediate q'[comment on table ut_coverage_runs is + 'Map of block and line coverage runs for a test-run']'; + dbms_output.put_line('UT_COVERAGE_RUNS table created'); + end if; +end; +/ diff --git a/source/core/coverage/ut_coverage_sources_tmp.sql b/source/core/coverage/ut_coverage_sources_tmp.sql index f53283dcd..90fe38171 100644 --- a/source/core/coverage/ut_coverage_sources_tmp.sql +++ b/source/core/coverage/ut_coverage_sources_tmp.sql @@ -1,9 +1,9 @@ create global temporary table ut_coverage_sources_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -15,10 +15,11 @@ create global temporary table ut_coverage_sources_tmp( full_name varchar2(4000), owner varchar2(250), name varchar2(250), + type varchar2(250), line number(38,0), to_be_skipped varchar2(1), text varchar2(4000), - constraint ut_coverage_sources_tmp_pk primary key (owner,name,line) + constraint ut_coverage_sources_tmp_pk primary key (owner,name,type,line) ) on commit preserve rows; --is this needed? diff --git a/source/core/events/ut_event_item.tps b/source/core/events/ut_event_item.tps index efec940f5..28391a8d2 100644 --- a/source/core/events/ut_event_item.tps +++ b/source/core/events/ut_event_item.tps @@ -1,10 +1,10 @@ -create or replace type ut_event_item authid current_user as object ( +create or replace noneditionable type ut_event_item authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/events/ut_event_listener.tps b/source/core/events/ut_event_listener.tps index 71ee16a0f..c16d00065 100644 --- a/source/core/events/ut_event_listener.tps +++ b/source/core/events/ut_event_listener.tps @@ -1,10 +1,10 @@ -create or replace type ut_event_listener authid current_user as object ( +create or replace noneditionable type ut_event_listener authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/events/ut_event_manager.pkb b/source/core/events/ut_event_manager.pkb index 039eb43a0..bbc342a1f 100644 --- a/source/core/events/ut_event_manager.pkb +++ b/source/core/events/ut_event_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_event_manager as +create or replace noneditionable package body ut_event_manager as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/events/ut_event_manager.pks b/source/core/events/ut_event_manager.pks index f67bd0f4d..d6480b83f 100644 --- a/source/core/events/ut_event_manager.pks +++ b/source/core/events/ut_event_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_event_manager authid current_user as +create or replace noneditionable package ut_event_manager authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_buffer_base.tpb b/source/core/output_buffers/ut_output_buffer_base.tpb index 018250e4b..6bbb00b4b 100644 --- a/source/core/output_buffers/ut_output_buffer_base.tpb +++ b/source/core/output_buffers/ut_output_buffer_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_buffer_base is +create or replace noneditionable type body ut_output_buffer_base is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,33 +18,110 @@ create or replace type body ut_output_buffer_base is member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null) is pragma autonomous_transaction; - l_exists int; begin cleanup_buffer(); self.self_type := coalesce(a_self_type,self.self_type); self.output_id := coalesce(a_output_id, self.output_id, sys_guid()); self.start_date := coalesce(self.start_date, sysdate); - self.last_message_id := 0; - select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id; - if ( l_exists > 0 ) then - update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id; - else - insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date); - end if; + merge /*+ no_parallel */ into ut_output_buffer_info_tmp dst + using (select 1 from dual) src + on (dst.output_id = self.output_id) + when matched then + update + set dst.start_date = self.start_date + when not matched then + insert (output_id, start_date) + values (self.output_id, self.start_date); commit; + dbms_lock.allocate_unique( self.output_id, self.lock_handle); self.is_closed := 0; end; - member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is + member procedure lock_buffer(a_timeout_sec number := null) is + l_status integer; + begin + l_status := dbms_lock.request( self.lock_handle, dbms_lock.x_mode, coalesce(a_timeout_sec, 0.1), false ); + if l_status != 0 then + raise_application_error(-20000, 'Cannot allocate lock for output buffer of reporter. lock request status = '||l_status||', lock handle = '||self.lock_handle||', self.output_id ='||self.output_id); + end if; + end; + + member procedure close(self in out nocopy ut_output_buffer_base) is + l_status integer; + begin + l_status := dbms_lock.release( self.lock_handle ); + if l_status != 0 then + raise_application_error(-20000, 'Cannot release lock for output buffer of reporter. Lock_handle = '||self.lock_handle||' status = '||l_status); + end if; + self.is_closed := 1; + end; + + + member procedure remove_buffer_info(self in ut_output_buffer_base) is + pragma autonomous_transaction; + begin + delete from ut_output_buffer_info_tmp a + where a.output_id = self.output_id; + commit; + end; + + member function timeout_producer_not_started( a_producer_started boolean, a_already_waited_sec number, a_init_wait_sec number ) return boolean + is + l_result boolean := false; + begin + if not a_producer_started and a_already_waited_sec >= a_init_wait_sec then + if a_init_wait_sec > 0 then + self.remove_buffer_info(); + raise_application_error( + ut_utils.gc_out_buffer_timeout, + 'Timeout occurred while waiting for report data producer to start. Waited for: '||ut_utils.to_string( a_already_waited_sec )||' seconds.' + ); + else + l_result := true; + end if; + end if; + return l_result; + end; + + member function timeout_producer_not_finished(a_producer_finished boolean, a_already_waited_sec number, a_timeout_sec number) return boolean + is + l_result boolean := false; + begin + if not a_producer_finished and a_timeout_sec is not null and a_already_waited_sec >= a_timeout_sec then + if a_timeout_sec > 0 then + self.remove_buffer_info(); + raise_application_error( + ut_utils.gc_out_buffer_timeout, + 'Timeout occurred while waiting for more data from producer. Waited for: '||ut_utils.to_string( a_already_waited_sec )||' seconds.' + ); + else + l_result := true; + end if; + end if; + return l_result; + end; + + member function get_lock_status return integer is + l_result integer; + l_release_status integer; + begin + l_result := dbms_lock.request( self.lock_handle, dbms_lock.s_mode, 0, false ); + if l_result = 0 then + l_release_status := dbms_lock.release( self.lock_handle ); + end if; + return l_result; + end; + + member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor is l_lines sys_refcursor; begin open l_lines for - select text, item_type + select /*+ no_parallel */ text, item_type from table(self.get_lines(a_initial_timeout, a_timeout_sec)); return l_lines; end; - member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) is + member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout number := null, a_timeout_sec number := null) is l_data sys_refcursor; l_clob clob; l_item_type varchar2(32767); @@ -54,16 +131,20 @@ create or replace type body ut_output_buffer_base is loop fetch l_data into l_clob, l_item_type; exit when l_data%notfound; - l_lines := ut_utils.clob_to_table(l_clob); - for i in 1 .. l_lines.count loop - dbms_output.put_line(l_lines(i)); - end loop; + if dbms_lob.getlength(l_clob) > 32767 then + l_lines := ut_utils.clob_to_table(l_clob); + for i in 1 .. l_lines.count loop + dbms_output.put_line(l_lines(i)); + end loop; + else + dbms_output.put_line(l_clob); + end if; end loop; close l_data; end; member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null) is - gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours + gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24 * 5); -- 5 days l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24); l_max_retention_date date := sysdate - l_retention_days; pragma autonomous_transaction; diff --git a/source/core/output_buffers/ut_output_buffer_base.tps b/source/core/output_buffers/ut_output_buffer_base.tps index 745692f38..e2d1c6731 100644 --- a/source/core/output_buffers/ut_output_buffer_base.tps +++ b/source/core/output_buffers/ut_output_buffer_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_buffer_base force authid definer as object( +create or replace noneditionable type ut_output_buffer_base force authid definer as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -19,16 +19,21 @@ create or replace type ut_output_buffer_base force authid definer as object( output_id raw(32), is_closed number(1,0), start_date date, - last_message_id number(38,0), + lock_handle varchar2(30 byte), self_type varchar2(250 byte), member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null), - member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, - member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null), + member procedure lock_buffer(a_timeout_sec number := null), + member function timeout_producer_not_started( a_producer_started boolean, a_already_waited_sec number, a_init_wait_sec number ) return boolean, + member function timeout_producer_not_finished(a_producer_finished boolean, a_already_waited_sec number, a_timeout_sec number) return boolean, + member function get_lock_status return integer, + member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor, + member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout number := null, a_timeout_sec number := null), member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null), - not instantiable member procedure close(self in out nocopy ut_output_buffer_base), + member procedure remove_buffer_info(self in ut_output_buffer_base), + member procedure close(self in out nocopy ut_output_buffer_base), not instantiable member procedure send_line(self in out nocopy ut_output_buffer_base, a_text varchar2, a_item_type varchar2 := null), not instantiable member procedure send_lines(self in out nocopy ut_output_buffer_base, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), not instantiable member procedure send_clob(self in out nocopy ut_output_buffer_base, a_text clob, a_item_type varchar2 := null), - not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined + not instantiable member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined ) not final not instantiable / diff --git a/source/core/output_buffers/ut_output_buffer_info_tmp.sql b/source/core/output_buffers/ut_output_buffer_info_tmp.sql index ec09619d2..b8bb10095 100644 --- a/source/core/output_buffers/ut_output_buffer_info_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_info_tmp.sql @@ -1,9 +1,9 @@ create table ut_output_buffer_info_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/output_buffers/ut_output_buffer_tmp.sql b/source/core/output_buffers/ut_output_buffer_tmp.sql index 49fefa24d..dc4c5043c 100644 --- a/source/core/output_buffers/ut_output_buffer_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_tmp.sql @@ -1,9 +1,9 @@ create table ut_output_buffer_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -21,12 +21,10 @@ create table ut_output_buffer_tmp( message_id number(38,0) not null, text varchar2(4000), item_type varchar2(1000), - is_finished number(1,0) default 0 not null, constraint ut_output_buffer_tmp_pk primary key(output_id, message_id), - constraint ut_output_buffer_tmp_ck check( - is_finished = 0 and (text is not null or item_type is not null ) - or is_finished = 1 and text is null and item_type is null ), + constraint ut_output_buffer_tmp_ck check( text is not null or item_type is not null ), constraint ut_output_buffer_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade ) organization index nologging initrans 100 overflow nologging initrans 100; +create sequence ut_output_buffer_tmp_seq cache 20; diff --git a/source/core/output_buffers/ut_output_bulk_buffer.tpb b/source/core/output_buffers/ut_output_bulk_buffer.tpb new file mode 100644 index 000000000..60efda708 --- /dev/null +++ b/source/core/output_buffers/ut_output_bulk_buffer.tpb @@ -0,0 +1,160 @@ +create or replace noneditionable type body ut_output_bulk_buffer is + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_output_bulk_buffer(self in out nocopy ut_output_bulk_buffer, a_output_id raw := null) return self as result is + begin + self.init(a_output_id, $$plsql_unit); + return; + end; + + overriding member procedure send_line(self in out nocopy ut_output_bulk_buffer, a_text varchar2, a_item_type varchar2 := null) is + pragma autonomous_transaction; + begin + if a_text is not null or a_item_type is not null then + if length(a_text) > ut_utils.gc_max_storage_varchar2_len then + self.send_lines( + ut_utils.convert_collection( + ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len) + ), + a_item_type + ); + else + insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); + end if; + commit; + end if; + end; + + overriding member procedure send_lines(self in out nocopy ut_output_bulk_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is + pragma autonomous_transaction; + begin + insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) + select /*+ no_parallel */ self.output_id, ut_output_buffer_tmp_seq.nextval, t.column_value, a_item_type + from table(a_text_list) t + where t.column_value is not null or a_item_type is not null; + commit; + end; + + overriding member procedure send_clob(self in out nocopy ut_output_bulk_buffer, a_text clob, a_item_type varchar2 := null) is + pragma autonomous_transaction; + begin + if a_text is not null and a_text != empty_clob() or a_item_type is not null then + if length(a_text) > ut_utils.gc_max_storage_varchar2_len then + self.send_lines( + ut_utils.convert_collection( + ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len) + ), + a_item_type + ); + else + insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); + end if; + commit; + end if; + end; + + overriding member procedure lines_to_dbms_output(self in ut_output_bulk_buffer, a_initial_timeout number := null, a_timeout_sec number := null) is + l_data sys_refcursor; + l_text ut_varchar2_rows; + l_item_type ut_varchar2_rows; + begin + l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); + loop + fetch l_data bulk collect into l_text, l_item_type limit 10000; + for idx in 1 .. l_text.count loop + dbms_output.put_line(l_text(idx)); + end loop; + exit when l_data%notfound; + end loop; + close l_data; + self.remove_buffer_info(); + end; + + overriding member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor is + lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); + l_already_waited_sec number(10,2) := 0; + l_sleep_time number(2,1); + l_exists integer; + l_finished boolean := false; + l_data_produced boolean := false; + l_producer_active boolean := false; + l_producer_started boolean := false; + l_producer_finished boolean := false; + l_results sys_refcursor; + begin + + while not l_finished loop + + if not l_data_produced then + select /*+ no_parallel */ count(1) into l_exists + from ut_output_buffer_tmp o + where o.output_id = self.output_id and rownum = 1; + l_data_produced := (l_exists = 1); + end if; + + l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; + l_producer_active := (self.get_lock_status() <> 0); + l_producer_started := (l_producer_active or l_data_produced ) or l_producer_started; + l_producer_finished := (l_producer_started and not l_producer_active) or l_producer_finished; + l_finished := + self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) + or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) + or l_producer_finished; + + dbms_session.sleep(l_sleep_time); + l_already_waited_sec := l_already_waited_sec + l_sleep_time; + end loop; + + open l_results for + select /*+ no_parallel */ o.text, o.item_type + from ut_output_buffer_tmp o + where o.output_id = self.output_id + and o.text is not null + order by o.output_id, o.message_id; + + return l_results; + + end; + + /* Important note. + This function code is almost duplicated between two types for performance reasons. + The pipe row clause is much faster on VARCHAR2 then it is on clob. + That is the key reason for two implementations. + */ + overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined is + l_data sys_refcursor; + l_text ut_varchar2_rows; + l_item_type ut_varchar2_rows; + begin + l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); + loop + fetch l_data bulk collect into l_text, l_item_type limit 10000; + for idx in 1 .. l_text.count loop + pipe row( ut_output_data_row(l_text(idx), l_item_type(idx)) ); + end loop; + exit when l_data%notfound; + end loop; + close l_data; + self.remove_buffer_info(); + return; + end; + +end; +/ diff --git a/source/core/output_buffers/ut_output_bulk_buffer.tps b/source/core/output_buffers/ut_output_bulk_buffer.tps new file mode 100644 index 000000000..7534e8fa8 --- /dev/null +++ b/source/core/output_buffers/ut_output_bulk_buffer.tps @@ -0,0 +1,27 @@ +create or replace noneditionable type ut_output_bulk_buffer under ut_output_buffer_base ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_output_bulk_buffer(self in out nocopy ut_output_bulk_buffer, a_output_id raw := null) return self as result, + overriding member procedure send_line(self in out nocopy ut_output_bulk_buffer, a_text varchar2, a_item_type varchar2 := null), + overriding member procedure send_lines(self in out nocopy ut_output_bulk_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), + overriding member procedure send_clob(self in out nocopy ut_output_bulk_buffer, a_text clob, a_item_type varchar2 := null), + overriding member procedure lines_to_dbms_output(self in ut_output_bulk_buffer, a_initial_timeout number := null, a_timeout_sec number := null), + overriding member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor, + overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined +) not final +/ diff --git a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql index 48cfe6fde..b832e68c7 100644 --- a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql +++ b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql @@ -6,9 +6,9 @@ begin v_table_sql := 'create table ut_output_clob_buffer_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -26,11 +26,8 @@ begin message_id number(38,0) not null, text clob, item_type varchar2(1000), - is_finished number(1,0) default 0 not null, constraint ut_output_clob_buffer_tmp_pk primary key(output_id, message_id), - constraint ut_output_clob_buffer_tmp_ck check( - is_finished = 0 and (text is not null or item_type is not null ) - or is_finished = 1 and text is null and item_type is null ), + constraint ut_output_clob_buffer_tmp_ck check( text is not null or item_type is not null ), constraint ut_output_clob_buffer_tmp_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade ) nologging initrans 100 '; @@ -45,3 +42,5 @@ begin end; end; / + +create sequence ut_output_clob_buffer_tmp_seq cache 20; diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tpb b/source/core/output_buffers/ut_output_clob_table_buffer.tpb index 8c2825151..c79e90510 100644 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tpb +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_clob_table_buffer is +create or replace noneditionable type body ut_output_clob_table_buffer is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,23 +22,12 @@ create or replace type body ut_output_clob_table_buffer is return; end; - overriding member procedure close(self in out nocopy ut_output_clob_table_buffer) is - pragma autonomous_transaction; - begin - self.last_message_id := self.last_message_id + 1; - insert into ut_output_clob_buffer_tmp(output_id, message_id, is_finished) - values (self.output_id, self.last_message_id, 1); - commit; - self.is_closed := 1; - end; - overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null) is pragma autonomous_transaction; begin if a_text is not null or a_item_type is not null then - self.last_message_id := self.last_message_id + 1; - insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, self.last_message_id, a_text, a_item_type); + insert /*+ no_parallel */ into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, ut_output_clob_buffer_tmp_seq.nextval, a_text, a_item_type); end if; commit; end; @@ -46,11 +35,10 @@ create or replace type body ut_output_clob_table_buffer is overriding member procedure send_lines(self in out nocopy ut_output_clob_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is pragma autonomous_transaction; begin - insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) - select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type + insert /*+ no_parallel */ into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) + select /*+ no_parallel */ self.output_id, ut_output_clob_buffer_tmp_seq.nextval, t.column_value, a_item_type from table(a_text_list) t where t.column_value is not null or a_item_type is not null; - self.last_message_id := self.last_message_id + SQL%rowcount; commit; end; @@ -58,98 +46,81 @@ create or replace type body ut_output_clob_table_buffer is pragma autonomous_transaction; begin if a_text is not null and a_text != empty_clob() or a_item_type is not null then - self.last_message_id := self.last_message_id + 1; - insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, self.last_message_id, a_text, a_item_type); + insert /*+ no_parallel */ into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, ut_output_clob_buffer_tmp_seq.nextval, a_text, a_item_type); end if; commit; end; - overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is - type t_rowid_tab is table of urowid; - l_message_rowids t_rowid_tab; - l_buffer_data ut_output_data_rows; - l_finished_flags ut_integer_list; - l_already_waited_for number(10,2) := 0; - l_finished boolean := false; - lc_init_wait_sec constant naturaln := coalesce(a_initial_timeout, 60 ); -- 1 minute - lc_max_wait_sec constant naturaln := coalesce(a_timeout_sec, 60 * 60 * 4); -- 4 hours - l_wait_for integer := lc_init_wait_sec; - lc_short_sleep_time constant number(1,1) := 0.1; --sleep for 100 ms between checks - lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long - lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec - l_sleep_time number(2,1) := lc_short_sleep_time; - lc_bulk_limit constant integer := 5000; - l_max_message_id integer := lc_bulk_limit; - - procedure remove_read_data(a_message_rowids t_rowid_tab) is - pragma autonomous_transaction; + overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined is + lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); + l_buffer_rowids ut_varchar2_rows; + l_buffer_data ut_output_data_rows; + l_already_waited_sec number(10,2) := 0; + l_finished boolean := false; + l_sleep_time number(2,1); + l_lock_status integer; + l_producer_started boolean := false; + l_producer_finished boolean := false; + procedure get_data_from_buffer_table( + a_buffer_data out nocopy ut_output_data_rows, + a_buffer_rowids out nocopy ut_varchar2_rows + ) is + lc_bulk_limit constant integer := 5000; begin - forall i in 1 .. a_message_rowids.count - delete from ut_output_clob_buffer_tmp a - where rowid = a_message_rowids(i); - commit; + with ordered_buffer as ( + select /*+ no_parallel index(a) */ ut_output_data_row(a.text, a.item_type), rowidtochar(a.rowid) + from ut_output_clob_buffer_tmp a + where a.output_id = self.output_id + and a.message_id <= (select min(message_id) from ut_output_clob_buffer_tmp o where o.output_id = self.output_id) + lc_bulk_limit + order by a.message_id + ) + select /*+ no_parallel */ b.* + bulk collect into a_buffer_data, a_buffer_rowids + from ordered_buffer b; end; - procedure remove_buffer_info is - pragma autonomous_transaction; + procedure remove_read_data(a_buffer_rowids ut_varchar2_rows) is + pragma autonomous_transaction; begin - delete from ut_output_buffer_info_tmp a - where a.output_id = self.output_id; + forall i in 1 .. a_buffer_rowids.count + delete from ut_output_clob_buffer_tmp a + where rowid = chartorowid(a_buffer_rowids(i)); commit; end; - begin + begin while not l_finished loop - with ordered_buffer as ( - select /*+ index(a) */ a.rowid, ut_output_data_row(a.text, a.item_type), is_finished - from ut_output_clob_buffer_tmp a - where a.output_id = self.output_id - and a.message_id <= l_max_message_id - order by a.message_id - ) - select b.* - bulk collect into l_message_rowids, l_buffer_data, l_finished_flags - from ordered_buffer b; - --nothing fetched from output, wait and try again - if l_buffer_data.count = 0 then - $if dbms_db_version.version >= 18 $then - dbms_session.sleep(l_sleep_time); - $else - dbms_lock.sleep(l_sleep_time); - $end - l_already_waited_for := l_already_waited_for + l_sleep_time; - if l_already_waited_for > lc_long_wait_time then - l_sleep_time := lc_long_sleep_time; - end if; - else - --reset wait time - -- we wait lc_max_wait_sec for new message - l_wait_for := lc_max_wait_sec; - l_already_waited_for := 0; - l_sleep_time := lc_short_sleep_time; + l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; + l_lock_status := self.get_lock_status(); + get_data_from_buffer_table( l_buffer_data, l_buffer_rowids ); + + if l_buffer_data.count > 0 then + l_already_waited_sec := 0; for i in 1 .. l_buffer_data.count loop if l_buffer_data(i).text is not null then - pipe row(l_buffer_data(i)); - elsif l_finished_flags(i) = 1 then - l_finished := true; - exit; + pipe row( l_buffer_data(i) ); end if; end loop; - remove_read_data(l_message_rowids); - l_max_message_id := l_max_message_id + lc_bulk_limit; - end if; - if l_finished or l_already_waited_for >= l_wait_for then - remove_buffer_info(); - if l_already_waited_for > 0 and l_already_waited_for >= l_wait_for then - raise_application_error( - ut_utils.gc_out_buffer_timeout, - 'Timeout occurred while waiting for output data. Waited for: '||l_already_waited_for||' seconds.' - ); - end if; + remove_read_data(l_buffer_rowids); + else + --nothing fetched from output, wait. + dbms_session.sleep(l_sleep_time); + l_already_waited_sec := l_already_waited_sec + l_sleep_time; end if; + + l_producer_started := (l_lock_status <> 0 or l_buffer_data.count > 0) or l_producer_started; + l_producer_finished := (l_producer_started and l_lock_status = 0 and l_buffer_data.count = 0) or l_producer_finished; + + l_finished := + self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) + or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) + or l_producer_finished; + end loop; + + self.remove_buffer_info(); return; end; diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tps b/source/core/output_buffers/ut_output_clob_table_buffer.tps index 2eb3640b0..22d6ac227 100644 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tps +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_clob_table_buffer under ut_output_buffer_base ( +create or replace noneditionable type ut_output_clob_table_buffer under ut_output_buffer_base ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,7 +20,6 @@ create or replace type ut_output_clob_table_buffer under ut_output_buffer_base ( overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null), overriding member procedure send_lines(self in out nocopy ut_output_clob_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), overriding member procedure send_clob(self in out nocopy ut_output_clob_table_buffer, a_text clob, a_item_type varchar2 := null), - overriding member procedure close(self in out nocopy ut_output_clob_table_buffer), - overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined + overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined ) not final / diff --git a/source/core/output_buffers/ut_output_data_row.tps b/source/core/output_buffers/ut_output_data_row.tps index b0f5efe91..a8f0743ee 100644 --- a/source/core/output_buffers/ut_output_data_row.tps +++ b/source/core/output_buffers/ut_output_data_row.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_data_row as object ( +create or replace noneditionable type ut_output_data_row as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_data_rows.tps b/source/core/output_buffers/ut_output_data_rows.tps index 1918f0c81..6067e0d3b 100644 --- a/source/core/output_buffers/ut_output_data_rows.tps +++ b/source/core/output_buffers/ut_output_data_rows.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_data_rows as +create or replace noneditionable type ut_output_data_rows as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_table_buffer.tpb b/source/core/output_buffers/ut_output_table_buffer.tpb index e3f869b22..2edabe58c 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tpb +++ b/source/core/output_buffers/ut_output_table_buffer.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_table_buffer is +create or replace noneditionable type body ut_output_table_buffer is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,21 +22,11 @@ create or replace type body ut_output_table_buffer is return; end; - overriding member procedure close(self in out nocopy ut_output_table_buffer) is - pragma autonomous_transaction; - begin - self.last_message_id := self.last_message_id + 1; - insert into ut_output_buffer_tmp(output_id, message_id, is_finished) - values (self.output_id, self.last_message_id, 1); - commit; - self.is_closed := 1; - end; - overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null) is pragma autonomous_transaction; begin if a_text is not null or a_item_type is not null then - if length(a_text) > ut_utils.gc_max_storage_varchar2_len then + if lengthb(a_text) > ut_utils.gc_max_storage_varchar2_len then self.send_lines( ut_utils.convert_collection( ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len) @@ -44,9 +34,8 @@ create or replace type body ut_output_table_buffer is a_item_type ); else - self.last_message_id := self.last_message_id + 1; - insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, self.last_message_id, a_text, a_item_type); + insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); end if; commit; end if; @@ -55,11 +44,10 @@ create or replace type body ut_output_table_buffer is overriding member procedure send_lines(self in out nocopy ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is pragma autonomous_transaction; begin - insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) - select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type + insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) + select /*+ no_parallel */ self.output_id, ut_output_buffer_tmp_seq.nextval, t.column_value, a_item_type from table(a_text_list) t where t.column_value is not null or a_item_type is not null; - self.last_message_id := self.last_message_id + SQL%rowcount; commit; end; @@ -67,7 +55,7 @@ create or replace type body ut_output_table_buffer is pragma autonomous_transaction; begin if a_text is not null and a_text != empty_clob() or a_item_type is not null then - if length(a_text) > ut_utils.gc_max_storage_varchar2_len then + if ut_utils.lengthb_clob(a_text) > ut_utils.gc_max_storage_varchar2_len then self.send_lines( ut_utils.convert_collection( ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len) @@ -75,99 +63,94 @@ create or replace type body ut_output_table_buffer is a_item_type ); else - self.last_message_id := self.last_message_id + 1; - insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, self.last_message_id, a_text, a_item_type); + insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); end if; commit; end if; end; - overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is - l_buffer_data ut_varchar2_rows; - l_item_types ut_varchar2_rows; - l_finished_flags ut_integer_list; - l_already_waited_for number(10,2) := 0; - l_finished boolean := false; - lc_init_wait_sec constant naturaln := coalesce(a_initial_timeout, 60 ); -- 1 minute - lc_max_wait_sec constant naturaln := coalesce(a_timeout_sec, 60 * 60 * 4); -- 4 hours - l_wait_for integer := lc_init_wait_sec; - lc_short_sleep_time constant number(1,1) := 0.1; --sleep for 100 ms between checks - lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long - lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec - l_sleep_time number(2,1) := lc_short_sleep_time; - lc_bulk_limit constant integer := 5000; - l_max_message_id integer := lc_bulk_limit; - - procedure get_data_from_buffer( - a_max_message_id integer, - a_buffer_data out nocopy ut_varchar2_rows, - a_item_types out nocopy ut_varchar2_rows, - a_finished_flags out nocopy ut_integer_list - ) is - pragma autonomous_transaction; - begin - delete from ( - select * - from ut_output_buffer_tmp o - where o.output_id = self.output_id - and o.message_id <= a_max_message_id - order by o.message_id - ) d - returning d.text, d.item_type, d.is_finished - bulk collect into a_buffer_data, a_item_types, a_finished_flags; - commit; - - end; - - procedure remove_buffer_info is - pragma autonomous_transaction; - begin - delete from ut_output_buffer_info_tmp a - where a.output_id = self.output_id; - commit; - end; + overriding member procedure lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout number := null, a_timeout_sec number := null) is + l_data sys_refcursor; + l_text ut_varchar2_rows; + l_item_type ut_varchar2_rows; + begin + l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); + loop + fetch l_data bulk collect into l_text, l_item_type limit 10000; + for idx in 1 .. l_text.count loop + dbms_output.put_line(l_text(idx)); + end loop; + exit when l_data%notfound; + end loop; + close l_data; + end; - begin + /* Important note. + This function code is almost duplicated between two types for performance reasons. + The pipe row clause is much faster on VARCHAR2 then it is on clob. + That is the key reason for two implementations. + */ + overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined is + lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); + l_buffer_texts ut_varchar2_rows; + l_buffer_item_types ut_varchar2_rows; + l_already_waited_sec number(10,2) := 0; + l_finished boolean := false; + l_sleep_time number(2,1); + l_lock_status integer; + l_producer_started boolean := false; + l_producer_finished boolean := false; + + procedure get_data_from_buffer_table( + a_buffer_texts out nocopy ut_varchar2_rows, + a_buffer_item_types out nocopy ut_varchar2_rows + ) is + lc_bulk_limit constant integer := 20000; + pragma autonomous_transaction; + begin + delete /*+ no_parallel */ from ( + select /*+ no_parallel */ * + from ut_output_buffer_tmp a + where a.output_id = self.output_id + and a.message_id <= (select min(message_id) from ut_output_buffer_tmp o where o.output_id = self.output_id) + lc_bulk_limit + order by a.message_id + ) d + returning d.text, d.item_type + bulk collect into a_buffer_texts, a_buffer_item_types; + commit; + end; + begin while not l_finished loop - get_data_from_buffer( l_max_message_id, l_buffer_data, l_item_types, l_finished_flags); - --nothing fetched from output, wait and try again - if l_buffer_data.count = 0 then - $if dbms_db_version.version >= 18 $then - dbms_session.sleep(l_sleep_time); - $else - dbms_lock.sleep(l_sleep_time); - $end - l_already_waited_for := l_already_waited_for + l_sleep_time; - if l_already_waited_for > lc_long_wait_time then - l_sleep_time := lc_long_sleep_time; - end if; - else - --reset wait time - -- we wait lc_max_wait_sec for new message - l_wait_for := lc_max_wait_sec; - l_already_waited_for := 0; - l_sleep_time := lc_short_sleep_time; - for i in 1 .. l_buffer_data.count loop - if l_buffer_data(i) is not null then - pipe row(ut_output_data_row(l_buffer_data(i),l_item_types(i))); - elsif l_finished_flags(i) = 1 then - l_finished := true; - exit; + + l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; + l_lock_status := self.get_lock_status(); + get_data_from_buffer_table( l_buffer_texts, l_buffer_item_types ); + + if l_buffer_texts.count > 0 then + l_already_waited_sec := 0; + for i in 1 .. l_buffer_texts.count loop + if l_buffer_texts(i) is not null then + pipe row( ut_output_data_row(l_buffer_texts(i), l_buffer_item_types(i)) ); end if; end loop; - l_max_message_id := l_max_message_id + lc_bulk_limit; - end if; - if l_finished or l_already_waited_for >= l_wait_for then - remove_buffer_info(); - if l_already_waited_for > 0 and l_already_waited_for >= l_wait_for then - raise_application_error( - ut_utils.gc_out_buffer_timeout, - 'Timeout occurred while waiting for output data. Waited for: '||l_already_waited_for||' seconds.' - ); - end if; + else + --nothing fetched from output, wait. + dbms_session.sleep(l_sleep_time); + l_already_waited_sec := l_already_waited_sec + l_sleep_time; end if; + + l_producer_started := (l_lock_status <> 0 or l_buffer_texts.count > 0) or l_producer_started; + l_producer_finished := (l_producer_started and l_lock_status = 0 and l_buffer_texts.count = 0) or l_producer_finished; + + l_finished := + self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) + or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) + or l_producer_finished; + end loop; + + self.remove_buffer_info(); return; end; diff --git a/source/core/output_buffers/ut_output_table_buffer.tps b/source/core/output_buffers/ut_output_table_buffer.tps index 3e395304a..06e157d90 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tps +++ b/source/core/output_buffers/ut_output_table_buffer.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_table_buffer under ut_output_buffer_base ( +create or replace noneditionable type ut_output_table_buffer under ut_output_buffer_base ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,7 +20,7 @@ create or replace type ut_output_table_buffer under ut_output_buffer_base ( overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null), overriding member procedure send_lines(self in out nocopy ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), overriding member procedure send_clob(self in out nocopy ut_output_table_buffer, a_text clob, a_item_type varchar2 := null), - overriding member procedure close(self in out nocopy ut_output_table_buffer), - overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined + overriding member procedure lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout number := null, a_timeout_sec number := null), + overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined ) not final / diff --git a/source/core/session_context/ut_session_context.pkb b/source/core/session_context/ut_session_context.pkb index 427d722da..2db83506e 100644 --- a/source/core/session_context/ut_session_context.pkb +++ b/source/core/session_context/ut_session_context.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_session_context as +create or replace noneditionable package body ut_session_context as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,11 +15,7 @@ create or replace package body ut_session_context as See the License for the specific language governing permissions and limitations under the License. */ - $IF $$SELF_TESTING_INSTALL $THEN gc_context_name constant varchar2(30) := ut_utils.ut_owner()||'_INFO'; - $ELSE - gc_context_name constant varchar2(30) := 'UT3_INFO'; - $END procedure set_context(a_name varchar2, a_value varchar2) is begin diff --git a/source/core/session_context/ut_session_context.pks b/source/core/session_context/ut_session_context.pks index bbe256db4..1221bccda 100644 --- a/source/core/session_context/ut_session_context.pks +++ b/source/core/session_context/ut_session_context.pks @@ -1,10 +1,10 @@ -create or replace package ut_session_context as +create or replace noneditionable package ut_session_context as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/session_context/ut_session_info.tpb b/source/core/session_context/ut_session_info.tpb index 2d3fdbed9..fd1b80069 100644 --- a/source/core/session_context/ut_session_info.tpb +++ b/source/core/session_context/ut_session_info.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_session_info as +create or replace noneditionable type body ut_session_info as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -28,12 +28,14 @@ create or replace type body ut_session_info as member procedure before_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is begin ut_session_context.set_context( 'run_paths', ut_utils.to_string( ut_utils.table_to_clob( a_run.run_paths,',' ), null ) ); + ut_session_context.set_context( 'coverage_run_id', rawtohex( a_run.coverage_options.coverage_run_id ) ); dbms_application_info.set_module( 'utPLSQL', null ); end; member procedure after_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is begin ut_session_context.clear_context( 'run_paths' ); + ut_session_context.clear_context( 'coverage_run_id' ); dbms_application_info.set_module( module, action ); dbms_application_info.set_client_info( client_info ); end; diff --git a/source/core/session_context/ut_session_info.tps b/source/core/session_context/ut_session_info.tps index 863b0dc3e..741d6cb59 100644 --- a/source/core/session_context/ut_session_info.tps +++ b/source/core/session_context/ut_session_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_session_info under ut_event_listener ( +create or replace noneditionable type ut_session_info under ut_event_listener ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_console_reporter_base.tpb b/source/core/types/ut_console_reporter_base.tpb index df256e832..635a4d456 100644 --- a/source/core/types/ut_console_reporter_base.tpb +++ b/source/core/types/ut_console_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_console_reporter_base is +create or replace noneditionable type body ut_console_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_console_reporter_base.tps b/source/core/types/ut_console_reporter_base.tps index 6c0a08502..d23c6d9e4 100644 --- a/source/core/types/ut_console_reporter_base.tps +++ b/source/core/types/ut_console_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_console_reporter_base under ut_output_reporter_base( +create or replace noneditionable type ut_console_reporter_base under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_coverage_options.tpb b/source/core/types/ut_coverage_options.tpb new file mode 100644 index 000000000..f4e07bf9b --- /dev/null +++ b/source/core/types/ut_coverage_options.tpb @@ -0,0 +1,73 @@ +create or replace noneditionable type body ut_coverage_options as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_coverage_options( + self in out nocopy ut_coverage_options, + coverage_run_id raw, + schema_names ut_varchar2_rows := null, + exclude_objects ut_varchar2_rows := null, + include_objects ut_varchar2_rows := null, + file_mappings ut_file_mappings := null, + include_schema_expr varchar2 := null, + include_object_expr varchar2 := null, + exclude_schema_expr varchar2 := null, + exclude_object_expr varchar2 := null + ) return self as result is + function to_ut_object_list(a_names ut_varchar2_rows, a_schema_names ut_varchar2_rows) return ut_object_names is + l_result ut_object_names; + l_object_name ut_object_name; + begin + if a_names is not empty then + l_result := ut_object_names(); + for i in 1 .. a_names.count loop + l_object_name := ut_object_name(a_names(i)); + if l_object_name.owner is null then + for i in 1 .. cardinality(a_schema_names) loop + l_result.extend; + l_result(l_result.last) := ut_object_name(a_schema_names(i)||'.'||l_object_name.name); + end loop; + else + l_result.extend; + l_result(l_result.last) := l_object_name; + end if; + end loop; + end if; + return l_result; + end; + begin + self.coverage_run_id := coverage_run_id; + self.file_mappings := file_mappings; + self.schema_names := schema_names; + self.exclude_objects := ut_object_names(); + + if exclude_objects is not empty then + self.exclude_objects := to_ut_object_list(exclude_objects, self.schema_names); + end if; + + self.include_objects := to_ut_object_list(include_objects, self.schema_names); + + self.include_schema_expr := include_schema_expr; + self.include_object_expr := include_object_expr; + self.exclude_schema_expr := exclude_schema_expr; + self.exclude_object_expr := exclude_object_expr; + + + return; + end; +end; +/ diff --git a/source/core/types/ut_coverage_options.tps b/source/core/types/ut_coverage_options.tps index bcdbc0b32..81a04101f 100644 --- a/source/core/types/ut_coverage_options.tps +++ b/source/core/types/ut_coverage_options.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_options force as object ( +create or replace noneditionable type ut_coverage_options force as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,9 +16,26 @@ create or replace type ut_coverage_options force as object ( limitations under the License. */ + coverage_run_id raw(32), schema_names ut_varchar2_rows, exclude_objects ut_object_names, include_objects ut_object_names, - file_mappings ut_file_mappings + file_mappings ut_file_mappings, + include_schema_expr varchar2(4000), + include_object_expr varchar2(4000), + exclude_schema_expr varchar2(4000), + exclude_object_expr varchar2(4000), + constructor function ut_coverage_options( + self in out nocopy ut_coverage_options, + coverage_run_id raw, + schema_names ut_varchar2_rows := null, + exclude_objects ut_varchar2_rows := null, + include_objects ut_varchar2_rows := null, + file_mappings ut_file_mappings := null, + include_schema_expr varchar2 := null, + include_object_expr varchar2 := null, + exclude_schema_expr varchar2 := null, + exclude_object_expr varchar2 := null + ) return self as result ) / diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index 826a5aaa1..5d454989d 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_executable is +create or replace noneditionable type body ut_executable is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -38,20 +38,30 @@ create or replace type body ut_executable is return ut_metadata.form_name(l_owner_name, object_name, procedure_name); end; - member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) is + member procedure do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows :=null) + is l_completed_without_errors boolean; begin - l_completed_without_errors := self.do_execute(a_item); + l_completed_without_errors := self.do_execute(a_item, a_ignored_exception_names, a_ignored_exception_numbers); end do_execute; - member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean is - l_statement varchar2(4000); - l_status number; - l_cursor_number number; - l_completed_without_errors boolean := true; - l_failed_with_invalid_pck boolean := true; - l_start_transaction_id varchar2(250); - l_end_transaction_id varchar2(250); + member function do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows :=null) + return boolean is + l_statement varchar2(4000); + l_status number; + l_cursor_number number; + l_completed_without_errors boolean := true; + l_failed_with_invalid_pck boolean := true; + l_start_transaction_id varchar2(250); + l_end_transaction_id varchar2(250); function is_defined return boolean is l_result boolean := false; @@ -111,19 +121,33 @@ create or replace type body ut_executable is if l_completed_without_errors then l_statement := 'declare' || chr(10) || - ' l_error_stack varchar2(32767);' || chr(10) || - ' l_error_backtrace varchar2(32767);' || chr(10) || + ' l_error_stack varchar2(32767);' || chr(10) || + ' l_error_backtrace varchar2(32767);' || chr(10) || + ' l_ignored_exception_detected integer := 0;' || chr(10) || 'begin' || chr(10) || ' begin' || chr(10) || ' ' || self.form_name( a_skip_current_user_schema => true ) || ';' || chr(10) || ' exception' || chr(10) || + case when a_ignored_exception_names is not empty then + ' when ' || ut_utils.table_to_clob( a_ignored_exception_names, ' or ' ) || ' then ' || chr(10) || + ' l_ignored_exception_detected := 1;' + end || ' when others then ' || chr(10) || + case when a_ignored_exception_numbers is not empty then + ' if sqlcode in (' || ut_utils.table_to_clob( a_ignored_exception_numbers, ', ' ) || ') then ' || chr(10) || + ' l_ignored_exception_detected := 1; ' || chr(10) || + ' else ' || chr(10) || + ' l_error_stack := dbms_utility.format_error_stack;' || chr(10) || + ' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) || + ' end if;' + else ' l_error_stack := dbms_utility.format_error_stack;' || chr(10) || - ' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) || - ' --raise on ORA-04068, ORA-04061: existing state of packages has been discarded to avoid unrecoverable session exception' || chr(10) || + ' l_error_backtrace := dbms_utility.format_error_backtrace;' + end || chr(10) || ' end;' || chr(10) || ' :a_error_stack := l_error_stack;' || chr(10) || ' :a_error_backtrace := l_error_backtrace;' || chr(10) || + ' :a_ignored_exception_detected := l_ignored_exception_detected;' || chr(10) || 'end;'; ut_utils.debug_log('ut_executable.do_execute l_statement: ' || l_statement); @@ -139,9 +163,11 @@ create or replace type body ut_executable is dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native); dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767); dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767); + dbms_sql.bind_variable(l_cursor_number, 'a_ignored_exception_detected', to_number(null)); l_status := dbms_sql.execute(l_cursor_number); dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack); dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace); + dbms_sql.variable_value(l_cursor_number, 'a_ignored_exception_detected', self.ignored_exception_detected); dbms_sql.close_cursor(l_cursor_number); exception when ut_utils.ex_invalid_package then diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps index 786d926ad..4e263402d 100644 --- a/source/core/types/ut_executable.tps +++ b/source/core/types/ut_executable.tps @@ -1,10 +1,10 @@ -create or replace type ut_executable under ut_event_item( +create or replace noneditionable type ut_executable under ut_event_item( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,26 +18,37 @@ create or replace type ut_executable under ut_event_item( /** * The name of the event to be executed before and after the executable is invoked */ - executable_type varchar2(250 char), - owner_name varchar2(250 char), - object_name varchar2(250 char), - procedure_name varchar2(250 char), - error_backtrace varchar2(4000), - error_stack varchar2(4000), - serveroutput clob, + executable_type varchar2(250 char), + owner_name varchar2(250 char), + object_name varchar2(250 char), + procedure_name varchar2(250 char), + error_backtrace varchar2(4000), + error_stack varchar2(4000), + ignored_exception_detected integer, + serveroutput clob, /** * Used for ordering of executables, as Oracle doesn not guarantee ordering of items in a nested table. */ seq_no integer, constructor function ut_executable( self in out nocopy ut_executable, a_owner varchar2, a_package varchar2, a_procedure_name varchar2, a_executable_type varchar2) return self as result, member function form_name(a_skip_current_user_schema boolean := false) return varchar2, - member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item), + member procedure do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows := null + ), /** * executes the defines executable * returns true if executed without exceptions * returns false if exceptions were raised */ - member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean, + member function do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows :=null + ) return boolean, member function get_error_stack_trace return varchar2 ) not final / diff --git a/source/core/types/ut_executable_test.tpb b/source/core/types/ut_executable_test.tpb index a11797a54..06851a007 100644 --- a/source/core/types/ut_executable_test.tpb +++ b/source/core/types/ut_executable_test.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_executable_test as +create or replace noneditionable type body ut_executable_test as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -31,37 +31,129 @@ create or replace type body ut_executable_test as member procedure do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_integer_list + a_expected_errors in ut_varchar2_rows ) is l_completed_without_errors boolean; begin - l_completed_without_errors := self.do_execute(a_item, a_expected_error_codes); + l_completed_without_errors := self.do_execute(a_item, a_expected_errors); end do_execute; member function do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_integer_list + a_expected_errors in ut_varchar2_rows ) return boolean is - l_expected_except_message varchar2(4000); + l_failure_message varchar2(32767); + l_expected_error_names ut_varchar2_rows; + l_expected_error_numbers ut_varchar2_rows; + l_all_expected_errors ut_varchar2_rows; - function failed_expec_errnum_message(a_expected_error_codes in ut_integer_list) return varchar is + procedure build_expected_exceptions( + a_item in out nocopy ut_suite_item, + a_exception_definitions in ut_varchar2_rows, + a_exception_names_list out ut_varchar2_rows, + a_exception_numbers_list out ut_varchar2_rows + ) is + l_exception_number integer; + l_exception_name varchar2(128); + function to_exception_number (a_exception_var in varchar2, a_item ut_suite_item) return integer is + function get_exception_no(a_exception_var in varchar2) return integer is + l_exc_no integer; + begin + execute immediate 'declare l_exception integer; begin :l_exception := '||a_exception_var||'; end;' + using out l_exc_no; + return l_exc_no; + exception + when others then + return null; + end; + function remap_no_data_found (a_number integer) return integer is + begin + return case a_number when 100 then -1403 else a_number end; + end; + begin + return remap_no_data_found( + coalesce( + get_exception_no(a_exception_var), + get_exception_no(a_item.object_name||'.'||a_exception_var), + get_exception_no(a_item.object_owner||'.'||a_exception_var), + get_exception_no(a_item.object_owner||'.'||a_item.object_name||'.'||a_exception_var) + ) + ); + end; + + function to_exception_name (a_exception_var in varchar2, a_item ut_suite_item) return varchar2 is + function verify_name(a_exception_name in varchar2) return varchar2 is + begin + --check if it is an existing, named exception + execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; + return a_exception_name; + exception + when others then + return null; + end; + begin + return coalesce( + verify_name(a_exception_var), + verify_name(a_item.object_name||'.'||a_exception_var), + verify_name(a_item.object_owner||'.'||a_exception_var), + verify_name(a_item.object_owner||'.'||a_item.object_name||'.'||a_exception_var) + ); + + end; + + begin + a_exception_names_list := ut_varchar2_rows(); + a_exception_numbers_list := ut_varchar2_rows(); + if a_exception_definitions is not empty then + for i in 1 .. a_exception_definitions.count loop + l_exception_number := + coalesce( + to_exception_number(a_exception_definitions(i), a_item), + to_number(a_exception_definitions(i) default null on conversion error ) + ); + l_exception_name := to_exception_name(a_exception_definitions(i), a_item); + + if l_exception_number is null and l_exception_name is null then + a_item.put_warning( + 'Invalid parameter value "'||a_exception_definitions(i)||'" for "--%throws" annotation. Parameter ignored.', + self.procedure_name, + a_item.line_no + ); + elsif l_exception_number >= 0 then + a_item.put_warning( + 'Invalid parameter value "'||a_exception_definitions(i)||'" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.', + self.procedure_name, + a_item.line_no + ); + elsif l_exception_number is not null then + a_exception_numbers_list.extend; + a_exception_numbers_list(a_exception_numbers_list.last) := l_exception_number; + elsif l_exception_name is not null then + a_exception_names_list.extend; + a_exception_names_list(a_exception_names_list.last) := l_exception_name; + end if; + end loop; + end if; + end; + + function get_exception_failure_message(a_expected_errors_list ut_varchar2_rows) return varchar2 is l_actual_error_no integer; - l_expected_error_codes varchar2(4000); + l_expected_errors varchar2(4000); l_fail_message varchar2(4000); begin --Convert the ut_varchar2_list to string to can construct the message - l_expected_error_codes := ut_utils.table_to_clob(a_expected_error_codes, ', '); + l_expected_errors := ut_utils.table_to_clob(a_expected_errors_list, ', '); if self.error_stack is null then - l_fail_message := 'Expected one of exceptions ('||l_expected_error_codes||') but nothing was raised.'; + l_fail_message := 'Expected one of exceptions ('|| l_expected_errors|| ') but nothing was raised.'; else - l_actual_error_no := regexp_substr(self.error_stack, '^[a-zA-Z]{3}(-[0-9]+)', subexpression=>1); - if not l_actual_error_no member of a_expected_error_codes then + l_actual_error_no := regexp_substr(self.error_stack, '^[[:alpha:]]{3}(-[0-9]+)', subexpression=>1); + if not l_actual_error_no member of a_expected_errors_list or l_actual_error_no is null then l_fail_message := 'Actual: '||l_actual_error_no||' was expected to '; - if cardinality(a_expected_error_codes) > 1 then - l_fail_message := l_fail_message || 'be one of: ('||l_expected_error_codes||')'; + if cardinality(a_expected_errors_list) > 1 then + l_fail_message := l_fail_message || 'be one of: ('|| l_expected_errors|| ')'; else - l_fail_message := l_fail_message || 'equal: '||l_expected_error_codes; + l_fail_message := l_fail_message || 'equal: '||l_expected_errors; end if; l_fail_message := substr( l_fail_message||chr(10)||self.error_stack||chr(10)||self.error_backtrace, 1, 4000 ); end if; @@ -71,14 +163,16 @@ create or replace type body ut_executable_test as end; begin --Create a ut_executable object and call do_execute after that get the data to know the test's execution result - self.do_execute(a_item); + build_expected_exceptions(a_item, a_expected_errors, l_expected_error_names, l_expected_error_numbers ); - if a_expected_error_codes is not null and a_expected_error_codes is not empty then - l_expected_except_message := failed_expec_errnum_message(a_expected_error_codes); + self.do_execute(a_item, l_expected_error_names, l_expected_error_numbers); + l_all_expected_errors := l_expected_error_names multiset union all l_expected_error_numbers; + if l_all_expected_errors is not empty and self.ignored_exception_detected = 0 then + l_failure_message := get_exception_failure_message( l_all_expected_errors); - if l_expected_except_message is not null then + if l_failure_message is not null then ut_expectation_processor.add_expectation_result( - ut_expectation_result(ut_utils.gc_failure, null, l_expected_except_message, false) + ut_expectation_result(ut_utils.gc_failure, null, l_failure_message, false) ); end if; self.error_stack := null; diff --git a/source/core/types/ut_executable_test.tps b/source/core/types/ut_executable_test.tps index 2772720de..2f9a5f236 100644 --- a/source/core/types/ut_executable_test.tps +++ b/source/core/types/ut_executable_test.tps @@ -1,10 +1,10 @@ -create or replace type ut_executable_test authid current_user under ut_executable ( +create or replace noneditionable type ut_executable_test authid current_user under ut_executable ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,12 +22,12 @@ create or replace type ut_executable_test authid current_user under ut_executabl member procedure do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_integer_list + a_expected_errors in ut_varchar2_rows ), member function do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_integer_list + a_expected_errors in ut_varchar2_rows ) return boolean ) final; diff --git a/source/core/types/ut_executables.tps b/source/core/types/ut_executables.tps index f5732d5a1..fb08b287d 100644 --- a/source/core/types/ut_executables.tps +++ b/source/core/types/ut_executables.tps @@ -1,10 +1,10 @@ -create or replace type ut_executables as +create or replace noneditionable type ut_executables as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_expectation_result.tpb b/source/core/types/ut_expectation_result.tpb index 9aa8b81c0..b98853efc 100644 --- a/source/core/types/ut_expectation_result.tpb +++ b/source/core/types/ut_expectation_result.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_expectation_result is +create or replace noneditionable type body ut_expectation_result is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_expectation_result.tps b/source/core/types/ut_expectation_result.tps index 815d90820..5fc296bfe 100644 --- a/source/core/types/ut_expectation_result.tps +++ b/source/core/types/ut_expectation_result.tps @@ -1,10 +1,10 @@ -create or replace type ut_expectation_result under ut_event_item( +create or replace noneditionable type ut_expectation_result under ut_event_item( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_expectation_results.tps b/source/core/types/ut_expectation_results.tps index 963c726f8..361bb8669 100644 --- a/source/core/types/ut_expectation_results.tps +++ b/source/core/types/ut_expectation_results.tps @@ -1,10 +1,10 @@ -create or replace type ut_expectation_results as +create or replace noneditionable type ut_expectation_results as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_file_mapping.tpb b/source/core/types/ut_file_mapping.tpb index 247aa5ac8..4286bb171 100644 --- a/source/core/types/ut_file_mapping.tpb +++ b/source/core/types/ut_file_mapping.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_file_mapping as +create or replace noneditionable type body ut_file_mapping as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_file_mapping.tps b/source/core/types/ut_file_mapping.tps index c032e0b77..bd048a218 100644 --- a/source/core/types/ut_file_mapping.tps +++ b/source/core/types/ut_file_mapping.tps @@ -1,10 +1,10 @@ -create or replace type ut_file_mapping as object( +create or replace noneditionable type ut_file_mapping as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_file_mappings.tps b/source/core/types/ut_file_mappings.tps index a48c3e872..8ad94d2ec 100644 --- a/source/core/types/ut_file_mappings.tps +++ b/source/core/types/ut_file_mappings.tps @@ -1,10 +1,10 @@ -create or replace type ut_file_mappings as +create or replace noneditionable type ut_file_mappings as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_integer_list.tps b/source/core/types/ut_integer_list.tps index 25f1679b2..86316e630 100644 --- a/source/core/types/ut_integer_list.tps +++ b/source/core/types/ut_integer_list.tps @@ -1,10 +1,10 @@ -create or replace type ut_integer_list as +create or replace noneditionable type ut_integer_list as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_key_value_pair.tps b/source/core/types/ut_key_value_pair.tps index 873a354fd..0082affd3 100644 --- a/source/core/types/ut_key_value_pair.tps +++ b/source/core/types/ut_key_value_pair.tps @@ -1,10 +1,10 @@ -create or replace type ut_key_value_pair force as object( +create or replace noneditionable type ut_key_value_pair force as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_key_value_pairs.tps b/source/core/types/ut_key_value_pairs.tps index 28fa87cf0..4b76438d4 100644 --- a/source/core/types/ut_key_value_pairs.tps +++ b/source/core/types/ut_key_value_pairs.tps @@ -1,10 +1,10 @@ -create or replace type ut_key_value_pairs as +create or replace noneditionable type ut_key_value_pairs as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_logical_suite.tpb b/source/core/types/ut_logical_suite.tpb index 74c7ff81c..47a154399 100644 --- a/source/core/types/ut_logical_suite.tpb +++ b/source/core/types/ut_logical_suite.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_logical_suite as +create or replace noneditionable type body ut_logical_suite as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,12 +16,12 @@ create or replace type body ut_logical_suite as limitations under the License. */ - overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite) is + overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2) is begin ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); self.start_time := current_timestamp; for i in 1 .. self.items.count loop - self.items(i).mark_as_skipped(); + self.items(i).mark_as_skipped(coalesce(a_skip_reason,self.disabled_reason)); end loop; self.end_time := self.start_time; ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self); diff --git a/source/core/types/ut_logical_suite.tps b/source/core/types/ut_logical_suite.tps index 71cfdb23d..5993ee4f8 100644 --- a/source/core/types/ut_logical_suite.tps +++ b/source/core/types/ut_logical_suite.tps @@ -1,10 +1,10 @@ -create or replace type ut_logical_suite under ut_suite_item ( +create or replace noneditionable type ut_logical_suite force under ut_suite_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,7 +21,7 @@ create or replace type ut_logical_suite under ut_suite_item ( */ items ut_suite_items, - overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite), + overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2), overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer, a_force boolean := false), overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean, overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite), diff --git a/source/core/types/ut_object_name.tpb b/source/core/types/ut_object_name.tpb index cf1ab2a78..ce5d3b052 100644 --- a/source/core/types/ut_object_name.tpb +++ b/source/core/types/ut_object_name.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_object_name as +create or replace noneditionable type body ut_object_name as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_object_name.tps b/source/core/types/ut_object_name.tps index 28e41958f..23ab1b161 100644 --- a/source/core/types/ut_object_name.tps +++ b/source/core/types/ut_object_name.tps @@ -1,10 +1,10 @@ -create or replace type ut_object_name as object ( +create or replace noneditionable type ut_object_name as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_object_names.tps b/source/core/types/ut_object_names.tps index 2f7e5ea16..10159fbbb 100644 --- a/source/core/types/ut_object_names.tps +++ b/source/core/types/ut_object_names.tps @@ -1,10 +1,10 @@ -create or replace type ut_object_names as +create or replace noneditionable type ut_object_names as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_output_reporter_base.tpb b/source/core/types/ut_output_reporter_base.tpb index c4ba73ba5..4857036a6 100644 --- a/source/core/types/ut_output_reporter_base.tpb +++ b/source/core/types/ut_output_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_reporter_base is +create or replace noneditionable type body ut_output_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -41,13 +41,6 @@ create or replace type body ut_output_reporter_base is return l_result; end; - overriding member procedure before_calling_run(self in out nocopy ut_output_reporter_base, a_run in ut_run) is - l_output_table_buffer ut_output_table_buffer; - begin - (self as ut_reporter_base).before_calling_run(a_run); - l_output_table_buffer := treat(self.output_buffer as ut_output_table_buffer); - end; - member procedure print_text(self in out nocopy ut_output_reporter_base, a_text varchar2, a_item_type varchar2 := null) is begin self.output_buffer.send_line(a_text, a_item_type); @@ -65,7 +58,7 @@ create or replace type body ut_output_reporter_base is final member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural) return ut_output_data_rows pipelined is begin - for i in (select value(x) val from table(self.output_buffer.get_lines(a_initial_timeout, a_timeout_sec)) x ) loop + for i in (select /*+ no_parallel */ value(x) val from table(self.output_buffer.get_lines(a_initial_timeout, a_timeout_sec)) x ) loop pipe row (i.val); end loop; end; @@ -87,6 +80,7 @@ create or replace type body ut_output_reporter_base is overriding member procedure on_initialize(self in out nocopy ut_output_reporter_base, a_run in ut_run) is begin + self.output_buffer.lock_buffer(); self.output_buffer.send_line(null, 'initialize'); end; diff --git a/source/core/types/ut_output_reporter_base.tps b/source/core/types/ut_output_reporter_base.tps index 01350208a..585069cf7 100644 --- a/source/core/types/ut_output_reporter_base.tps +++ b/source/core/types/ut_output_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_reporter_base under ut_reporter_base( +create or replace noneditionable type ut_output_reporter_base under ut_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,8 +20,7 @@ create or replace type ut_output_reporter_base under ut_reporter_base( member procedure init(self in out nocopy ut_output_reporter_base, a_self_type varchar2, a_output_buffer ut_output_buffer_base := null), overriding member procedure set_reporter_id(self in out nocopy ut_output_reporter_base, a_reporter_id raw), member function set_reporter_id(self in ut_output_reporter_base, a_reporter_id raw) return ut_output_reporter_base, - overriding member procedure before_calling_run(self in out nocopy ut_output_reporter_base, a_run in ut_run), - + member procedure print_text(self in out nocopy ut_output_reporter_base, a_text varchar2, a_item_type varchar2 := null), member procedure print_text_lines(self in out nocopy ut_output_reporter_base, a_text_lines ut_varchar2_rows, a_item_type varchar2 := null), member procedure print_clob(self in out nocopy ut_output_reporter_base, a_clob clob, a_item_type varchar2 := null), diff --git a/source/core/types/ut_path_item.tpb b/source/core/types/ut_path_item.tpb new file mode 100644 index 000000000..3d85c4e3e --- /dev/null +++ b/source/core/types/ut_path_item.tpb @@ -0,0 +1,42 @@ +create or replace noneditionable type body ut_path_item as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2) return self as result is + begin + self.schema_name := schema_name; + self.object_name := object_name; + self.procedure_name := procedure_name; + return; + end; + + constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2,suite_path varchar2) return self as result is + begin + self.schema_name := schema_name; + self.suite_path := suite_path; + return; + end; + + constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2) return self as result is + begin + self.schema_name := schema_name; + self.object_name := object_name; + self.procedure_name := procedure_name; + self.suite_path := suite_path; + return; + end; +end; +/ diff --git a/source/core/types/ut_path_item.tps b/source/core/types/ut_path_item.tps new file mode 100644 index 000000000..e90cf6099 --- /dev/null +++ b/source/core/types/ut_path_item.tps @@ -0,0 +1,26 @@ +create or replace noneditionable type ut_path_item as object ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + schema_name varchar2(4000), + object_name varchar2(250), + procedure_name varchar2(250), + suite_path varchar2(4000), + constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2) return self as result, + constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, suite_path varchar2) return self as result, + constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2) return self as result +) +/ diff --git a/source/core/types/ut_path_items.tps b/source/core/types/ut_path_items.tps new file mode 100644 index 000000000..0cf12fa1a --- /dev/null +++ b/source/core/types/ut_path_items.tps @@ -0,0 +1,19 @@ +create or replace noneditionable type ut_path_items as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + table of ut_path_item +/ diff --git a/source/core/types/ut_reporter_base.tpb b/source/core/types/ut_reporter_base.tpb index 94d518af4..5dca1db44 100644 --- a/source/core/types/ut_reporter_base.tpb +++ b/source/core/types/ut_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_reporter_base is +create or replace noneditionable type body ut_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -165,52 +165,54 @@ create or replace type body ut_reporter_base is end; overriding member procedure on_event( self in out nocopy ut_reporter_base, a_event_name varchar2, a_event_item ut_event_item) is + /* Resolves issue with ORA-21779 being thrown see issue: 1309 -> ( https://github.com/utPLSQL/utPLSQL/issues/1309#issuecomment-4020289898 ) */ + l_event_item ut_event_item := a_event_item; begin case a_event_name when ut_event_manager.gc_initialize - then self.on_initialize(treat(a_event_item as ut_run)); + then self.on_initialize(treat(l_event_item as ut_run)); when ut_event_manager.gc_before_run - then self.before_calling_run(treat(a_event_item as ut_run)); + then self.before_calling_run(treat(l_event_item as ut_run)); when ut_event_manager.gc_before_suite - then self.before_calling_suite(treat(a_event_item as ut_logical_suite)); + then self.before_calling_suite(treat(l_event_item as ut_logical_suite)); when ut_event_manager.gc_before_before_all - then self.before_calling_before_all(treat(a_event_item as ut_executable)); + then self.before_calling_before_all(treat(l_event_item as ut_executable)); when ut_event_manager.gc_before_before_each - then self.before_calling_before_each(treat(a_event_item as ut_executable)); + then self.before_calling_before_each(treat(l_event_item as ut_executable)); when ut_event_manager.gc_before_test - then self.before_calling_test(treat(a_event_item as ut_test)); + then self.before_calling_test(treat(l_event_item as ut_test)); when ut_event_manager.gc_before_before_test - then self.before_calling_before_test(treat(a_event_item as ut_executable)); + then self.before_calling_before_test(treat(l_event_item as ut_executable)); when ut_event_manager.gc_before_test_execute - then self.before_calling_test_execute(treat(a_event_item as ut_executable)); + then self.before_calling_test_execute(treat(l_event_item as ut_executable)); when ut_event_manager.gc_before_after_test - then self.before_calling_after_test(treat(a_event_item as ut_executable)); + then self.before_calling_after_test(treat(l_event_item as ut_executable)); when ut_event_manager.gc_before_after_each - then self.before_calling_after_each(treat(a_event_item as ut_executable)); + then self.before_calling_after_each(treat(l_event_item as ut_executable)); when ut_event_manager.gc_before_after_all - then self.before_calling_after_all(treat(a_event_item as ut_executable)); + then self.before_calling_after_all(treat(l_event_item as ut_executable)); when ut_event_manager.gc_after_run - then self.after_calling_run(treat(a_event_item as ut_run)); + then self.after_calling_run(treat(l_event_item as ut_run)); when ut_event_manager.gc_after_suite - then self.after_calling_suite(treat(a_event_item as ut_logical_suite)); + then self.after_calling_suite(treat(l_event_item as ut_logical_suite)); when ut_event_manager.gc_after_before_all - then self.after_calling_before_all(treat(a_event_item as ut_executable)); + then self.after_calling_before_all(treat(l_event_item as ut_executable)); when ut_event_manager.gc_after_before_each - then self.after_calling_before_each(treat(a_event_item as ut_executable)); + then self.after_calling_before_each(treat(l_event_item as ut_executable)); when ut_event_manager.gc_after_test - then self.after_calling_test(treat(a_event_item as ut_test)); + then self.after_calling_test(treat(l_event_item as ut_test)); when ut_event_manager.gc_after_before_test - then self.after_calling_before_test(treat(a_event_item as ut_executable)); + then self.after_calling_before_test(treat(l_event_item as ut_executable)); when ut_event_manager.gc_after_test_execute - then self.after_calling_test_execute(treat(a_event_item as ut_executable)); + then self.after_calling_test_execute(treat(l_event_item as ut_executable)); when ut_event_manager.gc_after_after_test - then self.after_calling_after_test(treat(a_event_item as ut_executable)); + then self.after_calling_after_test(treat(l_event_item as ut_executable)); when ut_event_manager.gc_after_after_each - then self.after_calling_after_each(treat(a_event_item as ut_executable)); + then self.after_calling_after_each(treat(l_event_item as ut_executable)); when ut_event_manager.gc_after_after_all - then self.after_calling_after_all(treat(a_event_item as ut_executable)); + then self.after_calling_after_all(treat(l_event_item as ut_executable)); when ut_event_manager.gc_finalize - then self.on_finalize(treat(a_event_item as ut_run)); + then self.on_finalize(treat(l_event_item as ut_run)); else null; end case; end; diff --git a/source/core/types/ut_reporter_base.tps b/source/core/types/ut_reporter_base.tps index 36af70776..f90162791 100644 --- a/source/core/types/ut_reporter_base.tps +++ b/source/core/types/ut_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporter_base under ut_event_listener ( +create or replace noneditionable type ut_reporter_base under ut_event_listener ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporter_info.tps b/source/core/types/ut_reporter_info.tps index d1f159211..6f7219f7c 100644 --- a/source/core/types/ut_reporter_info.tps +++ b/source/core/types/ut_reporter_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporter_info as object ( +create or replace noneditionable type ut_reporter_info as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporters.tps b/source/core/types/ut_reporters.tps index b16e74653..d47240e8b 100644 --- a/source/core/types/ut_reporters.tps +++ b/source/core/types/ut_reporters.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporters as +create or replace noneditionable type ut_reporters as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporters_info.tps b/source/core/types/ut_reporters_info.tps index 6e9a866ef..b100789df 100644 --- a/source/core/types/ut_reporters_info.tps +++ b/source/core/types/ut_reporters_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporters_info as +create or replace noneditionable type ut_reporters_info as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_results_counter.tpb b/source/core/types/ut_results_counter.tpb index 0007acd9b..64be5d5a4 100644 --- a/source/core/types/ut_results_counter.tpb +++ b/source/core/types/ut_results_counter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_results_counter as +create or replace noneditionable type body ut_results_counter as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_results_counter.tps b/source/core/types/ut_results_counter.tps index 1b26b673a..d53d37e21 100644 --- a/source/core/types/ut_results_counter.tps +++ b/source/core/types/ut_results_counter.tps @@ -1,10 +1,10 @@ -create or replace type ut_results_counter as object( +create or replace noneditionable type ut_results_counter as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index bff16dc69..85fa930e4 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_run as +create or replace noneditionable type body ut_run as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,16 +18,14 @@ create or replace type body ut_run as constructor function ut_run( self in out nocopy ut_run, - a_items ut_suite_items, + a_items ut_suite_items := null, a_run_paths ut_varchar2_list := null, - a_schema_names ut_varchar2_rows := null, - a_exclude_objects ut_object_names := null, - a_include_objects ut_object_names := null, - a_project_file_mappings ut_file_mappings := null, + a_coverage_options ut_coverage_options := null, a_test_file_mappings ut_file_mappings := null, a_client_character_set varchar2 := null, a_random_test_order_seed positive := null, - a_run_tags ut_varchar2_rows := null + a_run_tags varchar2 := null, + a_support_info boolean := true ) return self as result is begin self.run_paths := a_run_paths; @@ -38,16 +36,17 @@ create or replace type body ut_run as self.random_test_order_seed := a_random_test_order_seed; self.results_count := ut_results_counter(); self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings()); - self.coverage_options := ut_coverage_options( - a_schema_names, - a_exclude_objects, - a_include_objects, - a_project_file_mappings - ); + self.coverage_options := a_coverage_options; + self.support_info_flag := ut_utils.boolean_to_int(coalesce(a_support_info, true)); return; end; - overriding member procedure mark_as_skipped(self in out nocopy ut_run) is + member function get_support_info_flag return boolean is + begin + return ut_utils.int_to_boolean(self.support_info_flag); + end; + + overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2) is begin null; end; diff --git a/source/core/types/ut_run.tps b/source/core/types/ut_run.tps index 2a4e11656..a3f0b69b8 100644 --- a/source/core/types/ut_run.tps +++ b/source/core/types/ut_run.tps @@ -1,10 +1,10 @@ -create or replace type ut_run under ut_suite_item ( +create or replace noneditionable type ut_run under ut_suite_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,25 +21,25 @@ create or replace type ut_run under ut_suite_item ( project_name varchar2(4000), items ut_suite_items, run_paths ut_varchar2_list, - run_tags ut_varchar2_rows, + run_tags varchar2(4000), coverage_options ut_coverage_options, test_file_mappings ut_file_mappings, client_character_set varchar2(100), random_test_order_seed number(38,0), + support_info_flag integer(1), constructor function ut_run( self in out nocopy ut_run, - a_items ut_suite_items, + a_items ut_suite_items := null, a_run_paths ut_varchar2_list := null, - a_schema_names ut_varchar2_rows := null, - a_exclude_objects ut_object_names := null, - a_include_objects ut_object_names := null, - a_project_file_mappings ut_file_mappings := null, + a_coverage_options ut_coverage_options := null, a_test_file_mappings ut_file_mappings := null, a_client_character_set varchar2 := null, a_random_test_order_seed positive := null, - a_run_tags ut_varchar2_rows := null + a_run_tags varchar2 := null, + a_support_info boolean := true ) return self as result, - overriding member procedure mark_as_skipped(self in out nocopy ut_run), + member function get_support_info_flag return boolean, + overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2), overriding member function do_execute(self in out nocopy ut_run) return boolean, overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false), overriding member procedure calc_execution_result(self in out nocopy ut_run), diff --git a/source/core/types/ut_run_info.tpb b/source/core/types/ut_run_info.tpb index 8e06d6137..509960b05 100644 --- a/source/core/types/ut_run_info.tpb +++ b/source/core/types/ut_run_info.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_run_info as +create or replace noneditionable type body ut_run_info as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -12,7 +12,7 @@ create or replace type body ut_run_info as Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions andTEST_GET_REPORTERS_LIST + See the License for the specific language governing permissions and limitations under the License. */ constructor function ut_run_info(self in out nocopy ut_run_info) return self as result is @@ -20,27 +20,27 @@ create or replace type body ut_run_info as begin self.self_type := $$plsql_unit; execute immediate - 'select '||l_ut_owner||'.ut.version() from dual' + 'select /*+ no_parallel */ '||l_ut_owner||'.ut.version() from dual' into self.ut_version; dbms_utility.db_version( self.db_version, self.db_compatibility ); db_os_type := dbms_utility.port_string(); execute immediate - 'select '||l_ut_owner||'.ut_key_value_pair(x.product, x.version) from product_component_version x' + 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.product, x.version) from product_component_version x' bulk collect into self.db_component_version; execute immediate - 'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) + 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_session_parameters x' bulk collect into self.nls_session_params; execute immediate - 'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_instance_parameters x' + 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_instance_parameters x' bulk collect into self.nls_instance_params; execute immediate - 'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_database_parameters x' + 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_database_parameters x' bulk collect into self.nls_db_params; return; end; diff --git a/source/core/types/ut_run_info.tps b/source/core/types/ut_run_info.tps index f59c22c05..b8ad8c55b 100644 --- a/source/core/types/ut_run_info.tps +++ b/source/core/types/ut_run_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_run_info under ut_event_item ( +create or replace noneditionable type ut_run_info under ut_event_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_stack.tpb b/source/core/types/ut_stack.tpb new file mode 100644 index 000000000..40ba8982b --- /dev/null +++ b/source/core/types/ut_stack.tpb @@ -0,0 +1,58 @@ +create or replace noneditionable type body ut_stack as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_stack( self in out nocopy ut_stack) return self as result is + begin + self.tokens := ut_varchar2_list(); + self.top := 0; + return; + end ut_stack; + + member function peek(self in out nocopy ut_stack) return varchar2 is + l_token varchar2(32767); + begin + if self.tokens.count =0 or self.tokens is null then + l_token := null; + else + l_token := self.tokens(self.tokens.last); + end if; + return l_token; + end; + + member procedure push(self in out nocopy ut_stack, a_token varchar2) is + begin + self.tokens.extend; + self.tokens(self.tokens.last) := a_token; + self.top := self.tokens.count; + end push; + + member procedure pop(self in out nocopy ut_stack,a_cnt in integer default 1) is + begin + self.tokens.trim(a_cnt); + self.top := self.tokens.count; + end pop; + + member function pop(self in out nocopy ut_stack) return varchar2 is + l_token varchar2(32767) := self.tokens(self.tokens.last); + begin + self.pop(); + return l_token; + end; +end; +/ + diff --git a/source/core/types/ut_stack.tps b/source/core/types/ut_stack.tps new file mode 100644 index 000000000..9356c4eb2 --- /dev/null +++ b/source/core/types/ut_stack.tps @@ -0,0 +1,26 @@ +create or replace noneditionable type ut_stack as object ( + top integer, + tokens ut_varchar2_list, + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + constructor function ut_stack( self in out nocopy ut_stack) return self as result, + member function peek(self in out nocopy ut_stack) return varchar2, + member procedure push(self in out nocopy ut_stack, a_token varchar2), + member procedure pop(self in out nocopy ut_stack,a_cnt in integer default 1), + member function pop(self in out nocopy ut_stack) return varchar2 +) +/ \ No newline at end of file diff --git a/source/core/types/ut_suite.tpb b/source/core/types/ut_suite.tpb index baaaf044d..7012dee97 100644 --- a/source/core/types/ut_suite.tpb +++ b/source/core/types/ut_suite.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite as +create or replace noneditionable type body ut_suite as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -44,7 +44,7 @@ create or replace type body ut_suite as ut_utils.debug_log('ut_suite.execute'); if self.get_disabled_flag() then - self.mark_as_skipped(); + self.mark_as_skipped(a_skip_reason => self.disabled_reason); else self.start_time := current_timestamp; ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); diff --git a/source/core/types/ut_suite.tps b/source/core/types/ut_suite.tps index ffe2d2d42..3ed0def80 100644 --- a/source/core/types/ut_suite.tps +++ b/source/core/types/ut_suite.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite under ut_logical_suite ( +create or replace noneditionable type ut_suite under ut_logical_suite ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_cache_row.tps b/source/core/types/ut_suite_cache_row.tps index 6817be5ec..2293f9273 100644 --- a/source/core/types/ut_suite_cache_row.tps +++ b/source/core/types/ut_suite_cache_row.tps @@ -1,10 +1,10 @@ -create type ut_suite_cache_row as object ( +create or replace noneditionable type ut_suite_cache_row as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,26 +15,27 @@ create type ut_suite_cache_row as object ( See the License for the specific language governing permissions and limitations under the License. */ - id number(22,0), - self_type varchar2(250 byte), - path varchar2(1000 byte), - object_owner varchar2(250 byte), - object_name varchar2(250 byte), - name varchar2(250 byte), - line_no number, - parse_time timestamp (6), - description varchar2(4000 byte), - rollback_type number, - disabled_flag number, - warnings ut_varchar2_rows, - before_all_list ut_executables, - after_all_list ut_executables, - before_each_list ut_executables, - before_test_list ut_executables, - after_each_list ut_executables, - after_test_list ut_executables, - expected_error_codes ut_integer_list, - tags ut_varchar2_rows, - item ut_executable_test + id number(22,0), + self_type varchar2(250 byte), + path varchar2(1000 byte), + object_owner varchar2(250 byte), + object_name varchar2(250 byte), + name varchar2(250 byte), + line_no number, + parse_time timestamp (6), + description varchar2(4000 byte), + rollback_type number, + disabled_flag number, + disabled_reason varchar2(4000 byte), + warnings ut_varchar2_rows, + before_all_list ut_executables, + after_all_list ut_executables, + before_each_list ut_executables, + before_test_list ut_executables, + after_each_list ut_executables, + after_test_list ut_executables, + expected_error_codes ut_varchar2_rows, + tags ut_varchar2_rows, + item ut_executable_test ) / \ No newline at end of file diff --git a/source/core/types/ut_suite_cache_rows.tps b/source/core/types/ut_suite_cache_rows.tps index 660f934cf..cb3b573eb 100644 --- a/source/core/types/ut_suite_cache_rows.tps +++ b/source/core/types/ut_suite_cache_rows.tps @@ -1,10 +1,10 @@ -create type ut_suite_cache_rows as +create or replace noneditionable type ut_suite_cache_rows as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_context.tpb b/source/core/types/ut_suite_context.tpb index 3669d3d7e..9221cb160 100644 --- a/source/core/types/ut_suite_context.tpb +++ b/source/core/types/ut_suite_context.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite_context as +create or replace noneditionable type body ut_suite_context as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_context.tps b/source/core/types/ut_suite_context.tps index a328e7657..a60899f9b 100644 --- a/source/core/types/ut_suite_context.tps +++ b/source/core/types/ut_suite_context.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_context under ut_suite ( +create or replace noneditionable type ut_suite_context under ut_suite ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_item.tpb b/source/core/types/ut_suite_item.tpb index 6478d5c82..01b9b0ee0 100644 --- a/source/core/types/ut_suite_item.tpb +++ b/source/core/types/ut_suite_item.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite_item as +create or replace noneditionable type body ut_suite_item as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -26,6 +26,7 @@ create or replace type body ut_suite_item as self.line_no := a_line_no; self.transaction_invalidators := ut_varchar2_list(); self.disabled_flag := ut_utils.boolean_to_int(false); + self.disabled_reason := null; end; member function get_disabled_flag return boolean is @@ -97,6 +98,16 @@ create or replace type body ut_suite_item as self.results_count.increase_warning_count; end; + member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2, a_procedure_name varchar2, a_line_no integer) is + l_result varchar2(1000); + begin + l_result := self.object_owner || '.' || self.object_name ; + if a_procedure_name is not null then + l_result := l_result || '.' || a_procedure_name ; + end if; + put_warning( a_message || chr( 10 ) || 'at package "' || upper(l_result) || '", line ' || a_line_no ); + end; + member function get_transaction_invalidators return ut_varchar2_list is begin return transaction_invalidators; diff --git a/source/core/types/ut_suite_item.tps b/source/core/types/ut_suite_item.tps index 53c59a2ea..556ff7f0b 100644 --- a/source/core/types/ut_suite_item.tps +++ b/source/core/types/ut_suite_item.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_item force under ut_event_item ( +create or replace noneditionable type ut_suite_item force under ut_event_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -46,6 +46,10 @@ create or replace type ut_suite_item force under ut_event_item ( */ disabled_flag integer(1), /** + * Indicates reason whysa test is to be disabled by execution + */ + disabled_reason varchar2(4000), + /** * Line no where annotation identifying this item is placed in package */ line_no integer, @@ -66,7 +70,7 @@ create or replace type ut_suite_item force under ut_event_item ( tags ut_varchar2_rows, member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer), member function get_disabled_flag return boolean, - not instantiable member procedure mark_as_skipped(self in out nocopy ut_suite_item), + not instantiable member procedure mark_as_skipped(self in out nocopy ut_suite_item, a_skip_reason in varchar2), member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer, a_force boolean := false), member function get_rollback_type return integer, member function create_savepoint_if_needed return varchar2, @@ -84,7 +88,8 @@ create or replace type ut_suite_item force under ut_event_item ( not instantiable member procedure mark_as_errored(self in out nocopy ut_suite_item, a_error_stack_trace varchar2), not instantiable member function get_error_stack_traces return ut_varchar2_list, not instantiable member function get_serveroutputs return clob, - member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2) + member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2), + member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2, a_procedure_name varchar2, a_line_no integer) ) not final not instantiable / diff --git a/source/core/types/ut_suite_items.tps b/source/core/types/ut_suite_items.tps index e80bcc7b4..fe11b732a 100644 --- a/source/core/types/ut_suite_items.tps +++ b/source/core/types/ut_suite_items.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_items as +create or replace noneditionable type ut_suite_items as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_test.tpb b/source/core/types/ut_test.tpb index 9fbcf9269..c3577274c 100644 --- a/source/core/types/ut_test.tpb +++ b/source/core/types/ut_test.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_test as +create or replace noneditionable type body ut_test as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,7 +18,7 @@ create or replace type body ut_test as constructor function ut_test( self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, - a_line_no integer, a_expected_error_codes ut_integer_list := null, a_tags ut_varchar2_rows := null + a_line_no integer, a_expected_error_codes ut_varchar2_rows := null, a_tags ut_varchar2_rows := null ) return self as result is begin self.self_type := $$plsql_unit; @@ -35,11 +35,12 @@ create or replace type body ut_test as return; end; - overriding member procedure mark_as_skipped(self in out nocopy ut_test) is + overriding member procedure mark_as_skipped(self in out nocopy ut_test, a_skip_reason in varchar2) is begin ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self); self.start_time := current_timestamp; self.result := ut_utils.gc_disabled; + self.disabled_reason := coalesce(a_skip_reason,self.disabled_reason); ut_utils.debug_log('ut_test.execute - disabled'); self.results_count.set_counter_values(self.result); self.end_time := self.start_time; @@ -54,7 +55,7 @@ create or replace type body ut_test as ut_utils.debug_log('ut_test.execute'); if self.get_disabled_flag() then - mark_as_skipped(); + mark_as_skipped(self.disabled_reason); else self.start_time := current_timestamp; ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self); diff --git a/source/core/types/ut_test.tps b/source/core/types/ut_test.tps index fcf565671..7590abc35 100644 --- a/source/core/types/ut_test.tps +++ b/source/core/types/ut_test.tps @@ -1,10 +1,10 @@ -create or replace type ut_test force under ut_suite_item ( +create or replace noneditionable type ut_test force under ut_suite_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -54,12 +54,12 @@ create or replace type ut_test force under ut_suite_item ( /** *Holds the expected error codes list when the user use the annotation throws */ - expected_error_codes ut_integer_list, + expected_error_codes ut_varchar2_rows, constructor function ut_test( self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, - a_line_no integer, a_expected_error_codes ut_integer_list := null, a_tags ut_varchar2_rows := null + a_line_no integer, a_expected_error_codes ut_varchar2_rows := null, a_tags ut_varchar2_rows := null ) return self as result, - overriding member procedure mark_as_skipped(self in out nocopy ut_test), + overriding member procedure mark_as_skipped(self in out nocopy ut_test, a_skip_reason in varchar2), overriding member function do_execute(self in out nocopy ut_test) return boolean, overriding member procedure calc_execution_result(self in out nocopy ut_test), overriding member procedure mark_as_errored(self in out nocopy ut_test, a_error_stack_trace varchar2), diff --git a/source/core/types/ut_varchar2_list.tps b/source/core/types/ut_varchar2_list.tps index dd15f0d8f..86c26d4de 100644 --- a/source/core/types/ut_varchar2_list.tps +++ b/source/core/types/ut_varchar2_list.tps @@ -1,10 +1,10 @@ -create or replace type ut_varchar2_list as +create or replace noneditionable type ut_varchar2_list as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_varchar2_rows.tps b/source/core/types/ut_varchar2_rows.tps index d56eeee46..f34f990e6 100644 --- a/source/core/types/ut_varchar2_rows.tps +++ b/source/core/types/ut_varchar2_rows.tps @@ -1,10 +1,10 @@ -create or replace type ut_varchar2_rows as +create or replace noneditionable type ut_varchar2_rows as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_dbms_output_cache.sql b/source/core/ut_dbms_output_cache.sql index 1fe4251c7..344afc7aa 100644 --- a/source/core/ut_dbms_output_cache.sql +++ b/source/core/ut_dbms_output_cache.sql @@ -1,15 +1,16 @@ /* -utPLSQL - Version 3 -Copyright 2016 - 2019 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ /* * This table is not a global temporary table as it needs to allow cross-session data exchange @@ -19,7 +20,7 @@ limitations under the License. declare l_tab_exist number; begin - select count(*) into l_tab_exist from + select /*+ no_parallel */ count(*) into l_tab_exist from (select table_name from all_tables where table_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA') union all select synonym_name from all_synonyms where synonym_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA')); diff --git a/source/core/ut_expectation_processor.pkb b/source/core/ut_expectation_processor.pkb index 0c2580220..e95576d8e 100644 --- a/source/core/ut_expectation_processor.pkb +++ b/source/core/ut_expectation_processor.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_expectation_processor as +create or replace noneditionable package body ut_expectation_processor as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -104,7 +104,7 @@ create or replace package body ut_expectation_processor as function get_session_parameters return tt_nls_params is l_session_params tt_nls_params; begin - select nsp.parameter, nsp.value + select /*+ no_parallel */ nsp.parameter, nsp.value bulk collect into l_session_params from nls_session_parameters nsp where parameter @@ -149,27 +149,28 @@ create or replace package body ut_expectation_processor as end; function who_called_expectation(a_call_stack varchar2) return varchar2 is - l_caller_stack_line varchar2(4000); - l_call_stack varchar2(4000); + c_max_source_line_len constant integer := 500; + l_caller_stack_line varchar2(32767); + l_call_stack varchar2(32767); l_line_no integer; l_owner varchar2(1000); l_object_name varchar2(1000); - l_result varchar2(4000); - -- in 12.2 format_call_stack reportes not only package name, but also the procedure name - -- when 11g and 12c reports only package name + l_source_line varchar2(32767); + l_result varchar2(32767); + -- format_call_stack reports not only package name, but also the procedure name function cut_header_and_expectations( a_stack varchar2 ) return varchar2 is begin - return regexp_substr( a_stack, '(.*\.(UT_EXPECTATION[A-Z0-9#_$]*|UT|UTASSERT2?)(\.[A-Z0-9#_$]+)?\s+)+((.|\s)*)', 1, 1, 'm', 4); + return regexp_substr( a_stack, '(.*\.(UT_EQUAL|UT_BE_WITHIN[[:alnum:]$#_]*|UT_EXPECTATION[[:alnum:]$#_]*|UT|UTASSERT2?)(\.[[:alnum:]$#_]+)?\s+)+((.|\s)*)', 1, 1, 'm', 4); end; function cut_address_columns( a_stack varchar2 ) return varchar2 is begin - return regexp_replace( a_stack, '^(0x)?[0-9a-f]+\s+', '', 1, 0, 'm' ); + return regexp_replace( a_stack, '^(0x)?[[:digit:]abcdef]+\s+', '', 1, 0, 'mi' ); end; function cut_framework_stack( a_stack varchar2 ) return varchar2 is begin return regexp_replace( a_stack, - '[0-9]+\s+anonymous\s+block\s+[0-9]+\s+package\s+body\s+sys\.dbms_sql(\.execute)?\s+[0-9]+\s+[0-9_$#a-z ]+\.ut_executable.*', + '[0-9]+\s+anonymous\s+block\s+[0-9]+\s+package\s+body\s+sys\.dbms_sql(\.execute)?\s+[0-9]+\s+[[:alnum:]_$# ]+\.ut_executable.*', '', 1, 1, 'mni' ); @@ -178,7 +179,7 @@ create or replace package body ut_expectation_processor as begin return regexp_replace( a_stack, - '([0-9]+)\s+(.* )?((anonymous block)|(([0-9_$#a-z]+\.[0-9_$#a-z]+(\.([0-9_$#a-z])+)?)))', + '([0-9]+)\s+(.* )?((anonymous block)|(([[:alnum:]$#_]+\.[[:alnum:]$#_]+(\.([[:alnum:]$#_])+)?)))', 'at "\3", line \1', 1, 0, 'i' ); end; @@ -190,15 +191,23 @@ create or replace package body ut_expectation_processor as l_caller_stack_line := regexp_substr(l_call_stack,'^(.*)'); if l_caller_stack_line like '%.%' then l_line_no := to_number( regexp_substr( l_caller_stack_line, ', line (\d+)', subexpression => 1 ) ); - l_owner := regexp_substr( l_caller_stack_line, 'at "([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?)", line (\d+)', subexpression => 1 ); - l_object_name := regexp_substr( l_caller_stack_line, 'at "([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?)", line (\d+)', subexpression => 3 ); + l_owner := regexp_substr( l_caller_stack_line, 'at "([[:alnum:]$#_]+)\.(([[:alnum:]$#_]+)(\.([[:alnum:]$#_]+))?)", line (\d+)', subexpression => 1 ); + l_object_name := regexp_substr( l_caller_stack_line, 'at "([[:alnum:]$#_]+)\.(([[:alnum:]$#_]+)(\.([[:alnum:]$#_]+))?)", line (\d+)', subexpression => 3 ); + l_source_line := rtrim(ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no),chr(10)); + if length( l_source_line ) > c_max_source_line_len then + l_source_line := substr( l_source_line, 1, c_max_source_line_len - ut_utils.gc_more_data_string_len ) || ut_utils.gc_more_data_string; + end if; l_result := - l_caller_stack_line || ' ' || rtrim(ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no),chr(10)) + l_caller_stack_line || ' ' || l_source_line || replace( l_call_stack, l_caller_stack_line ); else l_result := l_call_stack; end if; - return rtrim(l_result,chr(10)); + l_result := rtrim(l_result,chr(10)); + if lengthb( l_result ) > ut_utils.gc_max_storage_varchar2_len then + l_result := substrb( l_result, 1, ut_utils.gc_max_storage_varchar2_len - ut_utils.gc_more_data_string_len ) || ut_utils.gc_more_data_string; + end if; + return l_result; end; procedure add_warning(a_messsage varchar2) is diff --git a/source/core/ut_expectation_processor.pks b/source/core/ut_expectation_processor.pks index cfcae8b42..8d19becce 100644 --- a/source/core/ut_expectation_processor.pks +++ b/source/core/ut_expectation_processor.pks @@ -1,10 +1,10 @@ -create or replace package ut_expectation_processor authid current_user as +create or replace noneditionable package ut_expectation_processor authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_file_mapper.pkb b/source/core/ut_file_mapper.pkb index adecb7dc8..8cb3f3911 100644 --- a/source/core/ut_file_mapper.pkb +++ b/source/core/ut_file_mapper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_file_mapper is +create or replace noneditionable package body ut_file_mapper is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_file_mapper.pks b/source/core/ut_file_mapper.pks index 4ed670ee5..e1ce48a54 100644 --- a/source/core/ut_file_mapper.pks +++ b/source/core/ut_file_mapper.pks @@ -1,10 +1,10 @@ -create or replace package ut_file_mapper authid current_user is +create or replace noneditionable package ut_file_mapper authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_metadata.pkb b/source/core/ut_metadata.pkb index 7859d6b3f..ed8391638 100644 --- a/source/core/ut_metadata.pkb +++ b/source/core/ut_metadata.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_metadata as +create or replace noneditionable package body ut_metadata as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -39,7 +39,7 @@ create or replace package body ut_metadata as l_view_name varchar2(200) := get_objects_view_name; begin - execute immediate q'[select count(*) + execute immediate q'[select /*+ no_parallel */ count(*) from ]'||l_view_name||q'[ where owner = :a_owner_name and object_name = :a_package_name @@ -58,7 +58,7 @@ create or replace package body ut_metadata as l_view_name varchar2(200) := get_dba_view('dba_procedures'); begin execute immediate - 'select count(*) from '||l_view_name + 'select /*+ no_parallel */ count(*) from '||l_view_name ||' where owner = :l_schema and object_name = :l_package_name and procedure_name = :l_procedure_name and rownum = 1' into l_cnt using a_owner_name, a_package_name, a_procedure_name; @@ -77,13 +77,24 @@ create or replace package body ut_metadata as if not nvl(c_key = g_cached_object, false) then g_cached_object := c_key; execute immediate - 'select trim(text) text - from '||l_view_name||q'[ s - where s.owner = :a_owner - and s.name = :a_object_name - /*skip the declarations, consider only definitions*/ - and s.type not in ('PACKAGE', 'TYPE') - order by line]' + 'with + all_source_filter as ( + select /*+ no_parallel */ + lag( + case when substr(text, -1) = chr(10) then 1 else 0 end + , 1 + ) over (partition by owner, name, type order by line) prev_line_end, + line, text + from '||l_view_name||q'[ a + where a.owner = :a_owner + and a.name = :a_object_name + /*skip the declarations, consider only definitions*/ + and a.type not in ('PACKAGE', 'TYPE') + ) + select trim(s.text) + from all_source_filter s + where nvl(s.prev_line_end, 1) > 0 + order by s.line]' bulk collect into g_source_cache using a_owner, a_object_name; end if; @@ -121,9 +132,26 @@ create or replace package body ut_metadata as end; function user_has_execute_any_proc return boolean is - l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_has_execute_any varchar2(1); begin - return is_object_visible(l_ut_owner||'.ut_utils'); + select /*+ no_parallel */ decode( count( 1 ), 0, 'N', 'Y' ) + into l_has_execute_any + from dual + where + exists( + select 1 + from + role_sys_privs + join session_roles + using ( role ) + where privilege = 'EXECUTE ANY PROCEDURE' + ) or + exists( + select 1 + from user_sys_privs + where privilege = 'EXECUTE ANY PROCEDURE' + ); + return l_has_execute_any = 'Y'; end; function is_object_visible(a_object_name varchar2) return boolean is @@ -140,7 +168,7 @@ create or replace package body ut_metadata as l_cnt number; c_current_schema constant all_tables.owner%type := sys_context('USERENV','CURRENT_SCHEMA'); begin - select count(*) + select /*+ no_parallel */ count(*) into l_cnt from all_objects t where t.object_name = a_object_name @@ -287,7 +315,7 @@ create or replace package body ut_metadata as begin l_result := regexp_substr( a_full_object_name, - '^([A-Za-z0-9$#_]+|".*?")\.([A-Za-z0-9$#_]+|".*?")', subexpression => 2 + '^([[:alnum:]$#_]+|".*?")\.([[:alnum:]$#_]+|".*?")', subexpression => 2 ); if not l_result like '"%"' then l_result := upper(l_result); diff --git a/source/core/ut_metadata.pks b/source/core/ut_metadata.pks index bf62c4e52..f320e7bf8 100644 --- a/source/core/ut_metadata.pks +++ b/source/core/ut_metadata.pks @@ -1,10 +1,10 @@ -create or replace package ut_metadata authid current_user as +create or replace noneditionable package ut_metadata authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_savepoint_seq.sql b/source/core/ut_savepoint_seq.sql index e1d80f452..393c2419a 100644 --- a/source/core/ut_savepoint_seq.sql +++ b/source/core/ut_savepoint_seq.sql @@ -1,9 +1,9 @@ create sequence ut_savepoint_seq /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -12,4 +12,4 @@ create sequence ut_savepoint_seq See the License for the specific language governing permissions and limitations under the License. */ - start with 1 cache 20; \ No newline at end of file + start with 1 cache 20 minvalue 1 maxvalue 99999999999999999 cycle; \ No newline at end of file diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 101ab2179..0c9bbc982 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_suite_builder is +create or replace noneditionable package body ut_suite_builder is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,7 +15,7 @@ create or replace package body ut_suite_builder is See the License for the specific language governing permissions and limitations under the License. */ - + subtype t_annotation_text is varchar2(4000); subtype t_annotation_name is varchar2(4000); subtype t_object_name is varchar2(500); @@ -36,6 +36,7 @@ create or replace package body ut_suite_builder is gc_throws constant t_annotation_name := 'throws'; gc_rollback constant t_annotation_name := 'rollback'; gc_context constant t_annotation_name := 'context'; + gc_name constant t_annotation_name := 'name'; gc_endcontext constant t_annotation_name := 'endcontext'; type tt_annotations is table of t_annotation_name; @@ -57,12 +58,10 @@ create or replace package body ut_suite_builder is gc_throws, gc_rollback, gc_context, + gc_name, gc_endcontext ); - gc_integer_exception constant varchar2(1) := 'I'; - gc_named_exception constant varchar2(1) := 'N'; - type tt_executables is table of ut_executables index by t_annotation_position; type t_annotation is record( @@ -95,27 +94,6 @@ create or replace package body ut_suite_builder is by_name tt_annotations_by_name ); - function get_qualified_object_name( - a_suite ut_suite_item, a_procedure_name t_object_name - ) return varchar2 is - l_result varchar2(1000); - begin - if a_suite is not null then - l_result := upper( a_suite.object_owner || '.' || a_suite.object_name ); - if a_procedure_name is not null then - l_result := l_result || upper( '.' || a_procedure_name ); - end if; - end if; - return l_result; - end; - - function get_object_reference( - a_suite ut_suite_item, a_procedure_name t_object_name, a_line_no binary_integer - ) return varchar2 is - begin - return chr( 10 ) || 'at package "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no; - end; - procedure delete_annotations_range( a_annotations in out nocopy t_annotations_info, a_start_pos t_annotation_position, @@ -161,8 +139,9 @@ create or replace package body ut_suite_builder is ) is begin a_suite.put_warning( - replace(a_message,'%%%','"--%'||a_annotation||'"') - || ' Annotation ignored.' || get_object_reference( a_suite, a_procedure_name, a_line_no ) + replace(a_message,'%%%','"--%'||a_annotation||'"')|| ' Annotation ignored.', + a_procedure_name, + a_line_no ); end; @@ -179,168 +158,72 @@ create or replace package body ut_suite_builder is procedure add_to_throws_numbers_list( a_suite in out nocopy ut_suite, - a_list in out nocopy ut_integer_list, + a_list in out nocopy ut_varchar2_rows, a_procedure_name t_object_name, a_throws_ann_text tt_annotation_texts ) is l_annotation_pos binary_integer; - function is_valid_qualified_name (a_name varchar2) return boolean is - l_name varchar2(500); - begin - l_name := dbms_assert.qualified_sql_name(a_name); - return true; - exception when others then - return false; - end; - - function check_exception_type(a_exception_name in varchar2) return varchar2 is - l_exception_type varchar2(50); - begin - --check if it is a predefined exception - begin - execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; - l_exception_type := gc_named_exception; - exception - when others then - if dbms_utility.format_error_stack() like '%PLS-00485%' then - begin - execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;'; - l_exception_type := gc_integer_exception; - exception - when others then - --invalid exception number (positive) - --TODO add warning for this value - null; - end; - end if; - end; - return l_exception_type; - end; - - function get_exception_number (a_exception_var in varchar2) return integer is - l_exc_no integer; - l_exc_type varchar2(50); - function remap_no_data_found (a_number integer) return integer is - begin - return case a_number when 100 then -1403 else a_number end; - end; - begin - l_exc_type := check_exception_type(a_exception_var); - - if l_exc_type is not null then - - execute immediate - case l_exc_type - when gc_integer_exception then - 'declare - l_exception number; - begin - :l_exception := '||a_exception_var||'; ' - when gc_named_exception then - 'begin - raise '||a_exception_var||'; - exception - when others then - :l_exception := sqlcode; ' - end || - 'end;' - using out l_exc_no; - - end if; - return remap_no_data_found(l_exc_no); - end; - - function build_exception_numbers_list( - a_suite in out nocopy ut_suite, - a_procedure_name t_object_name, - a_line_no integer, - a_annotation_text in varchar2 - ) return ut_integer_list is - l_throws_list ut_varchar2_list; - l_exception_number integer; - l_exception_number_list ut_integer_list := ut_integer_list(); - c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$'; - begin - --the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers - l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y')); - - for i in 1 .. l_throws_list.count - loop - /** - * Check if its a valid qualified name and if so try to resolve name to an exception number - */ - if is_valid_qualified_name(l_throws_list(i)) then - l_exception_number := get_exception_number(l_throws_list(i)); - elsif regexp_like(l_throws_list(i), c_regexp_for_exception_no) then - l_exception_number := l_throws_list(i); - end if; - - if l_exception_number is null then - a_suite.put_warning( - 'Invalid parameter value "'||l_throws_list(i) - ||'" for "--%throws" annotation. Parameter ignored.'||get_object_reference( a_suite, a_procedure_name, a_line_no ) - ); - else - l_exception_number_list.extend; - l_exception_number_list(l_exception_number_list.last) := l_exception_number; - end if; - l_exception_number := null; - end loop; - - return l_exception_number_list; - end; - begin - a_list := ut_integer_list(); l_annotation_pos := a_throws_ann_text.first; while l_annotation_pos is not null loop if a_throws_ann_text(l_annotation_pos) is null then a_suite.put_warning( - '"--%throws" annotation requires a parameter. Annotation ignored.' - || get_object_reference( a_suite, a_procedure_name, l_annotation_pos ) + '"--%throws" annotation requires a parameter. Annotation ignored.', + a_procedure_name, + l_annotation_pos ); else - a_list := - a_list multiset union - build_exception_numbers_list( - a_suite, - a_procedure_name, - l_annotation_pos, - a_throws_ann_text(l_annotation_pos) - ); + ut_utils.append_to_list( + a_list, + ut_utils.convert_collection( ut_utils.trim_list_elements ( ut_utils.string_to_table( a_throws_ann_text(l_annotation_pos), ',' ) ) ) + ); end if; l_annotation_pos := a_throws_ann_text.next(l_annotation_pos); end loop; end; - + procedure add_tags_to_suite_item( a_suite in out nocopy ut_suite, a_tags_ann_text tt_annotation_texts, a_list in out nocopy ut_varchar2_rows, a_procedure_name t_object_name := null - ) is + ) is l_annotation_pos binary_integer; - l_tag_list ut_varchar2_list := ut_varchar2_list(); + l_tags_list ut_varchar2_list := ut_varchar2_list(); + l_tag_items ut_varchar2_list; begin l_annotation_pos := a_tags_ann_text.first; while l_annotation_pos is not null loop if a_tags_ann_text(l_annotation_pos) is null then a_suite.put_warning( - '"--%tags" annotation requires a tag value populated. Annotation ignored.' - || get_object_reference( a_suite, a_procedure_name, l_annotation_pos ) + '"--%tags" annotation requires a tag value populated. Annotation ignored.', + a_procedure_name, + l_annotation_pos ); else - l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements( - ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',') - ); + l_tag_items := ut_utils.trim_list_elements(ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')); + if l_tag_items is not empty then + for i in 1 .. l_tag_items.count loop + if regexp_like(l_tag_items(i),'^[^-](\S)+$') then + l_tags_list.extend(); + l_tags_list(l_tags_list.last) := l_tag_items(i); + else + a_suite.put_warning( + 'Invalid value "'||l_tag_items(i)||'" for "--%tags" annotation. See documentation for details on valid tag values. Annotation value ignored.', + a_procedure_name, + l_annotation_pos + ); + end if; + end loop; + end if; end if; l_annotation_pos := a_tags_ann_text.next(l_annotation_pos); end loop; - --remove empty strings from table list e.g. tag1,,tag2 and conver to rows - a_list := ut_utils.convert_collection( ut_utils.filter_list(l_tag_list,ut_utils.gc_word_no_space) ); + --remove empty strings from table list e.g. tag1,,tag2 and convert to rows + a_list := ut_utils.convert_collection( ut_utils.filter_list(set(l_tags_list),ut_utils.gc_word_no_space) ); end; - + procedure set_seq_no( a_list in out nocopy ut_executables ) is @@ -472,6 +355,7 @@ create or replace package body ut_suite_builder is l_annotation_texts tt_annotation_texts; l_proc_annotations tt_annotations_by_name := a_annotations.by_proc(a_procedure_name); begin + if not l_proc_annotations.exists(gc_test) then return; end if; @@ -519,16 +403,22 @@ create or replace package body ut_suite_builder is ); set_seq_no(l_test.after_test_list); end if; - + if l_proc_annotations.exists( gc_tags) then add_tags_to_suite_item(a_suite, l_proc_annotations( gc_tags), l_test.tags, a_procedure_name); end if; - + if l_proc_annotations.exists( gc_throws) then add_to_throws_numbers_list(a_suite, l_test.expected_error_codes, a_procedure_name, l_proc_annotations( gc_throws)); end if; l_test.disabled_flag := ut_utils.boolean_to_int( l_proc_annotations.exists( gc_disabled)); - + + if l_proc_annotations.exists(gc_disabled) then + l_annotation_texts := l_proc_annotations( gc_disabled); + --take the last definition if more than one was provided + l_test.disabled_reason := l_annotation_texts(l_annotation_texts.first); + end if; + a_suite_items.extend; a_suite_items( a_suite_items.last ) := l_test; @@ -625,7 +515,7 @@ create or replace package body ut_suite_builder is a_suite.path := lower(coalesce(a_suite.path, a_suite.object_name)); end; - procedure add_suite_tests( + procedure add_tests_to_items( a_suite in out nocopy ut_suite, a_annotations t_annotations_info, a_suite_items in out nocopy ut_suite_items @@ -673,12 +563,16 @@ create or replace package body ut_suite_builder is if a_annotations.by_name.exists(gc_aftereach) then l_after_each_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_aftereach), gc_aftereach ); end if; - + if a_annotations.by_name.exists(gc_tags) then add_tags_to_suite_item(a_suite, a_annotations.by_name(gc_tags),a_suite.tags); end if; + a_suite.disabled_flag := ut_utils.boolean_to_int(a_annotations.by_name.exists(gc_disabled)); - + if a_annotations.by_name.exists(gc_disabled) then + a_suite.disabled_reason := a_annotations.by_name(gc_disabled)(a_annotations.by_name(gc_disabled).first); + end if; + --process procedure annotations for suite get_annotated_procedures(a_annotations, a_suite, a_suite_items, l_before_each_list, l_after_each_list, l_before_all_list, l_after_all_list); @@ -690,21 +584,59 @@ create or replace package body ut_suite_builder is set_seq_no(a_suite.after_all_list); end; + function get_next_annotation_of_type( + a_start_position t_annotation_position, + a_annotation_type varchar2, + a_package_annotations in tt_annotations_by_name + ) return t_annotation_position is + l_result t_annotation_position; + begin + if a_package_annotations.exists(a_annotation_type) then + l_result := a_package_annotations(a_annotation_type).first; + while l_result <= a_start_position loop + l_result := a_package_annotations(a_annotation_type).next(l_result); + end loop; + end if; + return l_result; + end; + function get_endcontext_position( a_context_ann_pos t_annotation_position, - a_package_annotations in out nocopy tt_annotations_by_name + a_package_annotations in tt_annotations_by_line ) return t_annotation_position is l_result t_annotation_position; + l_open_count integer := 1; + l_idx t_annotation_position := a_package_annotations.next(a_context_ann_pos); begin - if a_package_annotations.exists(gc_endcontext) then - l_result := a_package_annotations(gc_endcontext).first; - while l_result <= a_context_ann_pos loop - l_result := a_package_annotations(gc_endcontext).next(l_result); - end loop; + while l_open_count > 0 and l_idx is not null loop + if ( a_package_annotations(l_idx).name = gc_context ) then + l_open_count := l_open_count+1; + elsif ( a_package_annotations(l_idx).name = gc_endcontext ) then + l_open_count := l_open_count-1; + l_result := l_idx; + end if; + l_idx := a_package_annotations.next(l_idx); + end loop; + if ( l_open_count > 0 ) then + l_result := null; end if; return l_result; end; + function has_nested_context( + a_context_ann_pos t_annotation_position, + a_package_annotations in tt_annotations_by_name + ) return boolean is + l_next_endcontext_pos t_annotation_position := 0; + l_next_context_pos t_annotation_position := 0; + begin + if ( a_package_annotations.exists(gc_endcontext) and a_package_annotations.exists(gc_context)) then + l_next_endcontext_pos := get_next_annotation_of_type(a_context_ann_pos, gc_endcontext, a_package_annotations); + l_next_context_pos := a_package_annotations(gc_context).next(a_context_ann_pos); + end if; + return ( l_next_context_pos < l_next_endcontext_pos ); + end; + function get_annotations_in_context( a_annotations t_annotations_info, a_context_pos t_annotation_position, @@ -735,90 +667,147 @@ create or replace package body ut_suite_builder is return l_result; end; - procedure get_suite_contexts_items( - a_suite in out nocopy ut_suite, + procedure get_context_items( + a_parent in out nocopy ut_suite, a_annotations in out nocopy t_annotations_info, - a_suite_items out nocopy ut_suite_items + a_suite_items out nocopy ut_suite_items, + a_parent_context_pos in integer := 0, + a_parent_end_context_pos in integer default null ) is - l_context_pos t_annotation_position; - l_end_context_pos t_annotation_position; - l_context_name t_object_name; - l_ctx_annotations t_annotations_info; - l_context ut_suite_context; - l_context_no binary_integer := 1; - l_context_items ut_suite_items; + l_context_pos t_annotation_position; + l_next_context_pos t_annotation_position; + l_end_context_pos t_annotation_position; + l_ctx_annotations t_annotations_info; + l_context ut_suite_context; + l_context_no binary_integer := 1; + l_context_items ut_suite_items; type tt_context_names is table of boolean index by t_object_name; - l_context_names tt_context_names; + l_used_context_names tt_context_names; + l_context_name t_object_name; + l_default_context_name t_object_name; + function get_context_name( + a_parent in out nocopy ut_suite, + a_start_position binary_integer + ) return varchar2 is + l_result t_annotation_name; + l_found boolean; + l_end_position binary_integer; + l_annotation_pos binary_integer; + l_context_names tt_annotation_texts; + begin + if a_annotations.by_name.exists(gc_name) then + l_context_names := a_annotations.by_name( gc_name ); + -- Maximum end-position to look for %name annotation is either the next %context or the next %endcontext annotation + l_end_position := + least( + coalesce( get_next_annotation_of_type(a_start_position, gc_endcontext, a_annotations.by_name), a_annotations.by_line.last ), + coalesce( get_next_annotation_of_type(a_start_position, gc_context, a_annotations.by_name), a_annotations.by_line.last ) + ); + l_annotation_pos := l_context_names.first; + + while l_annotation_pos is not null loop + if l_annotation_pos > a_start_position and l_annotation_pos < l_end_position then + if l_found then + add_annotation_ignored_warning(a_parent, gc_name,'Duplicate annotation %%%.', l_annotation_pos); + else + l_result := l_context_names(l_annotation_pos); + end if; + l_found := true; + end if; + l_annotation_pos := l_context_names.next(l_annotation_pos); + end loop; + end if; + return l_result; + end; begin a_suite_items := ut_suite_items(); if not a_annotations.by_name.exists(gc_context) then return; end if; - l_context_pos := a_annotations.by_name( gc_context).first; + l_context_pos := a_annotations.by_name( gc_context).next(a_parent_context_pos); while l_context_pos is not null loop - l_end_context_pos := get_endcontext_position(l_context_pos, a_annotations.by_name ); - - exit when l_end_context_pos is null; + l_default_context_name := 'nested_context_#'||l_context_no; + l_context_name := null; + l_end_context_pos := get_endcontext_position(l_context_pos, a_annotations.by_line ); + l_next_context_pos := a_annotations.by_name(gc_context).next(l_context_pos); + l_context_name := get_context_name(a_parent, l_context_pos); + if not regexp_like( l_context_name, '^(\w|[$#])+$' ) or l_context_name is null then + if not regexp_like( l_context_name, '^(\w|[$#])+$' ) then + a_parent.put_warning( + 'Invalid value "'||l_context_name||'" for context name.' || + ' Context name ignored and fallback to auto-name "'||l_default_context_name||'" ', + null, + l_context_pos + ); + end if; + l_context_name := l_default_context_name; + end if; + if l_used_context_names.exists(l_context_name) then + add_annotation_ignored_warning( + a_parent, gc_name, + 'Context name "'||l_context_name||'" already used in this scope. Name must be unique.' || + ' Using fallback name '||l_default_context_name||'.', l_context_pos ); + l_context_name := l_default_context_name; + end if; + l_used_context_names(l_context_name) := true; - l_context_items := ut_suite_items(); - --create a sub-set of annotations to process as sub-suite (context) - l_ctx_annotations := get_annotations_in_context( a_annotations, l_context_pos, l_end_context_pos); + l_context := ut_suite_context(a_parent.object_owner, a_parent.object_name, l_context_name, l_context_pos ); + l_context.path := a_parent.path||'.'||l_context.name; + l_context.description := coalesce( a_annotations.by_line( l_context_pos ).text, l_context_name ); + l_context.parse_time := a_annotations.parse_time; - l_context_name := coalesce( - l_ctx_annotations.by_line( l_context_pos ).text - , gc_context||'_'||l_context_no - ); - if l_context_names.exists(l_context_name) then - add_annotation_ignored_warning( a_suite, 'context', 'Context name must be unique in a suite. Context and all of it''s content ignored.', l_context_pos ); + --if nested context found + if has_nested_context(l_context_pos, a_annotations.by_name) then + get_context_items( l_context, a_annotations, l_context_items, l_context_pos, l_end_context_pos ); else - l_context_names(l_context_name) := true; + l_context_items := ut_suite_items(); + end if; - l_context := ut_suite_context(a_suite.object_owner, a_suite.object_name, l_context_name, l_context_pos ); + if l_end_context_pos is null then + a_parent.put_warning( + 'Missing "--%endcontext" annotation for a "--%context" annotation. The end of package is considered end of context.', + null, + l_context_pos + ); + l_end_context_pos := a_annotations.by_line.last; + end if; - l_context.path := a_suite.path||'.'||l_context_name; - l_context.description := l_ctx_annotations.by_line( l_context_pos ).text; - l_context.parse_time := a_annotations.parse_time; + --create a sub-set of annotations to process as sub-suite (context) + l_ctx_annotations := get_annotations_in_context( a_annotations, l_context_pos, l_end_context_pos); - warning_on_duplicate_annot( l_context, l_ctx_annotations.by_name, gc_context ); + warning_on_duplicate_annot( l_context, l_ctx_annotations.by_name, gc_context ); - add_suite_tests( l_context, l_ctx_annotations, l_context_items ); - add_items_to_list(a_suite_items, l_context_items); - a_suite_items.extend; - a_suite_items(a_suite_items.last) := l_context; - end if; + add_tests_to_items( l_context, l_ctx_annotations, l_context_items ); + add_items_to_list(a_suite_items, l_context_items); + a_suite_items.extend; + a_suite_items(a_suite_items.last) := l_context; -- remove annotations within context after processing them delete_annotations_range(a_annotations, l_context_pos, l_end_context_pos); exit when not a_annotations.by_name.exists( gc_context); l_context_pos := a_annotations.by_name( gc_context).next( l_context_pos); + -- don't go on when the next context is outside the parent's context boundaries + if (a_parent_end_context_pos <= l_context_pos ) then + l_context_pos := null; + end if; l_context_no := l_context_no + 1; end loop; end; - procedure warning_on_incomplete_context( + procedure warning_on_extra_endcontext( a_suite in out nocopy ut_suite, a_package_ann_index tt_annotations_by_name ) is l_annotation_pos t_annotation_position; begin - if a_package_ann_index.exists(gc_context) then - l_annotation_pos := a_package_ann_index(gc_context).first; - while l_annotation_pos is not null loop - add_annotation_ignored_warning( - a_suite, gc_context, 'Invalid annotation %%%. Cannot find following "--%endcontext".', - l_annotation_pos - ); - l_annotation_pos := a_package_ann_index(gc_context).next(l_annotation_pos); - end loop; - end if; if a_package_ann_index.exists(gc_endcontext) then l_annotation_pos := a_package_ann_index(gc_endcontext).first; while l_annotation_pos is not null loop add_annotation_ignored_warning( - a_suite, gc_endcontext, 'Invalid annotation %%%. Cannot find preceding "--%context".', + a_suite, gc_endcontext, 'Extra %%% annotation found. Cannot find corresponding "--%context".', l_annotation_pos ); l_annotation_pos := a_package_ann_index(gc_endcontext).next(l_annotation_pos); @@ -889,12 +878,12 @@ create or replace package body ut_suite_builder is warning_on_duplicate_annot( l_suite, l_annotations.by_name, gc_suite ); build_suitepath( l_suite, l_annotations ); - get_suite_contexts_items( l_suite, l_annotations, a_suite_items ); + get_context_items( l_suite, l_annotations, a_suite_items ); --create suite tests and add - add_suite_tests( l_suite, l_annotations, a_suite_items ); + add_tests_to_items( l_suite, l_annotations, a_suite_items ); --by this time all contexts were consumed and l_annotations should not have any context/endcontext annotation in it. - warning_on_incomplete_context( l_suite, l_annotations.by_name ); + warning_on_extra_endcontext( l_suite, l_annotations.by_name ); a_suite_items.extend; a_suite_items( a_suite_items.last) := l_suite; diff --git a/source/core/ut_suite_builder.pks b/source/core/ut_suite_builder.pks index e982fdbc1..31b76e2c6 100644 --- a/source/core/ut_suite_builder.pks +++ b/source/core/ut_suite_builder.pks @@ -1,10 +1,10 @@ -create or replace package ut_suite_builder authid current_user is +create or replace noneditionable package ut_suite_builder authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_suite_cache.sql b/source/core/ut_suite_cache.sql index a7f998f83..296851a10 100644 --- a/source/core/ut_suite_cache.sql +++ b/source/core/ut_suite_cache.sql @@ -1,9 +1,9 @@ create table ut_suite_cache /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_cache_macros.pkb b/source/core/ut_suite_cache_macros.pkb new file mode 100644 index 000000000..735b81830 --- /dev/null +++ b/source/core/ut_suite_cache_macros.pkb @@ -0,0 +1,46 @@ +create or replace noneditionable package body ut_suite_cache_macros as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + function match_paths(a_items dbms_tf.table_t, a_paths dbms_tf.table_t) return varchar2 sql_macro is + begin + --names: "_" is not a wildcard, "*" is; suitepath patterns: "." and "$" are literal, "*" matches part of a path element + return q'[ + select p.path_id, i.object_owner, i.path + from a_items i + join a_paths p + on i.object_owner = upper(p.schema_name) + where ( p.suite_path is null and p.object_name is null ) + or ( p.suite_path is null + and i.object_name like replace(replace(upper(p.object_name), '_', '\_'), '*', '%') escape '\' + and ( p.procedure_name is null or p.procedure_name = '*' + or i.name like replace(replace(upper(p.procedure_name), '_', '\_'), '*', '%') escape '\' + ) + ) + or ( instr(p.suite_path, '*') = 0 + and ( i.path = p.suite_path or substr(i.path, 1, length(p.suite_path) + 1) = p.suite_path || '.' ) + ) + or ( instr(p.suite_path, '*') > 0 + and regexp_like( + i.path, + '^' || replace(replace(replace(p.suite_path, '.', '\.'), '$', '\$'), '*', '[[:alnum:]$#_]*') + ) + )]'; + end; + +end; +/ diff --git a/source/core/ut_suite_cache_macros.pks b/source/core/ut_suite_cache_macros.pks new file mode 100644 index 000000000..2554ccba2 --- /dev/null +++ b/source/core/ut_suite_cache_macros.pks @@ -0,0 +1,43 @@ +create or replace noneditionable package ut_suite_cache_macros authid definer as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /* + * SQL macros for ut_suite_cache_manager. + * + * A package containing SQL macros cannot be an invoker rights package, so the macros are kept apart from ut_suite_cache_manager. + * A macro only returns SQL text, which is expanded into the calling SQL statement. + * A macro body sees the values of literal arguments only, so the returned text does not depend on argument values. + */ + + /** + * Table SQL macro matching suite items with run paths: the single definition of which items a run path selects. + * Returns one row (path_id, object_owner, path) for every pair of a path and an item it selects: + * - schema: all items of the schema + * - schema.package[.*]: all items of the package + * - schema.package.procedure: the items named like the procedure + * - schema:suite.path: the item at the suitepath and all items below it + * - schema:suite*.path: the items whose path starts with a match of the suitepath pattern + * Package and procedure names may contain wildcards (*). Parents of the selected items are not returned. + * + * @param a_items table or query with columns object_owner, object_name, name, path (as in ut_suite_cache), without collection columns + * @param a_paths table or query with columns path_id and the columns of ut_path_item + */ + function match_paths(a_items dbms_tf.table_t, a_paths dbms_tf.table_t) return varchar2 sql_macro; + +end; +/ diff --git a/source/core/ut_suite_cache_manager.pkb b/source/core/ut_suite_cache_manager.pkb index ef12e1def..a3ff6edfd 100644 --- a/source/core/ut_suite_cache_manager.pkb +++ b/source/core/ut_suite_cache_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_suite_cache_manager is +create or replace noneditionable package body ut_suite_cache_manager is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -17,216 +17,264 @@ create or replace package body ut_suite_cache_manager is */ /* - * Private code + * Public code */ - gc_get_cache_suite_sql constant varchar2(32767) := - q'[with - suite_items as ( - select /*+ cardinality(c 100) */ value(c) as obj - from ut_suite_cache c - where 1 = 1 - and c.object_owner = :l_object_owner - and ( {:path:} - and {:object_name:} - and {:procedure_name:} - ) - ) + function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items is + c_package_path_regex constant varchar2(100) := '^([[:alnum:]$#_]+)(\.([[:alnum:]$#_\*]+))?(\.([[:alnum:]$#_\*]+))?$'; + l_results ut_path_items := ut_path_items(); + l_path_item ut_path_item; + i pls_integer; + begin + i := a_paths.first; + while (i is not null) loop + l_results.extend; + if a_paths(i) like '%:%' then + l_path_item := ut_path_item(schema_name => upper(regexp_substr(a_paths(i),'^[^.:]+')), + suite_path => ltrim(regexp_substr(a_paths(i),'[.:].*$'),':')); + l_results(l_results.last) := l_path_item; + else + l_path_item := ut_path_item(schema_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 1), + object_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 3), + procedure_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 5)); + l_results(l_results.last) := l_path_item; + end if; + i := a_paths.next(i); + end loop; + + return l_results; + end; + + /* + Returns ids of the cache rows the paths select (wildcards included, see ut_suite_cache_macros.match_paths) + and of their parents, only for packages the invoking user can access, unless a_skip_access_check is true. + A separate statement, as a SQL macro cannot be used inside a WITH clause (ORA-64630). + */ + function get_matched_ids( + a_schema_paths ut_path_items, + a_skip_access_check boolean + ) return ut_integer_list is + l_results ut_integer_list; + l_skip_access_check varchar2(1) := case when a_skip_access_check then 'Y' else 'N' end; + begin + --all_objects is used only in the main query: in a WITH clause of a statement with a SQL macro it raises ORA-00942 + with + path_items as ( + select rownum as path_id, sp.schema_name, sp.object_name, sp.procedure_name, sp.suite_path + from table(a_schema_paths) sp + ), + schema_items as ( + --only scalar columns: a table argument of a SQL macro cannot have collection columns (ORA-62558) + select /*+ no_parallel */ c.id, c.object_owner, c.object_name, c.name, c.path + from &&ut3_owner..ut_suite_cache c + where c.object_owner in (select upper(p.schema_name) from path_items p) + ) + select /*+ no_parallel */ distinct r.id + bulk collect into l_results + from (&&ut3_owner..ut_suite_cache_macros.match_paths(schema_items, path_items)) m + join schema_items s + on s.object_owner = m.object_owner + and s.path = m.path + join schema_items r + on r.object_owner = s.object_owner + and ( r.path = s.path or substr(s.path, 1, length(r.path) + 1) = r.path || '.' /* the selected row or its parent */ ) + where l_skip_access_check = 'Y' + or ( exists ( select 1 from all_objects a where a.owner = s.object_owner and a.object_name = s.object_name and a.object_type = 'PACKAGE' ) + and exists ( select 1 from all_objects a where a.owner = r.object_owner and a.object_name = r.object_name and a.object_type = 'PACKAGE' ) + ); + return l_results; + end; + + /* + Returns suite items for the paths, sorted bottom up, so that reconstruct_from_cache in ut_suite_manager + can build the suite hierarchy in a single pass. The statement: + - matched_rows: the rows from get_matched_ids + - tagged_rows: when tags are given, the rows having a test matching the tag expression below them (or being one); + a test inherits the tags of the suites and contexts above it + - logical_suites: suites for the parts of the suitepaths that have no package behind them, + or whose package the user can't access (with a warning in that case) + - ordered: the hierarchy sorted depth first by schema, then by line number, or by a hash of the path when a_random_seed is given + The tag expression is evaluated per test by ut_suite_tag_filter.is_matching, so the statement is static SQL. + Without a_with_executables, the rows have no executables (before/after lists, test item), which only a run needs. + */ + function select_suite_rows( + a_schema_paths ut_path_items, + a_skip_access_check boolean, + a_tags varchar2, + a_random_seed positive, + a_with_executables boolean + ) return ut_suite_cache_rows is + l_results ut_suite_cache_rows; + l_matched_ids ut_integer_list := get_matched_ids(a_schema_paths, a_skip_access_check); + l_with_executables varchar2(1) := case when a_with_executables then 'Y' else 'N' end; + --an expression of spaces and tabs only is no tag filter + l_tags varchar2(32767) := ut_suite_tag_filter.remove_whitespace(a_tags); + begin + with + matched_rows as ( + select /*+ no_parallel */ c.id, c.self_type, c.path, c.object_owner, c.object_name, c.line_no, c.tags + from &&ut3_owner..ut_suite_cache c + where c.id in (select m.column_value from table(l_matched_ids) m) + ), + propagate_tags_from_ancestors as ( + select c.id, c.self_type, c.path, c.object_owner, listagg(distinct c_tags.tag, ',') within group (order by c_tags.tag) as tags + from matched_rows c + left join matched_rows t + on t.self_type in ('UT_SUITE','UT_SUITE_CONTEXT') + and c.path like t.path||'.%' /* all descendants */ + and c.object_owner = t.object_owner + outer apply (select column_value tag from table(c.tags) union select column_value tag from table(t.tags) ) c_tags + where c.self_type = 'UT_TEST' + group by c.id, c.self_type, c.path, c.object_owner + ), + filter_by_tags as ( + select x.path, x.object_owner + from propagate_tags_from_ancestors x + where &&ut3_owner..ut_suite_tag_filter.is_matching(x.tags, l_tags) = 1 + ), + tagged_rows as ( + select /*+ no_expand */ item.* + from matched_rows item + where l_tags is null + or exists ( + select 1 + from filter_by_tags tst + where tst.path||'.' like item.path || '.%' /* all descendants and self */ + and tst.object_owner = item.object_owner + ) ), - {:tags:} suitepaths as ( - select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath, - c.obj.path as path, - c.obj.object_owner as object_owner - from {:suite_item_name:} c - where c.obj.self_type = 'UT_SUITE' + select distinct substr(c.path,1,instr(c.path,'.',-1)-1) as suitepath, c.path, c.object_owner + from tagged_rows c + where c.self_type = 'UT_SUITE' ), - gen as ( - select rownum as pos - from xmltable('1 to 20') + gen as ( + --not xmltable('1 to 20'): together with the recursive "ordered" below it makes the parse hang or fail with ORA-07445 [qmxtrProcCorrOpn] on 19.20 + select level as pos from dual connect by level <= 20 ), - suitepath_part AS ( - select distinct - substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, - object_owner + suitepath_part as ( + select distinct substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, b.object_owner from suitepaths b - join gen g - on g.pos <= regexp_count(b.suitepath, '\w+') + join gen g + on g.pos <= regexp_count(b.suitepath, '\w+') ), - logical_suite_data as ( - select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner, - upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name, - cast(null as ut_executables) as x, - cast(null as ut_integer_list) as y, - cast(null as ut_executable_test) as z + logical_suites as ( + select p.path, p.object_owner, upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name from suitepath_part p - where p.path - not in (select s.path from suitepaths s) + where p.path not in (select s.path from suitepaths s) ), - logical_suites as ( - select ut_suite_cache_row( - null, - s.self_type, s.path, s.object_owner, s.object_name, - s.object_name, null, null, null, null, 0, - ut_varchar2_rows(), - s.x, s.x, s.x, s.x, s.x, s.x, - s.y, null, s.z - ) as obj - from logical_suite_data s + all_items as ( + select t.id, t.path, t.object_owner, t.object_name, t.line_no + from tagged_rows t + union all + select null as id, l.path, l.object_owner, l.object_name, null as line_no + from logical_suites l ), - items as ( - select obj from {:suite_item_name:} + items_for_sort as ( + select a.id, a.path, substr(a.path,1,instr(a.path,'.',-1,1)-1) as parent_path, a.object_owner, a.object_name, + case when a_random_seed is null then a.line_no end as line_no, + case when a_random_seed is not null then &&ut3_owner..ut_utils.hash_suite_path(a.path, a_random_seed) end as random_seed + from all_items a + ), + ordered(id, path, parent_path, object_owner, object_name, line_no, random_seed) as ( + select s.id, s.path, s.parent_path, s.object_owner, s.object_name, s.line_no, s.random_seed + from items_for_sort s + where s.parent_path is null union all - select obj from logical_suites + select s.id, s.path, s.parent_path, s.object_owner, s.object_name, s.line_no, s.random_seed + from ordered o + join items_for_sort s + on s.parent_path = o.path + and s.object_owner = o.object_owner ) - select c.obj - from items c - order by c.obj.object_owner,{:random_seed:}]'; - - function get_missing_cache_objects(a_object_owner varchar2) return ut_varchar2_rows is - l_result ut_varchar2_rows; - l_data ut_annotation_objs_cache_info; - begin - l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, 'PACKAGE'); - - select i.object_name - bulk collect into l_result - from ut_suite_cache_package i - where not exists ( - select 1 from table(l_data) o - where o.object_owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = 'PACKAGE' - ) - and i.object_owner = a_object_owner; - return l_result; - end; - - - function get_path_sql(a_path in varchar2) return varchar2 is - begin - return case when a_path is not null then q'[ - :l_path||'.' like c.path || '.%' /*all children and self*/ - or ( c.path||'.' like :l_path || '.%' --all parents - ]' - else ' :l_path is null and ( :l_path is null ' end; - end; - - function get_object_name_sql(a_object_name in varchar2) return varchar2 is - begin - return case when a_object_name is not null - then ' c.object_name = :a_object_name ' - else ' :a_object_name is null' end; - end; + --object_owner first: a run can span several schemas, so top level items are grouped by schema + --(below the top level all items of a subtree have the same owner) + --path: siblings with the same line number (packages, logical suites) keep the order of their paths + search depth first by object_owner, line_no desc, random_seed desc nulls last, path set order1 + select /*+ no_parallel */ + case + when o.id is not null and l_with_executables = 'Y' then value(c) + when o.id is not null then + --without the executables, which only a run needs + &&ut3_owner..ut_suite_cache_row( + c.id, c.self_type, c.path, c.object_owner, c.object_name, c.name, + c.line_no, c.parse_time, c.description, c.rollback_type, c.disabled_flag, c.disabled_reason, + null, + null, null, null, null, null, null, + null, c.tags, null + ) + else &&ut3_owner..ut_suite_cache_row( + null, 'UT_LOGICAL_SUITE', o.path, o.object_owner, o.object_name, o.object_name, + null, null, null, null, 0, null, + case + when h.id is null then &&ut3_owner..ut_varchar2_rows() + else &&ut3_owner..ut_varchar2_rows( + 'Suite ' || lower(h.object_owner || '.' || h.object_name) + || ' is not run, as it does not exist or you have no EXECUTE privilege on it.' + || ' Its beforeall/afterall, rollback setting and tags are not applied to the suites below it.' + ) + end, + null, null, null, null, null, null, + null, null, null + ) + end + bulk collect into l_results + from ordered o + left join &&ut3_owner..ut_suite_cache c + on c.id = o.id + --a package suite that get_matched_ids left out as not accessible, replaced by a logical suite + left join &&ut3_owner..ut_suite_cache h + on o.id is null + and h.object_owner = o.object_owner + and h.path = o.path + and h.self_type = 'UT_SUITE' + order by o.order1 desc; - function get_procedure_name_sql(a_procedure_name in varchar2) return varchar2 is - begin - return case when a_procedure_name is not null - then ' c.name = :a_procedure_name' - else ' :a_procedure_name is null' end; + return l_results; end; - function get_tags_sql(a_tags_count in integer) return varchar2 is + function get_suite_rows( + a_schema_paths ut_path_items, + a_skip_access_check boolean, + a_tags varchar2 := null, + a_random_seed positive := null + ) return ut_suite_cache_rows is begin - return case when a_tags_count > 0 then - q'[filter_tags as ( - select c.obj.path as path - from suite_items c - where c.obj.tags multiset intersect :a_tag_list is not empty - ), - suite_items_tags as ( - select c.* - from suite_items c - where exists ( - select 1 from filter_tags t - where t.path||'.' like c.obj.path || '.%' /*all children and self*/ - or c.obj.path||'.' like t.path || '.%' --all parents - ) - ),]' - else - q'[dummy as (select 'x' from dual where :a_tag_list is null ),]' - end; + return select_suite_rows(a_schema_paths, a_skip_access_check, a_tags, a_random_seed, a_with_executables => true); end; - function get_random_seed_sql(a_random_seed positive) return varchar2 is + function get_suite_items_info( + a_suite_cache_items ut_suite_cache_rows + ) return ut_suite_items_info is + l_results ut_suite_items_info; begin - return case - when a_random_seed is null then q'[ - replace( - case - when c.obj.self_type in ( 'UT_TEST' ) - then substr(c.obj.path, 1, instr(c.obj.path, '.', -1) ) - else c.obj.path - end, '.', chr(0) - ) desc nulls last, - c.obj.object_name desc, - c.obj.line_no, - :a_random_seed]' - else - ' ut_runner.hash_suite_path( - c.obj.path, :a_random_seed - ) desc nulls last' - end; + select /*+ no_parallel */ &&ut3_owner..ut_suite_item_info( + c.object_owner, c.object_name, c.name, + c.description, c.self_type, c.line_no, + c.path, c.disabled_flag, c.disabled_reason, c.tags + ) + bulk collect into l_results + from table(a_suite_cache_items) c; + return l_results; end; - - - /* - * Public code - */ - function get_cached_suite_rows( - a_object_owner varchar2, - a_path varchar2 := null, - a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_random_seed positive := null, - a_tags ut_varchar2_rows := null - ) return ut_suite_cache_rows is - l_path varchar2(4000); - l_results ut_suite_cache_rows := ut_suite_cache_rows(); - l_sql varchar2(32767); - l_suite_item_name varchar2(20); - l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows()); - l_object_owner varchar2(250) := ut_utils.qualified_sql_name(a_object_owner); - l_object_name varchar2(250) := ut_utils.qualified_sql_name(a_object_name); - l_procedure_name varchar2(250) := ut_utils.qualified_sql_name(a_procedure_name); + function get_suites_info( + a_schema_paths ut_path_items, + a_skip_access_check boolean + ) return ut_suite_items_info is begin - if a_path is null and a_object_name is not null then - select min(c.path) - into l_path - from ut_suite_cache c - where c.object_owner = upper(l_object_owner) - and c.object_name = upper(l_object_name) - and c.name = nvl(upper(l_procedure_name), c.name); - else - l_path := lower(ut_utils.qualified_sql_name(a_path)); - end if; - l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end; - - l_sql := gc_get_cache_suite_sql; - l_sql := replace(l_sql,'{:suite_item_name:}',l_suite_item_name); - l_sql := replace(l_sql,'{:object_owner:}',upper(l_object_owner)); - l_sql := replace(l_sql,'{:path:}',get_path_sql(l_path)); - l_sql := replace(l_sql,'{:object_name:}',get_object_name_sql(l_object_name)); - l_sql := replace(l_sql,'{:procedure_name:}',get_procedure_name_sql(l_procedure_name)); - l_sql := replace(l_sql,'{:tags:}',get_tags_sql(l_tags.count)); - l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed)); - - ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) ); - - execute immediate l_sql - bulk collect into l_results - using upper(l_object_owner), l_path, l_path, upper(a_object_name), upper(a_procedure_name), l_tags, a_random_seed; - return l_results; + return get_suite_items_info( + select_suite_rows(a_schema_paths, a_skip_access_check, a_tags => null, a_random_seed => null, a_with_executables => false) + ); end; function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is l_cache_parse_time timestamp; begin - select min(t.parse_time) + select /*+ no_parallel */ min(t.parse_time) into l_cache_parse_time - from ut_suite_cache_schema t - where object_owner = a_schema_name; + from &&ut3_owner..ut_suite_cache_schema t + where object_owner = upper(a_schema_name); return l_cache_parse_time; end; @@ -241,56 +289,53 @@ create or replace package body ut_suite_cache_manager is l_object_owner varchar2(250) := upper(a_object_owner); l_object_name varchar2(250) := upper(a_object_name); begin - if a_suite_items is not null and a_suite_items.count = 0 then - - delete from ut_suite_cache t - where t.object_owner = l_object_owner - and t.object_name = l_object_name; + if a_suite_items is null or a_suite_items.count = 0 then - delete from ut_suite_cache_package t + --rows of ut_suite_cache are removed by the "on delete cascade" foreign key + delete from &&ut3_owner..ut_suite_cache_package t where t.object_owner = l_object_owner and t.object_name = l_object_name; else - select min(parse_time) + select /*+ no_parallel */ min(parse_time) into l_cached_parse_time - from ut_suite_cache_package t + from &&ut3_owner..ut_suite_cache_package t where t.object_name = l_object_name and t.object_owner = l_object_owner; if a_parse_time > l_cached_parse_time or l_cached_parse_time is null then - update ut_suite_cache_schema t - set t.parse_time = a_parse_time + update /*+ no_parallel */ &&ut3_owner..ut_suite_cache_schema t + set t.parse_time = greatest(t.parse_time,a_parse_time) where object_owner = l_object_owner; if sql%rowcount = 0 then - insert into ut_suite_cache_schema + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache_schema (object_owner, parse_time) values (l_object_owner, a_parse_time); end if; - update ut_suite_cache_package t + update /*+ no_parallel */ &&ut3_owner..ut_suite_cache_package t set t.parse_time = a_parse_time where t.object_owner = l_object_owner and t.object_name = l_object_name; if sql%rowcount = 0 then - insert into ut_suite_cache_package + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache_package (object_owner, object_name, parse_time) values (l_object_owner, l_object_name, a_parse_time ); end if; - delete from ut_suite_cache t + delete from &&ut3_owner..ut_suite_cache t where t.object_owner = l_object_owner and t.object_name = l_object_name; - insert into ut_suite_cache t + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache t ( id, self_type, path, object_owner, object_name, name, line_no, parse_time, description, - rollback_type, disabled_flag, warnings, + rollback_type, disabled_flag,disabled_reason, warnings, before_all_list, after_all_list, before_each_list, after_each_list, before_test_list, after_test_list, @@ -298,13 +343,13 @@ create or replace package body ut_suite_cache_manager is item ) with suites as ( - select treat(value(x) as ut_suite) i + select treat(value(x) as &&ut3_owner..ut_suite) i from table(a_suite_items) x where x.self_type in( 'UT_SUITE', 'UT_SUITE_CONTEXT' ) ) - select ut_suite_cache_seq.nextval, s.i.self_type as self_type, s.i.path as path, + select /*+ no_parallel */ &&ut3_owner..ut_suite_cache_seq.nextval, s.i.self_type as self_type, s.i.path as path, upper(s.i.object_owner) as object_owner, upper(s.i.object_name) as object_name, upper(s.i.name) as name, s.i.line_no as line_no, s.i.parse_time as parse_time, s.i.description as description, - s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag, s.i.warnings as warnings, + s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag,s.i.disabled_reason as disabled_reason, s.i.warnings as warnings, s.i.before_all_list as before_all_list, s.i.after_all_list as after_all_list, null before_each_list, null after_each_list, null before_test_list, null after_test_list, @@ -312,11 +357,11 @@ create or replace package body ut_suite_cache_manager is null item from suites s; - insert into ut_suite_cache t + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache t ( id, self_type, path, object_owner, object_name, name, line_no, parse_time, description, - rollback_type, disabled_flag, warnings, + rollback_type, disabled_flag,disabled_reason, warnings, before_all_list, after_all_list, before_each_list, after_each_list, before_test_list, after_test_list, @@ -324,13 +369,13 @@ create or replace package body ut_suite_cache_manager is item ) with tests as ( - select treat(value(x) as ut_test) t + select treat(value(x) as &&ut3_owner..ut_test) t from table ( a_suite_items ) x where x.self_type in ( 'UT_TEST' ) ) - select ut_suite_cache_seq.nextval, s.t.self_type as self_type, s.t.path as path, + select /*+ no_parallel */ &&ut3_owner..ut_suite_cache_seq.nextval, s.t.self_type as self_type, s.t.path as path, upper(s.t.object_owner) as object_owner, upper(s.t.object_name) as object_name, upper(s.t.name) as name, s.t.line_no as line_no, s.t.parse_time as parse_time, s.t.description as description, - s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.warnings as warnings, + s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.disabled_reason as disabled_reason, s.t.warnings as warnings, null before_all_list, null after_all_list, s.t.before_each_list as before_each_list, s.t.after_each_list as after_each_list, s.t.before_test_list as before_test_list, s.t.after_test_list as after_test_list, @@ -344,48 +389,28 @@ create or replace package body ut_suite_cache_manager is end; procedure remove_missing_objs_from_cache(a_schema_name varchar2) is - l_objects ut_varchar2_rows; pragma autonomous_transaction; begin - l_objects := get_missing_cache_objects(a_schema_name); - delete from ut_suite_cache i + --rows of ut_suite_cache are removed by the "on delete cascade" foreign key + delete /*+ no_parallel */ from &&ut3_owner..ut_suite_cache_package i where i.object_owner = a_schema_name - and i.object_name in ( select column_value from table (l_objects) ); - - delete from ut_suite_cache_package i - where i.object_owner = a_schema_name - and i.object_name in ( select column_value from table (l_objects) ); + and not exists ( + select 1 + from (&&ut3_owner..ut_annotation_cache_macros.get_cached_objects(a_schema_name, 'PACKAGE')) o + where o.object_name = i.object_name + ); commit; end; - function get_cached_suite_info( - a_object_owner varchar2, - a_object_name varchar2 - ) return ut_suite_items_info is - l_cache_rows ut_suite_cache_rows; - l_results ut_suite_items_info; - begin - l_cache_rows := get_cached_suite_rows( a_object_owner => a_object_owner, a_object_name =>a_object_name ); - select ut_suite_item_info( - c.object_owner, c.object_name, c.name, - c.description, c.self_type, c.line_no, - c.path, c.disabled_flag, c.tags - ) - bulk collect into l_results - from table(l_cache_rows) c; - - return l_results; - end; - function get_cached_packages( a_schema_names ut_varchar2_rows ) return ut_object_names is l_results ut_object_names; begin - select ut_object_name( c.object_owner, c.object_name ) + select /*+ no_parallel */ &&ut3_owner..ut_object_name( c.object_owner, c.object_name ) bulk collect into l_results - from ut_suite_cache_package c + from &&ut3_owner..ut_suite_cache_package c join table ( a_schema_names ) s on c.object_owner = upper(s.column_value); return l_results; @@ -399,27 +424,27 @@ create or replace package body ut_suite_cache_manager is l_count integer; begin if a_procedure_name is not null then - select count( 1 ) into l_count from dual + select /*+ no_parallel */ count( 1 ) into l_count from dual where exists( select 1 - from ut_suite_cache c + from &&ut3_owner..ut_suite_cache c where c.object_owner = a_owner_name and c.object_name = a_package_name and c.name = a_procedure_name ); elsif a_package_name is not null then - select count( 1 ) into l_count from dual + select /*+ no_parallel */ count( 1 ) into l_count from dual where exists( select 1 - from ut_suite_cache c + from &&ut3_owner..ut_suite_cache c where c.object_owner = a_owner_name and c.object_name = a_package_name ); else - select count( 1 ) into l_count from dual + select /*+ no_parallel */ count( 1 ) into l_count from dual where exists( select 1 - from ut_suite_cache c + from &&ut3_owner..ut_suite_cache c where c.object_owner = a_owner_name ); end if; @@ -427,5 +452,5 @@ create or replace package body ut_suite_cache_manager is return l_count > 0; end; -end ut_suite_cache_manager; +end; / diff --git a/source/core/ut_suite_cache_manager.pks b/source/core/ut_suite_cache_manager.pks index d5b31ccee..1ff9552cc 100644 --- a/source/core/ut_suite_cache_manager.pks +++ b/source/core/ut_suite_cache_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_suite_cache_manager authid definer is +create or replace noneditionable package ut_suite_cache_manager authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,6 +18,11 @@ create or replace package ut_suite_cache_manager authid definer is /** * Responsible for storing and retrieving suite data from cache + * + * The package runs with invoker rights. It accesses the suite cache tables of the framework owner + * through the code based access control role _cbac_modify_objects_role granted to the package, + * so all references to framework objects in SQL statements are qualified with the framework owner. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. */ /* @@ -41,29 +46,34 @@ create or replace package ut_suite_cache_manager authid definer is procedure remove_missing_objs_from_cache(a_schema_name varchar2); /* - * Retrieves suite items data from cache. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally for building suites at runtime. + * Splits run paths (schema[.package[.procedure]] or schema:suitepath, wildcards allowed) into their parts. + * Wildcards are resolved by get_suite_rows. + */ + function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items; + + /* + * Retrieves suite items matching the paths from cache, with logical suites added for suitepaths without a package. + * Returns only items of packages the invoking user can access, unless a_skip_access_check is true. + * When a_tags is given, returns only items with a test matching the tag expression below them (or being one). + * The rows are sorted bottom up: children before parents, by line number or, when a_random_seed is given, randomly. + * Not to be used publicly. Used internally for building suites at runtime and suites info. */ - function get_cached_suite_rows( - a_object_owner varchar2, - a_path varchar2 := null, - a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_random_seed positive := null, - a_tags ut_varchar2_rows := null + function get_suite_rows( + a_schema_paths ut_path_items, + a_skip_access_check boolean, + a_tags varchar2 := null, + a_random_seed positive := null ) return ut_suite_cache_rows; /* - * Retrieves suite item info rows from cache. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally for building suites info. + * Retrieves information about the suite items matching the paths, as get_suite_rows does without tags. + * Not to be used publicly. Used internally for ut_runner.get_suites_info. */ - function get_cached_suite_info( - a_object_owner varchar2, - a_object_name varchar2 + function get_suites_info( + a_schema_paths ut_path_items, + a_skip_access_check boolean ) return ut_suite_items_info; - + /* * Retrieves list of cached suite packages. * Returned data is not filtered by user access rights. @@ -83,6 +93,6 @@ create or replace package ut_suite_cache_manager authid definer is a_package_name varchar2, a_procedure_name varchar2 ) return boolean; - + end ut_suite_cache_manager; / diff --git a/source/core/ut_suite_cache_package.sql b/source/core/ut_suite_cache_package.sql index 06f786949..1f05c633f 100644 --- a/source/core/ut_suite_cache_package.sql +++ b/source/core/ut_suite_cache_package.sql @@ -1,9 +1,9 @@ create table ut_suite_cache_package ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_cache_schema.sql b/source/core/ut_suite_cache_schema.sql index 46c7b0ef3..a49b92f7e 100644 --- a/source/core/ut_suite_cache_schema.sql +++ b/source/core/ut_suite_cache_schema.sql @@ -1,9 +1,9 @@ create table ut_suite_cache_schema ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_cache_seq.sql b/source/core/ut_suite_cache_seq.sql index 36de28809..ce7b5d19a 100644 --- a/source/core/ut_suite_cache_seq.sql +++ b/source/core/ut_suite_cache_seq.sql @@ -1,9 +1,9 @@ create sequence ut_suite_cache_seq /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index e71a51dc8..3689d991e 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_suite_manager is +create or replace noneditionable package body ut_suite_manager is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -17,19 +17,8 @@ create or replace package body ut_suite_manager is */ gc_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: '; - - type t_path_item is record ( - object_name varchar2(250), - procedure_name varchar2(250), - suite_path varchar2(4000) - ); - type t_path_items is table of t_path_item; - type t_schema_paths is table of t_path_items index by varchar2(250 char); - cursor c_cached_suites_cursor is select * from table(ut_suite_cache_rows()); type tt_cached_suites is table of c_cached_suites_cursor%rowtype; - type t_cached_suites_cursor is ref cursor return c_cached_suites_cursor%rowtype; - type t_item_levels is table of ut_suite_items index by binary_integer; ------------------ @@ -41,7 +30,8 @@ create or replace package body ut_suite_manager is else for i in 1 .. a_paths.count loop l_path := a_paths(i); - if l_path is null or not (regexp_like(l_path, '^[A-Za-z0-9$#_]+(\.[A-Za-z0-9$#_]+){0,2}$') or regexp_like(l_path, '^([A-Za-z0-9$#_]+)?:[A-Za-z0-9$#_]+(\.[A-Za-z0-9$#_]+)*$')) then + if l_path is null or not ( + regexp_like(l_path, '^[[:alnum:]$#_\*]+(\.[[:alnum:]$#_\*]+){0,2}$') or regexp_like(l_path, '^([[:alnum:]$#_]+)?:[[:alnum:]$#_\*]+(\.[[:alnum:]$#_\*]+)*$')) then raise_application_error(ut_utils.gc_invalid_path_format, 'Invalid path format: ' || nvl(l_path, 'NULL')); end if; end loop; @@ -70,9 +60,9 @@ create or replace package body ut_suite_manager is for i in 1 .. a_paths.count loop --if path is suite-path - if regexp_like(a_paths(i), '^([A-Za-z0-9$#_]+)?:') then + if regexp_like(a_paths(i), '^([[:alnum:]$#_]+)?:') then --get schema name / path - l_schema := regexp_substr(a_paths(i), '^([A-Za-z0-9$#_]+)?:',subexpression => 1); + l_schema := regexp_substr(a_paths(i), '^([[:alnum:]$#_]+)?:',subexpression => 1); -- transform ":path1[.path2]" to "schema:path1[.path2]" if l_schema is not null then l_schema := sys.dbms_assert.schema_name(upper(l_schema)); @@ -84,12 +74,14 @@ create or replace package body ut_suite_manager is -- get schema name / object.[procedure] name -- When path is one of: schema or schema.package[.object] or package[.object] -- transform it back to schema[.package[.object]] + -- Object name or procedure is allowed to have filter char + -- However this is not allowed on schema begin - l_object := regexp_substr(a_paths(i), '^[A-Za-z0-9$#_]+'); + l_object := regexp_substr(a_paths(i), '^[[:alnum:]$#_\*]+'); l_schema := sys.dbms_assert.schema_name(upper(l_object)); exception when sys.dbms_assert.invalid_schema_name then - if ut_metadata.package_exists_in_cur_schema(upper(l_object)) then + if l_object like '%*%' or ut_metadata.package_exists_in_cur_schema(upper(l_object)) then a_paths(i) := c_current_schema || '.' || a_paths(i); l_schema := c_current_schema; else @@ -110,34 +102,6 @@ create or replace package body ut_suite_manager is l_schema_names := resolve_schema_names(a_paths); end; - function group_paths_by_schema(a_paths ut_varchar2_list) return t_schema_paths is - c_package_path_regex constant varchar2(100) := '^([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?(\.([A-Za-z0-9$#_]+))?$'; - l_schema varchar2(4000); - l_empty_result t_path_item; - l_result t_path_item; - l_results t_schema_paths; - begin - for i in 1 .. a_paths.count loop - l_result := l_empty_result; - if a_paths(i) like '%:%' then - l_schema := upper(regexp_substr(a_paths(i),'^[^.:]+')); - l_result.suite_path := ltrim(regexp_substr(a_paths(i),'[.:].*$'),':'); - else - l_schema := regexp_substr(a_paths(i), c_package_path_regex, subexpression => 1); - l_result.object_name := regexp_substr(a_paths(i), c_package_path_regex, subexpression => 3); - l_result.procedure_name := regexp_substr(a_paths(i), c_package_path_regex, subexpression => 5); - end if; - if l_results.exists(l_schema) then - l_results(l_schema).extend; - l_results(l_schema)(l_results(l_schema).last) := l_result; - else - l_results(l_schema) := t_path_items(l_result); - end if; - end loop; - return l_results; - end; - - function sort_by_seq_no( a_list ut_executables ) return ut_executables is @@ -178,98 +142,58 @@ create or replace package body ut_suite_manager is a_items_at_level t_item_levels ) return ut_suite_item is l_result ut_suite_item; + l_items ut_suite_items; begin + --the items one level below, collected before the parent (rows are sorted bottom up) + l_items := case when a_prev_level > a_level then a_items_at_level(a_prev_level) else ut_suite_items() end; case a_rows( a_idx ).self_type when 'UT_SUITE' then l_result := - case when a_prev_level > a_level then - ut_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => a_items_at_level(a_prev_level), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - else - ut_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => ut_suite_items(), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - end; + ut_suite( + self_type => a_rows( a_idx ).self_type, + object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), + name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, + line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, + start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, + results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), + items => l_items, + before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags + ); when 'UT_SUITE_CONTEXT' then l_result := - case when a_prev_level > a_level then - ut_suite_context( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => a_items_at_level(a_prev_level), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - else - ut_suite_context( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => ut_suite_items(), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - end; + ut_suite_context( + self_type => a_rows( a_idx ).self_type, + object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), + name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, + line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, + start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, + results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), + items => l_items, + before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags + ); when 'UT_LOGICAL_SUITE' then l_result := - case when a_prev_level > a_level then - ut_logical_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => a_items_at_level(a_prev_level), tags => null - ) - else - ut_logical_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => ut_suite_items(), tags => null - ) - end; + ut_logical_suite( + self_type => a_rows( a_idx ).self_type, + object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), + name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, + line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, + start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, + results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), + items => l_items, tags => null + ); when 'UT_TEST' then l_result := ut_test( self_type => a_rows(a_idx).self_type, object_owner => a_rows(a_idx).object_owner, object_name => lower(a_rows(a_idx).object_name), name => lower(a_rows(a_idx).name), description => a_rows(a_idx).description, path => a_rows(a_idx).path, - rollback_type => a_rows(a_idx).rollback_type, disabled_flag => a_rows(a_idx).disabled_flag, + rollback_type => a_rows(a_idx).rollback_type, disabled_flag => a_rows(a_idx).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows(a_idx).line_no, parse_time => a_rows(a_idx).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows(a_idx).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), @@ -285,42 +209,46 @@ create or replace package body ut_suite_manager is return l_result; end; + /* + Builds the suite hierarchy from cache rows sorted bottom-up (see ut_suite_cache_manager.get_suite_rows) + and propagates the rollback type of top level suites to their items. + + The rows are converted to records with SQL before use. Building ut_test objects from the item attribute + of ut_suite_cache_row objects directly makes the test execution fail on Oracle 19.20 with + ORA-00600: [pfrobj.c: invalid RTTI for Object] in ut_executable.do_execute (seen in nested runs, test_ut_test). + */ procedure reconstruct_from_cache( a_suites in out nocopy ut_suite_items, - a_suite_data_cursor sys_refcursor + a_suite_rows ut_suite_cache_rows ) is - c_bulk_limit constant pls_integer := 1000; l_items_at_level t_item_levels; l_rows tt_cached_suites; l_level pls_integer; l_prev_level pls_integer; l_idx integer; begin - loop - fetch a_suite_data_cursor bulk collect into l_rows limit c_bulk_limit; - - l_idx := l_rows.first; - while l_idx is not null loop - l_level := length(l_rows(l_idx).path) - length( replace(l_rows(l_idx).path, '.') ) + 1; - if l_level > 1 then - if not l_items_at_level.exists(l_level) then - l_items_at_level(l_level) := ut_suite_items(); - end if; - l_items_at_level(l_level).extend; - pragma inline(get_logical_suite, 'YES'); - l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); - else - a_suites.extend; - pragma inline(get_logical_suite, 'YES'); - a_suites(a_suites.last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); - end if; - if l_prev_level > l_level then - l_items_at_level(l_prev_level).delete; + select * bulk collect into l_rows from table(a_suite_rows); + + l_idx := l_rows.first; + while l_idx is not null loop + l_level := length(l_rows(l_idx).path) - length( replace(l_rows(l_idx).path, '.') ) + 1; + if l_level > 1 then + if not l_items_at_level.exists(l_level) then + l_items_at_level(l_level) := ut_suite_items(); end if; - l_prev_level := l_level; - l_idx := l_rows.next(l_idx); - end loop; - exit when a_suite_data_cursor%NOTFOUND; + l_items_at_level(l_level).extend; + pragma inline(get_logical_suite, 'YES'); + l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); + else + a_suites.extend; + pragma inline(get_logical_suite, 'YES'); + a_suites(a_suites.last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); + end if; + if l_prev_level > l_level then + l_items_at_level(l_prev_level).delete; + end if; + l_prev_level := l_level; + l_idx := l_rows.next(l_idx); end loop; reverse_list_order( a_suites ); @@ -328,52 +256,79 @@ create or replace package body ut_suite_manager is for i in 1 .. a_suites.count loop a_suites( i ).set_rollback_type( a_suites( i ).get_rollback_type ); end loop; - close a_suite_data_cursor; end reconstruct_from_cache; + /* + A user can run all packages of a schema they own, and of any schema with EXECUTE ANY PROCEDURE, + so the access to those packages does not need checking. + */ + function can_skip_access_check(a_owner_name varchar2) return boolean is + begin + return sys_context( 'userenv', 'current_user' ) = upper(a_owner_name) or ut_metadata.user_has_execute_any_proc(); + end; + + function can_skip_access_check(a_schema_paths ut_path_items) return boolean is + begin + for i in 1 .. a_schema_paths.count loop + if not can_skip_access_check(a_schema_paths(i).schema_name) then + return false; + end if; + end loop; + return true; + end; + + /* + Raises ut_utils.gc_suite_package_not_found for the first path that selects none of the suite rows + (as returned by ut_suite_cache_manager.get_suite_rows), with the same matching rule: + the SQL macro ut_suite_cache_macros.match_paths. + */ + procedure reconcile_paths_and_suites( + a_schema_paths ut_path_items, + a_suite_rows ut_suite_cache_rows + ) is + begin + for i in ( + with + path_items as ( + select /*+ materialize */ rownum as path_id, sp.schema_name, sp.object_name, sp.procedure_name, sp.suite_path + from table(a_schema_paths) sp + ), + suite_items as ( + select r.object_owner, r.object_name, r.name, r.path + from table(a_suite_rows) r + ) + select /*+ no_parallel */ p.schema_name, p.object_name, p.procedure_name, p.suite_path + from path_items p + where not exists ( + select 1 + from (&&ut3_owner..ut_suite_cache_macros.match_paths(suite_items, path_items)) m + where m.path_id = p.path_id + ) + order by p.path_id + ) loop + if i.suite_path is not null then + raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||i.schema_name||':'||i.suite_path|| '.'); + elsif i.procedure_name is not null then + raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||i.schema_name||'.'||i.object_name|| '.'||i.procedure_name||' does not exist'); + elsif i.object_name is not null then + raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||i.schema_name||'.'||i.object_name|| ' does not exist'); + end if; + end loop; + end; + function get_cached_suite_data( - a_object_owner varchar2, - a_path varchar2 := null, - a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false, + a_schema_paths ut_path_items, a_random_seed positive, - a_tags ut_varchar2_rows := null - ) return t_cached_suites_cursor is - l_unfiltered_rows ut_suite_cache_rows; - l_result t_cached_suites_cursor; + a_tags varchar2 := null + ) return ut_suite_cache_rows is + l_suite_rows ut_suite_cache_rows; begin - l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_rows( - a_object_owner, - a_path, - a_object_name, - a_procedure_name, - a_random_seed, - a_tags + l_suite_rows := ut_suite_cache_manager.get_suite_rows( + a_schema_paths, can_skip_access_check(a_schema_paths), a_tags, a_random_seed ); - if a_skip_all_objects then - open l_result for - select c.* from table(l_unfiltered_rows) c; - else - open l_result for - select c.* from table(l_unfiltered_rows) c - where exists - ( select 1 - from all_objects a - where a.object_name = c.object_name - and a.owner = c.object_owner - and a.object_type = 'PACKAGE' - ); - end if; - - return l_result; - end; + reconcile_paths_and_suites(a_schema_paths, l_suite_rows); - function can_skip_all_objects_scan( - a_owner_name varchar2 - ) return boolean is - begin - return sys_context( 'userenv', 'current_schema' ) = a_owner_name or ut_metadata.user_has_execute_any_proc() or ut_trigger_check.is_alive(); + return l_suite_rows; end; procedure build_and_cache_suites( @@ -424,47 +379,58 @@ create or replace package body ut_suite_manager is ) is l_annotations_cursor sys_refcursor; l_suite_cache_time timestamp; + l_owner_name varchar2(128) := upper(a_owner_name); begin ut_event_manager.trigger_event('refresh_cache - start'); - l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(a_owner_name); + l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(l_owner_name); l_annotations_cursor := ut_annotation_manager.get_annotated_objects( - a_owner_name, 'PACKAGE', l_suite_cache_time + l_owner_name, 'PACKAGE', l_suite_cache_time ); - build_and_cache_suites(a_owner_name, l_annotations_cursor); + build_and_cache_suites(l_owner_name, l_annotations_cursor); - if can_skip_all_objects_scan(a_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then - ut_suite_cache_manager.remove_missing_objs_from_cache( a_owner_name ); + if can_skip_access_check(l_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then + ut_suite_cache_manager.remove_missing_objs_from_cache( l_owner_name ); end if; ut_event_manager.trigger_event('refresh_cache - end'); end; - procedure add_suites_for_path( - a_owner_name varchar2, - a_path varchar2 := null, - a_object_name varchar2 := null, - a_procedure_name varchar2 := null, + /* + Resolves the schema names of the paths, refreshes the suite cache of those schemas + and returns the paths split into their parts. + */ + function refresh_cache_for_paths( + a_paths ut_varchar2_list + ) return ut_path_items is + l_paths ut_varchar2_list := a_paths; + l_schema_names ut_varchar2_rows; + l_schema varchar2(4000); + begin + l_schema_names := resolve_schema_names(l_paths); + l_schema := l_schema_names.first; + while l_schema is not null loop + refresh_cache(upper(l_schema_names(l_schema))); + l_schema := l_schema_names.next(l_schema); + end loop; + return ut_suite_cache_manager.get_schema_paths(l_paths); + end; + + procedure add_suites_for_paths( + a_schema_paths ut_path_items, a_suites in out nocopy ut_suite_items, a_random_seed positive, - a_tags ut_varchar2_rows := null + a_tags varchar2 := null ) is begin - refresh_cache(a_owner_name); - reconstruct_from_cache( a_suites, get_cached_suite_data( - a_owner_name, - a_path, - a_object_name, - a_procedure_name, - can_skip_all_objects_scan(a_owner_name), + a_schema_paths, a_random_seed, a_tags ) ); - end; ----------------------------------------------- @@ -476,21 +442,17 @@ create or replace package body ut_suite_manager is a_annotated_objects sys_refcursor, a_path varchar2 := null, a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false + a_procedure_name varchar2 := null ) return ut_suite_items is l_suites ut_suite_items := ut_suite_items(); + l_schema_paths ut_path_items; begin build_and_cache_suites(a_owner_name, a_annotated_objects); - + l_schema_paths := ut_path_items(ut_path_item(a_owner_name,a_object_name,a_procedure_name,a_path)); reconstruct_from_cache( l_suites, get_cached_suite_data( - a_owner_name, - a_path, - a_object_name, - a_procedure_name, - a_skip_all_objects, + l_schema_paths, null, null ) @@ -498,13 +460,21 @@ create or replace package body ut_suite_manager is return l_suites; end; - function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names is + function get_schema_ut_packages(a_schema_names ut_varchar2_rows, a_schema_name_expr varchar2) return ut_object_names is + l_schema_names ut_varchar2_rows := a_schema_names; begin - for i in 1 .. a_schema_names.count loop - refresh_cache(a_schema_names(i)); + if a_schema_name_expr is not null then + select username + bulk collect into l_schema_names + from all_users + where regexp_like(username,a_schema_name_expr,'i'); + end if; + + for i in 1 .. l_schema_names.count loop + refresh_cache(l_schema_names(i)); end loop; - return ut_suite_cache_manager.get_cached_packages( a_schema_names ); + return ut_suite_cache_manager.get_cached_packages( l_schema_names ); end; function get_schema_names(a_paths ut_varchar2_list) return ut_varchar2_rows is @@ -525,91 +495,40 @@ create or replace package body ut_suite_manager is a_paths ut_varchar2_list, a_suites out nocopy ut_suite_items, a_random_seed positive := null, - a_tags ut_varchar2_rows := ut_varchar2_rows() + a_tags varchar2 := null ) is - l_paths ut_varchar2_list := a_paths; - l_path_items t_path_items; - l_path_item t_path_item; - l_schema varchar2(4000); - l_suites_count pls_integer := 0; - l_index varchar2(4000 char); - l_schema_paths t_schema_paths; + l_tags_match integer; begin ut_event_manager.trigger_event('configure_execution_by_path - start'); + --raise an error for an invalid tag expression even when the paths select no tests to evaluate it on + if a_tags is not null then + l_tags_match := ut_suite_tag_filter.is_matching(null, a_tags); + end if; a_suites := ut_suite_items(); - --resolve schema names from paths and group paths by schema name - resolve_schema_names(l_paths); - - l_schema_paths := group_paths_by_schema(l_paths); - l_schema := l_schema_paths.first; - while l_schema is not null loop - l_path_items := l_schema_paths(l_schema); - for i in 1 .. l_path_items.count loop - l_path_item := l_path_items(i); - add_suites_for_path( - upper(l_schema), - l_path_item.suite_path, - l_path_item.object_name, - l_path_item.procedure_name, - a_suites, - a_random_seed, - a_tags - ); - if a_suites.count = l_suites_count then - if l_path_item.suite_path is not null then - raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||l_schema||':'||l_path_item.suite_path|| '.'); - elsif l_path_item.procedure_name is not null then - raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||l_schema||'.'||l_path_item.object_name|| '.'||l_path_item.procedure_name||' does not exist'); - elsif l_path_item.object_name is not null then - raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||l_schema||'.'||l_path_item.object_name|| ' does not exist'); - end if; - end if; - l_index := a_suites.first; - l_suites_count := a_suites.count; - end loop; - l_schema := l_schema_paths.next(l_schema); - end loop; - - --propagate rollback type to suite items after organizing suites into hierarchy - for i in 1 .. a_suites.count loop - a_suites(i).set_rollback_type( a_suites(i).get_rollback_type() ); - end loop; + add_suites_for_paths( + refresh_cache_for_paths(a_paths), + a_suites, + a_random_seed, + a_tags + ); - ut_event_manager.trigger_event('configure_execution_by_path - start'); + ut_event_manager.trigger_event('configure_execution_by_path - end'); end configure_execution_by_path; function get_suites_info( - a_owner_name varchar2, - a_package_name varchar2 := null + a_paths ut_varchar2_list ) return sys_refcursor is - l_result sys_refcursor; - l_all_suite_info ut_suite_items_info; - l_owner_name varchar2(250) := ut_utils.qualified_sql_name(a_owner_name); - l_package_name varchar2(250) := ut_utils.qualified_sql_name(a_package_name); + l_result sys_refcursor; + l_all_suite_info ut_suite_items_info; + l_schema_paths ut_path_items := refresh_cache_for_paths(a_paths); begin + l_all_suite_info := ut_suite_cache_manager.get_suites_info(l_schema_paths, can_skip_access_check(l_schema_paths)); + open l_result for + select /*+ no_parallel */ value(c) + from table(l_all_suite_info) c + order by c.object_owner, c.object_name, c.item_line_no; - refresh_cache(l_owner_name); - - l_all_suite_info := ut_suite_cache_manager.get_cached_suite_info( l_owner_name, l_package_name ); - if can_skip_all_objects_scan( l_owner_name ) then - open l_result for - select value(c) - from table(l_all_suite_info) c - order by c.object_owner, c.object_name, c.item_line_no; - else - open l_result for - select value(c) - from table(l_all_suite_info) c - where exists - ( select 1 - from all_objects a - where a.object_name = c.object_name - and a.owner = c.object_owner - and a.object_type = 'PACKAGE' - ) - order by c.object_owner, c.object_name, c.item_line_no; - end if; return l_result; end; @@ -627,8 +546,8 @@ create or replace package body ut_suite_manager is refresh_cache(l_owner_name); l_item_exists := ut_suite_cache_manager.suite_item_exists( l_owner_name, l_package_name, l_procedure_name ); - if not can_skip_all_objects_scan( l_owner_name ) then - select count(1) + if not can_skip_access_check( l_owner_name ) and l_package_name is not null then + select /*+ no_parallel */ count(1) into l_count from dual c where exists diff --git a/source/core/ut_suite_manager.pks b/source/core/ut_suite_manager.pks index 093201b36..b381ecc63 100644 --- a/source/core/ut_suite_manager.pks +++ b/source/core/ut_suite_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_suite_manager authid current_user is +create or replace noneditionable package ut_suite_manager authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,6 +20,13 @@ create or replace package ut_suite_manager authid current_user is * Resposible for building hierarhy of sutes from individual suites created by suite_builder */ + /* + * The package runs with invoker rights. It calls the SQL macros of ut_suite_cache_macros in SQL statements + * through the code based access control role _cbac_modify_objects_role granted to the package, + * so the references to framework objects in those statements are qualified with the framework owner. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. + */ + /** * @private * @@ -30,7 +37,7 @@ create or replace package ut_suite_manager authid current_user is * @param a_schema_names list of schemas to return the information for * @return array containing unit test schema and object names */ - function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names; + function get_schema_ut_packages(a_schema_names ut_varchar2_rows, a_schema_name_expr varchar2) return ut_object_names; /** * Builds a hierarchical suites based on given suite-paths @@ -39,6 +46,7 @@ create or replace package ut_suite_manager authid current_user is * @return array containing root suites-ready to be executed * */ + --TODO:Zerknij czy mozna wywalic function configure_execution_by_path(a_paths ut_varchar2_list, a_random_seed positive := null) return ut_suite_items; /** @@ -52,7 +60,7 @@ create or replace package ut_suite_manager authid current_user is a_paths in ut_varchar2_list, a_suites out nocopy ut_suite_items, a_random_seed in positive := null, - a_tags ut_varchar2_rows := ut_varchar2_rows() + a_tags in varchar2 := null ); /** @@ -71,23 +79,18 @@ create or replace package ut_suite_manager authid current_user is a_annotated_objects sys_refcursor, a_path varchar2 := null, a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false + a_procedure_name varchar2 := null ) return ut_suite_items; /** * Returns a ref cursor containing information about unit test suites and the tests contained in them * - * @param a_owner owner of unit tests to retrieve - * @param a_package_name name of test package (optional) - * @param a_procedure_name name of test procedure (optional) - * @return ut_suite_items_info table of objects + * @param a_paths list of paths to be resolved and return a suites. */ function get_suites_info( - a_owner_name varchar2, - a_package_name varchar2 := null - ) return sys_refcursor; + a_paths ut_varchar2_list + ) return sys_refcursor; /** * Returns true if given suite item exists diff --git a/source/core/ut_suite_tag_filter.pkb b/source/core/ut_suite_tag_filter.pkb new file mode 100644 index 000000000..1ff204a5e --- /dev/null +++ b/source/core/ut_suite_tag_filter.pkb @@ -0,0 +1,257 @@ +create or replace noneditionable package body ut_suite_tag_filter is + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /** + * Constants used in the conversion to postfix notation + */ + gc_operators constant ut_varchar2_list := ut_varchar2_list('|','&','!'); + gc_unary_operators constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator + gc_binary_operators constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator + gc_exception_msg constant varchar2(200) := 'Invalid tag expression'; + + type t_precedence_table is table of number index by varchar2(1); + g_precedence t_precedence_table; + + g_last_tag_expression varchar2(32767); + g_last_postfix ut_varchar2_list; + + function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list is + l_tags_tokens ut_varchar2_list := ut_varchar2_list(); + begin + if a_tags is not null then + select regexp_substr(a_tags,'([^!()|&]+)|([!()|&])', 1, level) as string_parts + bulk collect into l_tags_tokens + from dual connect by regexp_substr (a_tags, '([^!()|&]+)|([!()|&])', 1, level) is not null; + end if; + + return l_tags_tokens; + end; + + function remove_whitespace(a_tag_expression varchar2) return varchar2 is + begin + return replace(replace(a_tag_expression, ' '), chr(9)); + end; + + /* + To support a legacy tag notation + , = OR + - = NOT + we replace those characters into + new notation. + | = OR + & = AND + ! = NOT + */ + function replace_legacy_tag_notation(a_tags varchar2) return varchar2 is + l_tags ut_varchar2_list := ut_utils.string_to_table(a_tags,','); + l_tags_include varchar2(4000); + l_tags_exclude varchar2(4000); + l_return_tag varchar2(4000); + begin + if instr(a_tags,',') > 0 or instr(a_tags,'-') > 0 then + + select '('||listagg( t.column_value,'|') + within group( order by column_value)||')' + into l_tags_include + from table(l_tags) t + where t.column_value not like '-%'; + + select '('||listagg( replace(t.column_value,'-','!'),'&') + within group( order by column_value)||')' + into l_tags_exclude + from table(l_tags) t + where t.column_value like '-%'; + + + l_return_tag:= + case + when l_tags_include <> '()' and l_tags_exclude <> '()' + then l_tags_include || '&' || l_tags_exclude + when l_tags_include <> '()' + then l_tags_include + when l_tags_exclude <> '()' + then l_tags_exclude + end; + else + l_return_tag := a_tags; + end if; + return l_return_tag; + end; + + /* + https://stackoverflow.com/questions/29634992/shunting-yard-validate-expression + */ + function shunt_logical_expression(a_tags in ut_varchar2_list) return ut_varchar2_list is + l_operator_stack ut_stack := ut_stack(); + l_rnp_tokens ut_varchar2_list := ut_varchar2_list(); + l_token varchar2(32767); + l_expect_operand boolean := true; + l_expect_operator boolean := false; + l_idx pls_integer; + begin + l_idx := a_tags.first; + --Execute modified shunting algorithm + WHILE (l_idx is not null) loop + l_token := a_tags(l_idx); + if (l_token member of gc_operators and l_token member of gc_binary_operators) then + if not(l_expect_operator) then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + while l_operator_stack.top > 0 and (g_precedence(l_operator_stack.peek) > g_precedence(l_token)) loop + l_rnp_tokens.extend; + l_rnp_tokens(l_rnp_tokens.last) := l_operator_stack.pop; + end loop; + l_operator_stack.push(a_tags(l_idx)); + l_expect_operand := true; + l_expect_operator:= false; + elsif (l_token member of gc_operators and l_token member of gc_unary_operators) then + if not(l_expect_operand) then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + l_operator_stack.push(a_tags(l_idx)); + l_expect_operand := true; + l_expect_operator:= false; + elsif l_token = '(' then + if not(l_expect_operand) then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + l_operator_stack.push(a_tags(l_idx)); + l_expect_operand := true; + l_expect_operator:= false; + elsif l_token = ')' then + if not(l_expect_operator) then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + while l_operator_stack.peek <> '(' loop + l_rnp_tokens.extend; + l_rnp_tokens(l_rnp_tokens.last) := l_operator_stack.pop; + end loop; + --no open bracket left on the stack: unmatched right bracket + if l_operator_stack.peek is null then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + l_operator_stack.pop; --Pop the open bracket and discard it + l_expect_operand := false; + l_expect_operator:= true; + else + if not(l_expect_operand) then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + l_rnp_tokens.extend; + l_rnp_tokens(l_rnp_tokens.last) :=l_token; + l_expect_operator := true; + l_expect_operand := false; + end if; + + l_idx := a_tags.next(l_idx); + end loop; + + --an empty expression, or one ending with an operator or a left bracket, is incomplete + if not(l_expect_operator) then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + + while l_operator_stack.peek is not null loop + if l_operator_stack.peek in ('(',')') then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + l_rnp_tokens.extend; + l_rnp_tokens(l_rnp_tokens.last):=l_operator_stack.pop; + end loop; + + return l_rnp_tokens; + end shunt_logical_expression; + + /* + Returns a tag expression in postfix notation (Reverse Polish Notation). + is_matching is called for each test with the same expression, so the result for the last expression is cached. + Raises ut_utils.gc_invalid_tag_expression for an invalid expression. + */ + function get_postfix_expression(a_tag_expression varchar2) return ut_varchar2_list is + l_postfix ut_varchar2_list; + begin + if g_last_tag_expression = a_tag_expression then + return g_last_postfix; + end if; + l_postfix := shunt_logical_expression( + tokenize_tags_string( replace_legacy_tag_notation( a_tag_expression ) ) + ); + g_last_tag_expression := a_tag_expression; + g_last_postfix := l_postfix; + return l_postfix; + end; + + /* + Evaluates a valid postfix expression against a list of tags, using a stack of operand values. + The values follow the three-valued logic of SQL: "x member of a_tags" is null when a_tags has a null element + and no element x, and "not null" is null, as in a SQL condition. + */ + function evaluate_postfix(a_postfix ut_varchar2_list, a_tags ut_varchar2_list) return boolean is + type t_boolean_stack is table of boolean index by pls_integer; + l_stack t_boolean_stack; + l_top pls_integer := 0; + l_token varchar2(32767); + begin + for i in 1 .. a_postfix.count loop + l_token := a_postfix(i); + case l_token + when '!' then + l_stack(l_top) := not l_stack(l_top); + when '&' then + l_top := l_top - 1; + l_stack(l_top) := l_stack(l_top) and l_stack(l_top + 1); + when '|' then + l_top := l_top - 1; + l_stack(l_top) := l_stack(l_top) or l_stack(l_top + 1); + else + l_top := l_top + 1; + l_stack(l_top) := + case l_token + when 'none' then a_tags is empty + when 'any' then a_tags is not empty + else l_token member of a_tags + end; + end case; + end loop; + return l_stack(1); + end; + + function is_matching(a_tags varchar2, a_tag_expression varchar2) return integer deterministic is + l_tag_expression varchar2(32767) := remove_whitespace(a_tag_expression); + begin + return + case + when l_tag_expression is null + then 1 + when evaluate_postfix( get_postfix_expression(l_tag_expression), ut_utils.string_to_table(a_tags, ',') ) + then 1 + else 0 + end; + end; + + +begin + --Define operators precedence + g_precedence('!'):=4; + g_precedence('&'):=3; + g_precedence('|'):=2; + g_precedence(')'):=1; + g_precedence('('):=1; + +end ut_suite_tag_filter; +/ diff --git a/source/core/ut_suite_tag_filter.pks b/source/core/ut_suite_tag_filter.pks new file mode 100644 index 000000000..3520c33c6 --- /dev/null +++ b/source/core/ut_suite_tag_filter.pks @@ -0,0 +1,56 @@ +create or replace noneditionable package ut_suite_tag_filter authid definer is + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /** + * Package that evaluates tag expressions against the tags of suite items. + * is_matching is called from SQL by ut_suite_cache_manager.get_suite_rows to filter suites by tags. + * + */ + + /* + * Return table of tokens character by character + */ + function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list; + + /* + * Function that uses Dijkstra algorithm to parse mathematical and logical expression + * and return a list of elements in Reverse Polish Notation ( postfix ) + * As part of execution it will validate expression. + */ + function shunt_logical_expression(a_tags in ut_varchar2_list) return ut_varchar2_list; + + /* + * Returns the tag expression without spaces and tabs. + * Tags cannot contain whitespace, so it only separates the tokens of an expression. + * An expression made only of spaces and tabs becomes null, which is no tag filter. + */ + function remove_whitespace(a_tag_expression varchar2) return varchar2; + + /* + * Returns 1 when the tags match the tag expression, 0 otherwise. + * An empty tag expression (see remove_whitespace) matches any tags. + * a_tags is a comma-separated list of tags (tags cannot contain commas), null for no tags. + * Takes text, not a collection: Oracle caches results of a deterministic function called from SQL + * only when all arguments are scalars, so items with the same tags are evaluated once per statement. + * Raises ut_utils.gc_invalid_tag_expression for an invalid expression. + */ + function is_matching(a_tags varchar2, a_tag_expression varchar2) + return integer deterministic; + +end ut_suite_tag_filter; +/ diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 9641275ea..865e9e17c 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_utils is +create or replace noneditionable package body ut_utils is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -19,9 +19,13 @@ create or replace package body ut_utils is /** * Constants regex used to validate XML name */ - gc_invalid_first_xml_char constant varchar2(50) := '[^_a-zA-Z]'; - gc_invalid_xml_char constant varchar2(50) := '[^_a-zA-Z0-9\.-]'; - gc_full_valid_xml_name constant varchar2(50) := '^([_a-zA-Z])([_a-zA-Z0-9\.-])*$'; + gc_invalid_first_xml_char constant varchar2(50) := '[^_[:alpha:]]'; + gc_invalid_xml_char constant varchar2(50) := '[^_[:alnum:]\.-]'; + gc_full_valid_xml_name constant varchar2(50) := '^([[:alpha:]])([_[:alnum:]\.-])*$'; + gc_owner_hash constant integer(11) := dbms_utility.get_hash_value( ut_owner(), 0, power(2,31)-1); + gc_open_chars constant varchar2(4):= '[{(<'; + gc_close_chars constant varchar2(4):= ']})>'; + gc_max_plsql_source_len constant integer := 32767; function surround_with(a_value varchar2, a_quote_char varchar2) return varchar2 is begin @@ -59,7 +63,7 @@ create or replace package body ut_utils is function gen_savepoint_name return varchar2 is begin - return 's'||trim(to_char(ut_savepoint_seq.nextval,'0000000000000000000000000000')); + return 's'||gc_owner_hash||trim(to_char(ut_savepoint_seq.nextval,'00000000000000000')); end; procedure debug_log(a_message varchar2) is @@ -90,8 +94,8 @@ create or replace package body ut_utils is a_max_output_len in number := gc_max_output_string_length ) return varchar2 is l_result varchar2(32767); - c_length constant integer := coalesce( length( a_value ), 0 ); - c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 ); + c_length constant integer := coalesce( lengthb( a_value ), 0 ); + c_max_input_string_length constant integer := a_max_output_len - coalesce( lengthb( a_quote_char ) * 2, 0 ); c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len; begin if c_length = 0 then @@ -110,8 +114,8 @@ create or replace package body ut_utils is a_max_output_len in number := gc_max_output_string_length ) return varchar2 is l_result varchar2(32767); - c_length constant integer := coalesce(dbms_lob.getlength(a_value), 0); - c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 ); + c_length constant integer := coalesce(ut_utils.lengthb_clob(a_value), 0); + c_max_input_string_length constant integer := a_max_output_len - coalesce( lengthb( a_quote_char ) * 2, 0 ); c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len; begin if a_value is null then @@ -133,7 +137,7 @@ create or replace package body ut_utils is ) return varchar2 is l_result varchar2(32767); c_length constant integer := coalesce(dbms_lob.getlength(a_value), 0); - c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 ); + c_max_input_string_length constant integer := a_max_output_len - coalesce( lengthb( a_quote_char ) * 2, 0 ); c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len; begin if a_value is null then @@ -228,6 +232,19 @@ create or replace package body ut_utils is return l_result; end; + function string_table_to_table(a_list ut_varchar2_list, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list is + l_result ut_varchar2_list; + begin + if a_delimiter is null then + l_result := a_list; + elsif a_list is not empty then + for i in 1 .. a_list.count loop + ut_utils.append_to_list(l_result, ut_utils.string_to_table(a_list(i), a_delimiter, a_skip_leading_delimiter) ); + end loop; + end if; + return l_result; + end; + function clob_to_table(a_clob clob, a_max_amount integer := 8191, a_delimiter varchar2:= chr(10)) return ut_varchar2_list is l_offset integer := 1; l_length integer := dbms_lob.getlength(a_clob); @@ -336,7 +353,7 @@ create or replace package body ut_utils is function get_utplsql_objects_list return ut_object_names is l_result ut_object_names; begin - select distinct ut_object_name(sys_context('userenv','current_user'), o.object_name) + select /*+ no_parallel */ distinct ut_object_name(sys_context('userenv','current_user'), o.object_name) bulk collect into l_result from user_objects o where o.object_name = 'UT' or object_name like 'UT\_%' escape '\' @@ -368,6 +385,19 @@ create or replace package body ut_utils is end if; end; + procedure append_to_list(a_list in out nocopy ut_varchar2_list, a_items ut_varchar2_list) is + begin + if a_items is not null then + if a_list is null then + a_list := ut_varchar2_list(); + end if; + for i in 1 .. a_items.count loop + a_list.extend; + a_list(a_list.last) := a_items(i); + end loop; + end if; + end; + procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item clob) is begin append_to_list( @@ -384,7 +414,7 @@ create or replace package body ut_utils is if a_list is null then a_list := ut_varchar2_rows(); end if; - if length(a_item) > gc_max_storage_varchar2_len then + if lengthb(a_item) > gc_max_storage_varchar2_len then append_to_list( a_list, ut_utils.convert_collection( @@ -440,7 +470,7 @@ create or replace package body ut_utils is l_result := ut_varchar2_rows(); for i in 1 .. a_collection.count loop l_result.extend(); - l_result(i) := substr(a_collection(i),1,gc_max_storage_varchar2_len); + l_result(i) := substrb(a_collection(i),1,gc_max_storage_varchar2_len); end loop; end if; return l_result; @@ -478,13 +508,6 @@ create or replace package body ut_utils is return l_xpath; end; - procedure cleanup_session_temp_tables is - begin - execute immediate 'truncate table dbmspcc_blocks'; - execute immediate 'truncate table dbmspcc_units'; - execute immediate 'truncate table dbmspcc_runs'; - end; - function to_version(a_version_no varchar2) return t_version is l_result t_version; c_version_part_regex constant varchar2(20) := '[0-9]+'; @@ -511,9 +534,11 @@ create or replace package body ut_utils is procedure flush_lines(a_lines ut_varchar2_rows, a_offset integer) is begin - insert into ut_dbms_output_cache (seq_no,text) - select rownum+a_offset, column_value - from table(a_lines); + if a_lines is not empty then + insert /*+ no_parallel */ into ut_dbms_output_cache (seq_no,text) + select /*+ no_parallel */ rownum+a_offset, column_value + from table(a_lines); + end if; end; begin loop @@ -533,10 +558,10 @@ create or replace package body ut_utils is procedure read_cache_to_dbms_output is l_lines_data sys_refcursor; l_lines ut_varchar2_rows; - c_lines_limit constant integer := 1000; + c_lines_limit constant integer := 10000; pragma autonomous_transaction; begin - open l_lines_data for select text from ut_dbms_output_cache order by seq_no; + open l_lines_data for select /*+ no_parallel */ text from ut_dbms_output_cache order by seq_no; loop fetch l_lines_data bulk collect into l_lines limit c_lines_limit; for i in 1 .. l_lines.count loop @@ -548,13 +573,14 @@ create or replace package body ut_utils is end loop; exit when l_lines_data%notfound; end loop; + close l_lines_data; execute immediate 'truncate table ut_dbms_output_cache'; commit; end; function ut_owner return varchar2 is begin - return sys_context('userenv','current_schema'); + return qualified_sql_name( sys_context('userenv','current_schema') ); end; function scale_cardinality(a_cardinality natural) return natural is @@ -624,104 +650,244 @@ create or replace package body ut_utils is function xmlgen_escaped_string(a_string in varchar2) return varchar2 is l_result varchar2(4000) := a_string; - l_sql varchar2(32767) := q'!select q'[!'||a_string||q'!]' as "!'||a_string||'" from dual'; + l_sql varchar2(32767) := q'!select /*+ no_parallel */ q'[!'||a_string||q'!]' as "!'||a_string||'" from dual'; begin if a_string is not null then - select extract(dbms_xmlgen.getxmltype(l_sql),'/*/*/*').getRootElement() + select /*+ no_parallel */ extract(dbms_xmlgen.getxmltype(l_sql),'/*/*/*').getRootElement() into l_result from dual; end if; return l_result; end; - function replace_multiline_comments(a_source clob) return clob is - l_result clob; - l_ml_comment_start binary_integer := 1; - l_comment_start binary_integer := 1; - l_text_start binary_integer := 1; - l_escaped_text_start binary_integer := 1; - l_escaped_text_end_char varchar2(1 char); - l_end binary_integer := 1; - l_ml_comment clob; - l_newlines_count binary_integer; - l_offset binary_integer := 1; - l_length binary_integer := coalesce(dbms_lob.getlength(a_source), 0); - begin - l_ml_comment_start := instr(a_source,'/*'); - l_comment_start := instr(a_source,'--'); - l_text_start := instr(a_source,''''); - l_escaped_text_start := instr(a_source,q'[q']'); - while l_offset > 0 and l_ml_comment_start > 0 loop - - if l_ml_comment_start > 0 and (l_ml_comment_start < l_comment_start or l_comment_start = 0) - and (l_ml_comment_start < l_text_start or l_text_start = 0)and (l_ml_comment_start < l_escaped_text_start or l_escaped_text_start = 0) - then - l_end := instr(a_source,'*/',l_ml_comment_start+2); - append_to_clob(l_result, dbms_lob.substr(a_source, l_ml_comment_start-l_offset, l_offset)); + function scan_line(a_line in varchar2, a_in_ml_comment in out boolean) return varchar2 is + -- Normal scan + l_remaining varchar2(32767) := a_line; + l_line varchar2(32767); + l_ml_start binary_integer; + l_comment_start binary_integer; + l_text_start binary_integer; + l_eq_text_start binary_integer; + l_eq_end_char varchar2(1 char); + l_pos binary_integer; + l_end binary_integer; + l_ml_end binary_integer; + begin + if a_in_ml_comment then + l_ml_end := instr(l_remaining, '*/'); + if l_ml_end > 0 then + a_in_ml_comment := false; + l_remaining := substr(l_remaining, l_ml_end + 2); + else + return null; + end if; + end if; + + loop + exit when l_remaining is null; + l_ml_start := instr(l_remaining, '/*'); + l_comment_start := instr(l_remaining, '--'); + l_text_start := instr(l_remaining, ''''); + -- q' always puts ' at l_text_start; just check the char immediately before it + l_eq_text_start := case + when l_text_start > 1 and substr(l_remaining, l_text_start - 1, 1) = 'q' + then l_text_start - 1 + else 0 + end; + -- Sentinel gc_max_plsql_source_len means "not present"; 32767 is beyond any VARCHAR2 position + l_pos := least( + case when l_ml_start > 0 then l_ml_start else gc_max_plsql_source_len end, + case when l_comment_start > 0 then l_comment_start else gc_max_plsql_source_len end, + case when l_text_start > 0 then l_text_start else gc_max_plsql_source_len end, + case when l_eq_text_start > 0 then l_eq_text_start else gc_max_plsql_source_len end + ); + + if l_pos = gc_max_plsql_source_len then + l_line := l_line || l_remaining; + exit; + end if; + + l_line := l_line || substr(l_remaining, 1, l_pos - 1); + l_remaining := substr(l_remaining, l_pos); + -- l_remaining now starts exactly at the token; all branch offsets below are relative to 1 + if l_pos = l_eq_text_start then + -- q-quoted string: l_remaining starts at 'q', delimiter is at position 3 + l_eq_end_char := translate(substr(l_remaining, 3, 1), gc_open_chars, gc_close_chars); + l_end := instr(l_remaining, l_eq_end_char || '''', 4); if l_end > 0 then - l_ml_comment := substr(a_source, l_ml_comment_start, l_end-l_ml_comment_start); - l_newlines_count := length( l_ml_comment ) - length( translate( l_ml_comment, 'a'||chr(10), 'a') ); - if l_newlines_count > 0 then - append_to_clob(l_result, lpad( chr(10), l_newlines_count, chr(10) ) ); - end if; - l_end := l_end + 2; + l_line := l_line || substr(l_remaining, 1, l_end + 1); + l_remaining := substr(l_remaining, l_end + 2); + else + l_line := l_line || l_remaining; + exit; end if; - else - if l_comment_start > 0 and (l_comment_start < l_ml_comment_start or l_ml_comment_start = 0) - and (l_comment_start < l_text_start or l_text_start = 0) and (l_comment_start < l_escaped_text_start or l_escaped_text_start = 0) - then - l_end := instr(a_source,chr(10),l_comment_start+2); - if l_end > 0 then - l_end := l_end + 1; - end if; - elsif l_text_start > 0 and (l_text_start < l_ml_comment_start or l_ml_comment_start = 0) - and (l_text_start < l_comment_start or l_comment_start = 0) and (l_text_start < l_escaped_text_start or l_escaped_text_start = 0) - then - l_end := instr(a_source,q'[']',l_text_start+1); - - --skip double quotes while searching for end of quoted text - while l_end > 0 and l_end = instr(a_source,q'['']',l_text_start+1) loop - l_end := instr(a_source,q'[']',l_end+1); - end loop; - if l_end > 0 then - l_end := l_end + 1; + elsif l_pos = l_ml_start then + -- Multi-line comment: l_remaining starts at '/*', so end search starts at 3 + l_ml_end := instr(l_remaining, '*/', 3); + if l_ml_end > 0 then + l_remaining := substr(l_remaining, l_ml_end + 2); + else + a_in_ml_comment := true; + -- preserve trailing newline if present — it belongs to this line, not the comment + if substr(l_remaining, -1) = chr(10) then + l_line := l_line || chr(10); end if; + return l_line; + end if; - elsif l_escaped_text_start > 0 and (l_escaped_text_start < l_ml_comment_start or l_ml_comment_start = 0) - and (l_escaped_text_start < l_comment_start or l_comment_start = 0) and (l_escaped_text_start < l_text_start or l_text_start = 0) - then - --translate char "[" from the start of quoted text "q'[someting]'" into "]" - l_escaped_text_end_char := translate( substr(a_source, l_escaped_text_start + 2, 1), '[{(<', ']})>'); - l_end := instr(a_source,l_escaped_text_end_char||'''',l_escaped_text_start + 3 ); - if l_end > 0 then - l_end := l_end + 2; + elsif l_pos = l_comment_start then + -- Single-line comment: everything from here is comment, keep and stop + l_line := l_line || l_remaining; + return l_line; + + else + -- Regular string literal: l_remaining starts at the opening quote + -- scan from position 2 to skip the opening quote + l_end := 2; + loop + l_end := instr(l_remaining, '''', l_end); + exit when l_end = 0; + if substr(l_remaining, l_end, 2) = '''''' then + l_end := l_end + 2; -- skip escaped quote pair + else + exit; -- real closing quote end if; - end if; + end loop; - if l_end = 0 then - append_to_clob(l_result, substr(a_source, l_offset, l_length-l_offset)); + if l_end > 0 then + l_line := l_line || substr(l_remaining, 1, l_end); + l_remaining := substr(l_remaining, l_end + 1); else - append_to_clob(l_result, substr(a_source, l_offset, l_end-l_offset)); + l_line := l_line || l_remaining; + exit; end if; + end if; - l_offset := l_end; - if l_offset >= l_ml_comment_start then - l_ml_comment_start := instr(a_source,'/*',l_offset); + end loop; + + return l_line; + end; + + function replace_multiline_comments(a_source dbms_preprocessor.source_lines_t) + return dbms_preprocessor.source_lines_t + is + l_result dbms_preprocessor.source_lines_t; + l_line varchar2(32767); + l_remaining varchar2(32767); + l_in_ml_comment boolean := false; + l_ml_end binary_integer; + l_has_ml_comment boolean := false; + begin + if a_source.count = 0 then + return a_source; + end if; + + -- Fast pre-scan to check for presence of multi-line comments; if none, return original source unmodified + for i in 1 .. a_source.count loop + if instr(a_source(i), '/*') > 0 then + l_has_ml_comment := true; + exit; end if; - if l_offset >= l_comment_start then - l_comment_start := instr(a_source,'--',l_offset); + end loop; + + if not l_has_ml_comment then + return a_source; + end if; + + for i in 1 .. a_source.count loop + l_line := a_source(i); + + -- Fast path: inside multi-line comment + if l_in_ml_comment then + l_ml_end := instr(l_line, '*/'); + if l_ml_end > 0 then + l_in_ml_comment := false; + l_line := substr(l_line, l_ml_end + 2); + -- fall through to normal scan + else + l_result(i) := ''; + continue; + end if; end if; - if l_offset >= l_text_start then - l_text_start := instr(a_source,'''',l_offset); + + -- Fast path: no special tokens on this line + if instr(l_line, '/') = 0 + and instr(l_line, '-') = 0 + and instr(l_line, '''') = 0 + then + l_result(i) := l_line; + continue; end if; - if l_offset >= l_escaped_text_start then - l_escaped_text_start := instr(a_source,q'[q']',l_offset); + + -- Normal scan + l_remaining := l_line; + l_line := scan_line(l_remaining, l_in_ml_comment); + if l_line is null then + l_line := ''; end if; + l_result(i) := l_line; end loop; - append_to_clob(l_result, substr(a_source, l_end)); + return l_result; - end; + end replace_multiline_comments; + + function strip_create_header_lines(a_source dbms_preprocessor.source_lines_t) + return dbms_preprocessor.source_lines_t + is + l_result dbms_preprocessor.source_lines_t := a_source; + l_rebased dbms_preprocessor.source_lines_t; + l_create_line pls_integer; + l_header_line pls_integer; + l_header_pos pls_integer := 0; + begin + if l_result.count = 0 then + return l_result; + end if; + + -- remove comment lines that contain "-- create or replace" and find first CREATE + for i in 1..l_result.count loop + l_result(i) := regexp_replace(l_result(i), '^.*[-]{2,}\s*create(\s+or\s+replace).*$', null, 1, 1, 'i'); + if l_create_line is null and regexp_like(l_result(i), '(^|[[:space:]])create([[:space:]]|$)', 'i') then + l_create_line := i; + end if; + end loop; + + -- find first occurrence of object keyword after CREATE (may be on later line) + if l_create_line is not null then + for i in l_create_line..l_result.count loop + l_header_pos := regexp_instr( + l_result(i), + '(^|[[:space:]])(package|type|procedure|function)([[:space:]]|$)', + 1, 1, 0, 'i', 2 + ); + if l_header_pos > 0 then + l_header_line := i; + exit; + end if; + end loop; + + if l_header_line is not null then + -- keep from keyword onward on the header line + l_result(l_header_line) := substr(l_result(l_header_line), l_header_pos); + -- remove "OWNER." from create or replace statement. + -- Owner is not supported along with AUTHID - see issue https://github.com/utPLSQL/utPLSQL/issues/1088 + l_result(l_header_line) := regexp_replace( + l_result(l_header_line), + '^(package|type|procedure|function)\s+("?[[:alpha:]][[:alnum:]$#_]*"?\.)(.*)', + '\1 \3', 1, 1, 'ni' + ); + + -- rebase so header line becomes line 1 (matches preprocessor expectations) + for i in l_header_line .. l_result.count loop + l_rebased(i - l_header_line + 1) := l_result(i); + end loop; + return l_rebased; + end if; + end if; + + return l_result; + end strip_create_header_lines; function get_child_reporters(a_for_reporters ut_reporters_info := null) return ut_reporters_info is l_for_reporters ut_reporters_info := a_for_reporters; @@ -731,7 +897,7 @@ create or replace package body ut_utils is l_for_reporters := ut_reporters_info(ut_reporter_info('UT_REPORTER_BASE','N','N','N')); end if; - select /*+ cardinality(f 10) */ + select /*+ no_parallel cardinality(f 10) */ ut_reporter_info( object_name => t.type_name, is_output_reporter => @@ -765,9 +931,9 @@ create or replace package body ut_utils is /** * Change string into unicode to match xmlgen format _00_ + * See the section of Oracle documentation called: Escape of Characters in Generated XML Data * https://docs.oracle.com/en/database/oracle/oracle-database/12.2/adxdb/generation-of-XML-data-from-relational-data.html#GUID-5BE09A7D-80D8-4734-B9AF-4A61F27FA9B2 - * secion v3.1.8.3169-develop - */ + */ function char_to_xmlgen_unicode(a_character varchar2) return varchar2 is begin return '_x00'||rawtohex(utl_raw.cast_to_raw(a_character))||'_'; @@ -779,7 +945,7 @@ create or replace package body ut_utils is function build_valid_xml_name(a_preprocessed_name varchar2) return varchar2 is l_post_processed varchar2(4000); begin - for i in (select regexp_substr( a_preprocessed_name ,'(.{1})', 1, level, null, 1 ) AS string_char,level level_no + for i in (select /*+ no_parallel */ regexp_substr( a_preprocessed_name ,'(.{1})', 1, level, null, 1 ) AS string_char,level level_no from dual connect by level <= regexp_count(a_preprocessed_name, '(.{1})')) loop if i.level_no = 1 and regexp_like(i.string_char,gc_invalid_first_xml_char) then @@ -824,6 +990,9 @@ create or replace package body ut_utils is begin if a_clob is not null and a_clob != empty_clob() then l_result := replace( a_clob, gc_cdata_end_tag, gc_cdata_end_tag_wrap ); + l_result := to_clob(gc_cdata_start_tag) + || replace( a_clob, gc_cdata_end_tag, gc_cdata_end_tag_wrap ) + || to_clob(gc_cdata_end_tag); else l_result := a_clob; end if; @@ -855,14 +1024,47 @@ create or replace package body ut_utils is return regexp_replace(a_item,a_prefix||a_connector); end; - function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is + function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh256) return t_hash is begin - return dbms_crypto.hash(a_data, a_hash_type); + --We cannot run hash on null + return case when a_data is null then null else dbms_crypto.hash(a_data, a_hash_type) end; end; - function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is + function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh256) return t_hash is begin - return dbms_crypto.hash(a_data, a_hash_type); + --We cannot run hash on null + return case when a_data is null then null else dbms_crypto.hash(a_data, a_hash_type) end; + end; + + function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is + l_start_pos pls_integer := 1; + l_end_pos pls_integer := 1; + l_result varchar2(4000); + l_item varchar2(4000); + l_at_end boolean := false; + begin + if a_random_seed is null then + l_result := a_path; + end if; + if a_path is not null then + loop + l_end_pos := instr(a_path,'.',l_start_pos); + if l_end_pos = 0 then + l_end_pos := length(a_path)+1; + l_at_end := true; + end if; + l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos); + if l_item is not null then + l_result := + l_result || + ut_utils.get_hash( to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ) ); + end if; + exit when l_at_end; + l_result := l_result || chr(0); + l_start_pos := l_end_pos + 1; + end loop; + end if; + return l_result; end; function qualified_sql_name(a_name varchar2) return varchar2 is @@ -874,5 +1076,95 @@ create or replace package body ut_utils is end; end; + function interval_to_text(a_interval dsinterval_unconstrained) return varchar2 is + l_day varchar2(100) := extract(day from a_interval); + l_hour varchar2(100) := extract(hour from a_interval); + l_minute varchar2(100) := extract(minute from a_interval); + l_second varchar2(100) := extract(second from a_interval); + l_result varchar2(32767); + begin + l_result := case + when l_day = 1 then l_day ||' day' + when l_day > 1 then l_day ||' days' + end || + case + when l_hour = 1 then ' '|| l_hour ||' hour' + when l_hour > 1 then ' '|| l_hour ||' hours' + end || + case + when l_minute = 1 then ' '||l_minute ||' minute' + when l_minute > 1 then ' '||l_minute ||' minutes' + end || + case + when l_second > 1 then ' '||l_second ||' seconds' + when l_second = 1 then ' '||l_second ||' second' + when l_second > 0 then ' '||l_second ||' seconds' + end; + l_result := + case + when a_interval is null then 'NULL' + when l_result is null then '0 seconds' + else ltrim(l_result,' ') + end; + + return l_result; + end; + + function interval_to_text(a_interval yminterval_unconstrained) return varchar2 is + l_year varchar2(4) := extract(year from a_interval); + l_month varchar2(20) := extract(month from a_interval); + l_result varchar2(32767); + begin + l_result := case + when l_year = 1 then l_year ||' year' + when l_year > 1 then l_year ||' years' + end || + case + when l_month > 1 then ' '||l_month ||' months' + when l_month = 1 then ' '||l_month ||' month' + end; + l_result := + case + when a_interval is null then 'NULL' + when l_result is null then '0 months' + else ltrim(l_result,' ') + end; + + return l_result; + end; + + + /* + * Inspired by + * https://stackoverflow.com/a/48782891 + */ + function lengthb_clob( a_clob clob) return integer is + l_blob blob; + l_desc_offset PLS_INTEGER := 1; + l_src_offset PLS_INTEGER := 1; + l_lang PLS_INTEGER := 0; + l_warning PLS_INTEGER := 0; + l_result integer; + begin + if a_clob = empty_clob() then + l_result := 0; + elsif a_clob is not null then + dbms_lob.createtemporary(l_blob,true); + dbms_lob.converttoblob + ( l_blob + , a_clob + , dbms_lob.getlength(a_clob) + , l_desc_offset + , l_src_offset + , dbms_lob.default_csid + , l_lang + , l_warning + ); + l_result := length(l_blob); + dbms_lob.freetemporary(l_blob); + end if; + return l_result; + end; + end ut_utils; / diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index f4923a751..d23659243 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -1,10 +1,10 @@ -create or replace package ut_utils authid definer is +create or replace noneditionable package ut_utils authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,8 +21,11 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.8.3169-develop'; - + gc_version constant varchar2(50) := 'v3.2.4.4670-develop'; + + gc_support_url constant varchar2(100) := 'https://utplsql.org/support'; + gc_support_text constant varchar2(200) := 'Using utPLSQL at work? Get support and help keep it maintained'; + subtype t_executable_type is varchar2(30); gc_before_all constant t_executable_type := 'beforeall'; gc_before_each constant t_executable_type := 'beforeeach'; @@ -121,15 +124,19 @@ create or replace package ut_utils authid definer is ex_failed_open_cur exception; gc_failed_open_cur constant pls_integer := -20218; pragma exception_init (ex_failed_open_cur, -20218); + + ex_invalid_tag_expression exception; + gc_invalid_tag_expression constant pls_integer := -20219; + pragma exception_init (ex_invalid_tag_expression, -20219); gc_max_storage_varchar2_len constant integer := 4000; gc_max_output_string_length constant integer := 4000; gc_more_data_string constant varchar2(5) := '[...]'; gc_more_data_string_len constant integer := length( gc_more_data_string ); gc_number_format constant varchar2(100) := 'TM9'; - gc_date_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ss'; - gc_timestamp_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ssxff'; - gc_timestamp_tz_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ssxff tzh:tzm'; + gc_date_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ss'; + gc_timestamp_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ssxff'; + gc_timestamp_tz_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ssxff tzh:tzm'; gc_null_string constant varchar2(4) := 'NULL'; gc_empty_string constant varchar2(5) := 'EMPTY'; @@ -216,8 +223,10 @@ create or replace package ut_utils authid definer is * * Splits a given string into table of string by delimiter. * The delimiter gets removed. - * If null passed as any of the parameters, empty table is returned. - * If no occurence of a_delimiter found in a_text then text is returned as a single row of the table. + * If null a_string passed, empty table is returned. + * If null a_delimiter passed, a_string is returned as element of result table. + * If null a_skip_leading_delimiter, it defaults to 'N' + * If no occurrence of a_delimiter found in a_text then text is returned as a single row of the table. * If no text between delimiters found then an empty row is returned, example: * string_to_table( 'a,,b', ',' ) gives table ut_varchar2_list( 'a', null, 'b' ); * @@ -229,14 +238,36 @@ create or replace package ut_utils authid definer is */ function string_to_table(a_string varchar2, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list; + /** + * + * Splits each string in table of string into a table of string using specified delimiter. + * The delimiter gets removed. + * If null a_delimiter passed, a_list is returned as-is. + * If null a_list passed, empty table is returned. + * If null a_skip_leading_delimiter, it defaults to 'N' + * If no occurrence of a_delimiter found in a_text then text is returned as a single row of the table. + * If no text between delimiters found then an empty row is returned, example: + * string_table_to_table( a_list => ut_varchar2_list('x','y',null,'a,,b'), a_delimiter=>',' ) gives table ut_varchar2_list( 'x', 'y', null, 'a', null, 'b' ); + * + * @param a_list the table of texts to be split. + * @param a_delimiter the delimiter character or string + * @param a_skip_leading_delimiter determines if the leading delimiter should be ignored, used by clob_to_table + * + * @return table of varchar2 values + */ + function string_table_to_table(a_list ut_varchar2_list, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list; + /** * Splits a given string into table of string by delimiter. * Default value of a_max_amount is 8191 because of code can contains multibyte character. * The delimiter gets removed. - * If null passed as any of the parameters, empty table is returned. + * If null a_clob passed, empty table is returned. + * If null a_delimiter passed, a_string is returned as element of result table. + * If null a_skip_leading_delimiter, it defaults to 'N' + * If no occurrence of a_delimiter found in a_text then text is returned as a single row of the table. * If split text is longer than a_max_amount it gets split into pieces of a_max_amount. * If no text between delimiters found then an empty row is returned, example: - * string_to_table( 'a,,b', ',' ) gives table ut_varchar2_list( 'a', null, 'b' ); + * clob_to_table( 'a,,b', ',' ) gives table ut_varchar2_list( 'a', null, 'b' ); * * @param a_clob the text to be split. * @param a_delimiter the delimiter character or string (default chr(10) ) @@ -287,6 +318,11 @@ create or replace package ut_utils authid definer is */ procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_items ut_varchar2_rows); + /** + * Append a list of items to the end of ut_varchar2_list + */ + procedure append_to_list(a_list in out nocopy ut_varchar2_list, a_items ut_varchar2_list); + procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, a_delimiter varchar2 := chr(10)); procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data clob); @@ -299,12 +335,6 @@ create or replace package ut_utils authid definer is function to_xpath(a_list ut_varchar2_list, a_ancestors varchar2 := '/*/') return varchar2; - /* - * Truncates session-level GTT's (on commit preserve rows) - * IMPORTANT: Procedure will do an implicit commit when called - */ - procedure cleanup_session_temp_tables; - /** * Converts version string into version record * @@ -378,7 +408,15 @@ create or replace package ut_utils authid definer is /** * Replaces multi-line comments in given source-code with empty lines */ - function replace_multiline_comments(a_source clob) return clob; + function replace_multiline_comments(a_source dbms_preprocessor.source_lines_t) + return dbms_preprocessor.source_lines_t; + + /** + * Strips the CREATE header (possibly split across lines) so source starts at + * package/type/procedure/function keyword, preserving line numbers. + */ + function strip_create_header_lines(a_source dbms_preprocessor.source_lines_t) + return dbms_preprocessor.source_lines_t; /** * Returns list of sub-type reporters for given list of super-type reporters @@ -422,18 +460,38 @@ create or replace package ut_utils authid definer is /* * Wrapper function for calling dbms_crypto.hash */ - function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; + function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh256) return t_hash; /* * Wrapper function for calling dbms_crypto.hash */ - function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; + function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh256) return t_hash; + + /* + * Returns a hash value of suitepath based on input path and random seed + */ + function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2; /* * Verifies that the input string is a qualified SQL name using sys.dbms_assert.qualified_sql_name * If null value passed returns null */ function qualified_sql_name(a_name varchar2) return varchar2; + + /* + * Return value of interval in plain english + */ + function interval_to_text(a_interval dsinterval_unconstrained) return varchar2; + + /* + * Return value of interval in plain english + */ + function interval_to_text(a_interval yminterval_unconstrained) return varchar2; + /* + * Return length of CLOB in bytes. Null for NULL + */ + function lengthb_clob( a_clob clob) return integer; + end ut_utils; / diff --git a/source/create_cbac_role.sql b/source/create_cbac_role.sql new file mode 100644 index 000000000..23082e34b --- /dev/null +++ b/source/create_cbac_role.sql @@ -0,0 +1,38 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Creates the code based access control (CBAC) role that gives invoker rights framework packages + access to framework tables, which are not granted to the users calling the framework. + The role is granted to the framework owner, as Oracle only allows granting a role to a program unit + when the role is granted to the owner of that program unit. + Each framework owner gets its own role, so packages of one utPLSQL installation cannot access tables of another one. + The role is created only if it does not exist yet, so the installation can be repeated without uninstalling first. +*/ + +prompt Creating role &&ut3_owner._cbac_modify_objects_role and granting it to &&ut3_owner + +declare + e_role_exists exception; + pragma exception_init(e_role_exists, -1921); +begin + execute immediate 'create role &&ut3_owner._cbac_modify_objects_role'; +exception + when e_role_exists then + null; +end; +/ + +grant &&ut3_owner._cbac_modify_objects_role to &&ut3_owner; diff --git a/source/create_grants.sql b/source/create_grants.sql index 4553c52f6..5cf7cfaaa 100644 --- a/source/create_grants.sql +++ b/source/create_grants.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -60,7 +60,15 @@ grant execute on &&ut3_owner..ut_file_mapping to &ut3_user; grant execute on &&ut3_owner..ut_file_mapper to &ut3_user; grant execute on &&ut3_owner..ut_suite_items_info to &ut3_user; grant execute on &&ut3_owner..ut_suite_item_info to &ut3_user; +grant execute on &&ut3_owner..ut_suite_cache_rows to &ut3_user; grant execute on &&ut3_owner..ut_run_info to &ut3_user; +grant execute on &&ut3_owner..ut_coverage_options to &ut3_user; + +--SQL macros used in SQL statements of the framework. +--On Oracle 21c XE, expanding a macro requires the calling user to have execute privilege on it. +--The macros only return SQL text; the tables they reference stay accessible only through the code based access control role. +grant execute on &&ut3_owner..ut_annotation_cache_macros to &ut3_user; +grant execute on &&ut3_owner..ut_suite_cache_macros to &ut3_user; --generic types grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user; @@ -87,6 +95,8 @@ grant execute on &&ut3_owner..ut_be_like to &ut3_user; grant execute on &&ut3_owner..ut_be_not_null to &ut3_user; grant execute on &&ut3_owner..ut_be_null to &ut3_user; grant execute on &&ut3_owner..ut_be_true to &ut3_user; +grant execute on &&ut3_owner..ut_be_within to &ut3_user; +grant execute on &&ut3_owner..ut_be_within_pct to &ut3_user; grant execute on &&ut3_owner..ut_contain to &ut3_user; grant execute on &&ut3_owner..ut_equal to &ut3_user; grant execute on &&ut3_owner..ut_have_count to &ut3_user; @@ -100,10 +110,10 @@ grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user; grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user; grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user; grant execute on &&ut3_owner..ut_realtime_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_tap_reporter to &ut3_user; --reporters - coverage grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user; grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user; grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user; --reporters - debug grant execute on &&ut3_owner..ut_debug_reporter to &ut3_user; @@ -119,6 +129,7 @@ grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user; grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user; grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user; grant execute on &&ut3_owner..ut_output_clob_table_buffer to &ut3_user; +grant execute on &&ut3_owner..ut_output_bulk_buffer to &ut3_user; --needed internally for selecting from annotation objects within packages that use invoker rights grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user; @@ -133,6 +144,7 @@ grant execute on &&ut3_owner..ut_suite_cache_rows to &ut3_user; grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user; grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user; grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user; +grant select on &&ut3_owner..ut_coverage_runs to &ut3_user; grant execute on &&ut3_owner..ut_matcher_options to &ut3_user; grant execute on &&ut3_owner..ut_matcher_options_items to &ut3_user; diff --git a/source/create_synonyms.sql b/source/create_synonyms.sql index 36dc465de..c862a389c 100644 --- a/source/create_synonyms.sql +++ b/source/create_synonyms.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -36,10 +36,10 @@ set termout off spool params.sql.tmp select case - when upper('&&ut3_user') = 'PUBLIC' then q'[define action_type='public' + when upper('&&ut3_user') = 'PUBLIC' then q'[define action_type='or replace noneditionable public' ]'||q'[define ut3_user='' ]'||q'[define grantee='PUBLIC']' - else q'[define action_type='or replace' + else q'[define action_type='or replace noneditionable' ]'||q'[define grantee='&&ut3_user'] ]'||q'[define ut3_user='&&ut3_user..']' end @@ -77,6 +77,7 @@ create &action_type. synonym &ut3_user.ut_file_mapper for &&ut3_owner..ut_file_m create &action_type. synonym &ut3_user.ut_suite_items_info for &&ut3_owner..ut_suite_items_info; create &action_type. synonym &ut3_user.ut_suite_item_info for &&ut3_owner..ut_suite_item_info; create &action_type. synonym &ut3_user.ut_run_info for &&ut3_owner..ut_run_info; +create &action_type. synonym &ut3_user.ut_coverage_options for &&ut3_owner..ut_coverage_options; --generic types create &action_type. synonym &ut3_user.ut_varchar2_list for &&ut3_owner..ut_varchar2_list; @@ -103,6 +104,8 @@ create &action_type. synonym &ut3_user.be_like for &&ut3_owner..be_like; create &action_type. synonym &ut3_user.be_not_null for &&ut3_owner..be_not_null; create &action_type. synonym &ut3_user.be_null for &&ut3_owner..be_null; create &action_type. synonym &ut3_user.be_true for &&ut3_owner..be_true; +create &action_type. synonym &ut3_user.be_within for &&ut3_owner..be_within; +create &action_type. synonym &ut3_user.be_within_pct for &&ut3_owner..be_within_pct; create &action_type. synonym &ut3_user.contain for &&ut3_owner..contain; create &action_type. synonym &ut3_user.equal for &&ut3_owner..equal; create &action_type. synonym &ut3_user.have_count for &&ut3_owner..have_count; @@ -116,10 +119,10 @@ create &action_type. synonym &ut3_user.ut_tfs_junit_reporter for &&ut3_owner..ut create &action_type. synonym &ut3_user.ut_documentation_reporter for &&ut3_owner..ut_documentation_reporter; create &action_type. synonym &ut3_user.ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; create &action_type. synonym &ut3_user.ut_realtime_reporter for &&ut3_owner..ut_realtime_reporter; +create &action_type. synonym &ut3_user.ut_tap_reporter for &&ut3_owner..ut_tap_reporter; --reporters - coverage create &action_type. synonym &ut3_user.ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; create &action_type. synonym &ut3_user.ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; -create &action_type. synonym &ut3_user.ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; create &action_type. synonym &ut3_user.ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; --reporters - debug create &action_type. synonym &ut3_user.ut_debug_reporter for &&ut3_owner..ut_debug_reporter; diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql index 6d43c6b7a..572ed7d8f 100644 --- a/source/create_synonyms_and_grants_for_public.sql +++ b/source/create_synonyms_and_grants_for_public.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql index 4ca721cf4..60b2725b5 100644 --- a/source/create_user_grants.sql +++ b/source/create_user_grants.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/create_user_synonyms.sql b/source/create_user_synonyms.sql index ee9f60fdd..7fbc5b247 100644 --- a/source/create_user_synonyms.sql +++ b/source/create_user_synonyms.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/create_utplsql_owner.sql b/source/create_utplsql_owner.sql index ee161c99c..0720a0d06 100644 --- a/source/create_utplsql_owner.sql +++ b/source/create_utplsql_owner.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,26 +21,23 @@ set feedback off set heading off set verify off -define ut3_user = &1 -define ut3_password = &2 -define ut3_tablespace = &3 +define ut3_owner_schema = &1 +define ut3_password = &2 +define ut3_tablespace = &3 -prompt Creating utPLSQL user &&ut3_user +prompt Creating utPLSQL user &&ut3_owner_schema -create user &ut3_user identified by "&ut3_password" default tablespace &ut3_tablespace quota unlimited on &ut3_tablespace; +create user &ut3_owner_schema identified by "&ut3_password" default tablespace &ut3_tablespace quota unlimited on &ut3_tablespace; -grant create session, create sequence, create procedure, create type, create table, create view, create synonym to &ut3_user; +grant create session, create sequence, create procedure, create type, create table, create view, create synonym to &ut3_owner_schema; -begin - $if dbms_db_version.version < 18 $then - execute immediate 'grant execute on dbms_lock to &ut3_user'; - $else - null; - $end -end; -/ +grant execute on dbms_lock to &ut3_owner_schema; +grant execute on dbms_crypto to &ut3_owner_schema; +grant execute on dbms_lob to &ut3_owner_schema; +grant execute on dbms_xmlgen to &ut3_owner_schema; +grant execute on dbms_sql to &ut3_owner_schema; +grant execute on dbms_random to &ut3_owner_schema; -grant execute on dbms_crypto to &ut3_user; -grant alter session to &ut3_user; +grant alter session to &ut3_owner_schema; diff --git a/source/define_ut3_owner_param.sql b/source/define_ut3_owner_param.sql index 1b183b581..27fbfe705 100644 --- a/source/define_ut3_owner_param.sql +++ b/source/define_ut3_owner_param.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/dummy.sql b/source/dummy.sql deleted file mode 100644 index 36d9f8778..000000000 --- a/source/dummy.sql +++ /dev/null @@ -1 +0,0 @@ -whenever sqlerror exit failure rollback diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index e96d716b5..cffa5fd26 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -1,9 +1,9 @@ create global temporary table ut_compound_data_diff_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 575568641..ac429e408 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_compound_data_helper is +create or replace noneditionable package body ut_compound_data_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -28,46 +28,46 @@ create or replace package body ut_compound_data_helper is with exp as ( select ucd.*, - {:duplicate_number:} dup_no + {:duplicate_number:} "UT3$_Dup#No" from ( select - ucd.item_data - ,x.data_id data_id - ,position + x.item_no item_no + ucd."UT3$_Item#Data" + ,x.data_id "UT3$_Data#Id" + ,ucd."UT3$_Position#" + x.item_no "UT3$_Item#No" {:columns:} from ut_compound_data_tmp x, xmltable('/ROWSET/ROW' passing x.item_data columns - item_data xmltype path '*' - ,position for ordinality + "UT3$_Item#Data" xmltype path '*' + ,"UT3$_Position#" for ordinality {:xml_to_columns:} ) ucd - where data_id = :exp_guid + where x.data_id = :exp_guid ) ucd ) , act as ( select ucd.*, - {:duplicate_number:} dup_no + {:duplicate_number:} "UT3$_Dup#No" from ( select - ucd.item_data - ,x.data_id data_id - ,position + x.item_no item_no + ucd."UT3$_Item#Data" + ,x.data_id "UT3$_Data#Id" + ,ucd."UT3$_Position#" + x.item_no "UT3$_Item#No" {:columns:} from ut_compound_data_tmp x, xmltable('/ROWSET/ROW' passing x.item_data columns - item_data xmltype path '*' - ,position for ordinality + "UT3$_Item#Data" xmltype path '*' + ,"UT3$_Position#" for ordinality {:xml_to_columns:} ) ucd - where data_id = :act_guid + where x.data_id = :act_guid ) ucd ) - select - a.item_data as act_item_data, - a.data_id act_data_id, - e.item_data as exp_item_data, - e.data_id exp_data_id, + select /*+ no_parallel */ + a."UT3$_Item#Data" as act_item_data, + a."UT3$_Data#Id" act_data_id, + e."UT3$_Item#Data" as exp_item_data, + e."UT3$_Data#Id" exp_data_id, {:item_no:} as item_no, - nvl(e.dup_no,a.dup_no) dup_no + nvl(e."UT3$_Dup#No",a."UT3$_Dup#No") dup_no from act a {:join_type:} exp e on ( {:join_condition:} ) where {:where_condition:}]'; @@ -103,7 +103,7 @@ create or replace package body ut_compound_data_helper is full outer join actual_cols a on e.exp_column_name = a.act_column_name ) - select case + select /*+ no_parallel */ case when exp_col_pos is null and act_col_pos is not null then '+' when exp_col_pos is not null and act_col_pos is null then '-' when exp_col_type_compare != act_col_type_compare then 't' @@ -119,8 +119,6 @@ create or replace package body ut_compound_data_helper is || case when a_order_enforced then q'[ --column position is not matching (both when excluded extra/missing columns as well as when they are included) or (a_pos_nn != e_pos_nn and exp_col_pos != act_col_pos)]' - else - null end ||q'[ order by exp_col_pos, act_col_pos]' bulk collect into l_results using a_expected, a_actual; @@ -280,7 +278,7 @@ create or replace package body ut_compound_data_helper is begin if a_data_info is not empty then for i in 1..a_data_info.count loop - if a_data_info(i).has_nested_col = 0 then + if a_data_info(i).has_nested_col = 0 and a_data_info(i).column_type <> 'OBJECT' then --Get XMLTABLE column list add_element_to_list(l_xmltab_list,generate_xmltab_stmt(a_data_info(i))); --Get Select statment list of columns @@ -302,20 +300,20 @@ create or replace package body ut_compound_data_helper is ut_utils.append_to_clob(a_partition_stmt,' row_number() over (partition by '||l_partition_tmp||' order by '||l_partition_tmp||' ) '); if a_pk_table.count > 0 then - -- If key defined do the join or these and where on diffrences - a_join_by_stmt := ut_utils.table_to_clob(l_join_by_list, ' and '); + -- If key defined do the join or these and where on diffrences as well as on duplicate number when rows are same. + a_join_by_stmt := ' e."UT3$_Dup#No" = a."UT3$_Dup#No" and '||ut_utils.table_to_clob(l_join_by_list, ' and '); elsif a_unordered then -- If no key defined do the join on all columns - a_join_by_stmt := ' e.dup_no = a.dup_no and '||ut_utils.table_to_clob(l_equal_list, ' and '); + a_join_by_stmt := ' e."UT3$_Dup#No" = a."UT3$_Dup#No" and '||ut_utils.table_to_clob(l_equal_list, ' and '); else -- Else join on rownumber - a_join_by_stmt := 'a.item_no = e.item_no '; + a_join_by_stmt := 'a."UT3$_Item#No" = e."UT3$_Item#No" '; end if; a_not_equal_stmt := ut_utils.table_to_clob(l_not_equal_list, ' or '); else --Partition by piece when no data ut_utils.append_to_clob(a_partition_stmt,' 1 '); - a_join_by_stmt := 'a.item_no = e.item_no '; + a_join_by_stmt := 'a."UT3$_Item#No" = e."UT3$_Item#No" '; end if; end; @@ -349,8 +347,8 @@ create or replace package body ut_compound_data_helper is begin return case - when a_unordered then 'row_number() over ( order by nvl(e.item_no,a.item_no))' - else 'nvl(e.item_no,a.item_no) ' + when a_unordered then 'row_number() over ( order by nvl(e."UT3$_Item#No",a."UT3$_Item#No"))' + else 'nvl(e."UT3$_Item#No",a."UT3$_Item#No") ' end; end; @@ -387,9 +385,9 @@ create or replace package body ut_compound_data_helper is end if; --If its inclusion we expect a actual set to fully match and have no extra elements over expected if a_inclusion_type then - ut_utils.append_to_clob(l_where_stmt,case when a_is_negated then ' 1 = 1 ' else ' ( a.data_id is null ) ' end); + ut_utils.append_to_clob(l_where_stmt,case when a_is_negated then ' 1 = 1 ' else ' ( a."UT3$_Data#Id" is null ) ' end); else - ut_utils.append_to_clob(l_where_stmt,' (a.data_id is null or e.data_id is null) '); + ut_utils.append_to_clob(l_where_stmt,' (a."UT3$_Data#Id" is null or e."UT3$_Data#Id" is null) '); end if; l_compare_sql := replace(l_compare_sql,'{:where_condition:}',l_where_stmt); @@ -400,8 +398,12 @@ create or replace package body ut_compound_data_helper is l_column_list ut_varchar2_list := ut_varchar2_list(); begin for i in 1..a_cursor_info.count loop - l_column_list.extend; - l_column_list(l_column_list.last) := a_cursor_info(i).access_path; + --This avoids extracting single columns from nested objects. + --as we can go down to any level but we will lose visibility of parent. + if a_cursor_info(i).hierarchy_level = 1 then + l_column_list.extend; + l_column_list(l_column_list.last) := a_cursor_info(i).access_path; + end if; end loop; return l_column_list; end; @@ -417,39 +419,78 @@ create or replace package body ut_compound_data_helper is l_join_xpath varchar2(32767) := ut_utils.to_xpath(a_join_by_list); l_results tt_row_diffs; l_sql varchar2(32767); + l_column_order varchar2(100); begin + if a_enforce_column_order then + l_column_order := 'col_no'; + else + l_column_order := 'col_name'; + end if; l_sql := q'[ - with exp as ( + with + exp_cols as ( select - exp_item_data, exp_data_id, item_no rn, rownum col_no, pk_value, + i.exp_item_data, i.exp_data_id, i.item_no rn, rownum col_no, i.diff_id, s.column_value col, s.column_value.getRootElement() col_name, - nvl(s.column_value.getclobval(),empty_clob()) col_val + nvl( s.column_value.getclobval(), empty_clob() ) col_val from ( select - exp_data_id, extract( ucd.exp_item_data, :column_path ) exp_item_data, item_no, - replace( extract( ucd.exp_item_data, :join_by ).getclobval(), chr(10) ) pk_value - from ut_compound_data_diff_tmp ucd - where diff_id = :diff_id + ucd.exp_data_id, extract( ucd.exp_item_data, :column_path ) exp_item_data, + ucd.item_no, ucd.diff_id + from ut_compound_data_diff_tmp ucd + where ucd.diff_id = :diff_id and ucd.exp_data_id = :self_guid ) i, - table( xmlsequence( extract(i.exp_item_data,:extract_path) ) ) s + table( xmlsequence( extract( i.exp_item_data, :extract_path ) ) ) s ), - act as ( + act_cols as ( select - act_item_data, act_data_id, item_no rn, rownum col_no, pk_value, + i.act_item_data, i.act_data_id, i.item_no rn, rownum col_no, i.diff_id, s.column_value col, s.column_value.getRootElement() col_name, - nvl(s.column_value.getclobval(),empty_clob()) col_val + nvl( s.column_value.getclobval(), empty_clob() ) col_val from ( select - act_data_id, extract( ucd.act_item_data, :column_path ) act_item_data, item_no, - replace( extract( ucd.act_item_data, :join_by ).getclobval(), chr(10) ) pk_value - from ut_compound_data_diff_tmp ucd - where diff_id = :diff_id + ucd.act_data_id, extract( ucd.act_item_data, :column_path ) act_item_data, + ucd.item_no, ucd.diff_id + from ut_compound_data_diff_tmp ucd + where ucd.diff_id = :diff_id and ucd.act_data_id = :other_guid ) i, - table( xmlsequence( extract(i.act_item_data,:extract_path) ) ) s + table( xmlsequence( extract( i.act_item_data, :extract_path ) ) ) s + ), + data_diff as ( + select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, null pk_value, col_name, diff_id + from ( + select nvl(exp.rn, act.rn) rn, + exp.diff_id diff_id, + xmlagg(exp.col order by exp.col_no) exp_item, + xmlagg(act.col order by nvl(exp.col_no, act.col_no)) act_item, + max(nvl(exp.col_name,act.col_name)) col_name + from exp_cols exp + join act_cols act + on exp.rn = act.rn and exp.col_name = act.col_name + where dbms_lob.compare(exp.col_val, act.col_val) != 0 + group by nvl(exp.rn, act.rn), exp.diff_id + ) + unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) + ), + unordered_diff as ( + select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, null pk_value, col_name, diff_id + from ( + select nvl(exp.rn, act.rn) rn, + exp.diff_id diff_id, + xmlagg(exp.col order by exp.col_name) exp_item, + xmlagg(act.col order by act.col_name) act_item, + max(nvl(exp.col_name,act.col_name)) col_name + from exp_cols exp + join act_cols act + on exp.rn = act.rn and exp.col_name = act.col_name + where dbms_lob.compare(exp.col_val, act.col_val) != 0 + group by nvl(exp.rn, act.rn), exp.diff_id + ) + unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ) - select rn, diff_type, diffed_row, pk_value pk_value + select /*+ no_parallel */ rn, diff_type, diffed_row, pk_value from ( select rn, diff_type, diffed_row, pk_value, case when diff_type = 'Actual:' then 1 else 2 end rnk, @@ -457,33 +498,21 @@ create or replace package body ut_compound_data_helper is col_name from ( ]' || case when a_unordered then q'[ - select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, pk_value, col_name - from ( - select nvl(exp.rn, act.rn) rn, - nvl(exp.pk_value, act.pk_value) pk_value, - exp.col exp_item, - act.col act_item, - nvl(exp.col_name,act.col_name) col_name - from exp - join act - on exp.rn = act.rn and exp.col_name = act.col_name - where dbms_lob.compare(exp.col_val, act.col_val) != 0 - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ]' + select /*+ no_unnest */ + u.rn, u.diff_type, u.diffed_row, + replace( + extract( case when i.exp_data_id is null then i.act_item_data else i.exp_item_data end, :join_by ).getclobval(), + chr(10) + ) pk_value, + u.col_name + from data_diff u + join ut_compound_data_diff_tmp i + on i.diff_id = u.diff_id + and i.item_no = u.rn]' else q'[ - select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, null pk_value, col_name - from ( - select nvl(exp.rn, act.rn) rn, - xmlagg(exp.col order by exp.col_no) exp_item, - xmlagg(act.col order by act.col_no) act_item, - max(nvl(exp.col_name,act.col_name)) col_name - from exp exp - join act act - on exp.rn = act.rn and exp.col_name = act.col_name - where dbms_lob.compare(exp.col_val, act.col_val) != 0 - group by (exp.rn, act.rn) - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ]' + select rn, diff_type, diffed_row, pk_value, col_name + from data_diff + where :join_by is null ]' end ||q'[ ) union all @@ -522,14 +551,12 @@ create or replace package body ut_compound_data_helper is case when final_order = 1 then to_char(rn) else col_name end, case when final_order = 1 then to_char(rnk) else col_name end ]' - else - null end; execute immediate l_sql bulk collect into l_results - using l_exp_extract_xpath, l_join_xpath, a_diff_id, a_expected_dataset_guid,a_extract_path, - l_act_extract_xpath, l_join_xpath, a_diff_id, a_actual_dataset_guid,a_extract_path, - l_join_xpath, l_join_xpath, a_diff_id; + using l_exp_extract_xpath, a_diff_id, a_expected_dataset_guid, a_extract_path, + l_act_extract_xpath, a_diff_id, a_actual_dataset_guid, a_extract_path, + l_join_xpath, l_join_xpath, l_join_xpath, a_diff_id; return l_results; end; @@ -541,7 +568,7 @@ create or replace package body ut_compound_data_helper is procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw) is begin forall idx in 1..a_diff_tab.count save exceptions - insert into ut_compound_data_diff_tmp + insert /*+ no_parallel */ into ut_compound_data_diff_tmp ( diff_id, act_item_data, act_data_id, exp_item_data, exp_data_id, item_no, duplicate_no ) values (a_diff_id, @@ -561,6 +588,8 @@ create or replace package body ut_compound_data_helper is procedure cleanup_diff is begin g_diff_count := 0; + delete from ut_compound_data_diff_tmp; + delete from ut_json_data_diff_tmp; end; function get_rows_diff_count return integer is @@ -614,13 +643,13 @@ create or replace package body ut_compound_data_helper is procedure save_cursor_data_for_diff(a_data_id raw, a_set_id integer, a_xml xmltype) is begin - insert into ut_compound_data_tmp (data_id, item_no, item_data) values (a_data_id, a_set_id, a_xml); + insert /*+ no_parallel */ into ut_compound_data_tmp (data_id, item_no, item_data) values (a_data_id, a_set_id, a_xml); end; function get_row_data_as_xml(a_data_id raw, a_max_rows integer) return ut_utils.t_clob_tab is l_results ut_utils.t_clob_tab; begin - select xmlserialize( content ucd.item_data no indent) + select /*+ no_parallel */ xmlserialize( content ucd.item_data no indent) bulk collect into l_results from ut_compound_data_tmp tmp ,xmltable ( '/ROWSET' passing tmp.item_data @@ -695,7 +724,7 @@ create or replace package body ut_compound_data_helper is or (a.json_type != e.json_type) or (decode(a.element_value,e.element_value,1,0) = 0) ) - select difference_type, + select /*+ no_parallel */ difference_type, act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path, exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path bulk collect into l_result_diff @@ -717,7 +746,7 @@ create or replace package body ut_compound_data_helper is l_diffs tt_json_diff_tab := compare_json_data(a_act_json_data,a_exp_json_data); begin forall i in 1..l_diffs.count - insert into ut_json_data_diff_tmp ( + insert /*+ no_parallel */ into ut_json_data_diff_tmp ( diff_id, difference_type, act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path, exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path @@ -734,7 +763,7 @@ create or replace package body ut_compound_data_helper is function get_json_diffs_type(a_diff_id raw) return tt_json_diff_type_tab is l_diffs_summary tt_json_diff_type_tab := tt_json_diff_type_tab(); begin - select d.difference_type,count(1) + select /*+ no_parallel */ d.difference_type,count(1) bulk collect into l_diffs_summary from ut_json_data_diff_tmp d where diff_id = a_diff_id @@ -746,7 +775,7 @@ create or replace package body ut_compound_data_helper is function get_json_diffs_tmp(a_diff_id raw) return tt_json_diff_tab is l_diffs tt_json_diff_tab; begin - select difference_type, + select /*+ no_parallel */ difference_type, act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path, exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path bulk collect into l_diffs @@ -756,6 +785,15 @@ create or replace package body ut_compound_data_helper is return l_diffs; end; + function get_json_object(a_json_t json) return json_element_t is + l_obj json_element_t; + begin + $if dbms_db_version.version >= 21 $then + l_obj := case when a_json_t is null then cast (null as json_element_t ) else json_element_t.parse(json_query(a_json_t, '$' returning clob)) end; + $end + return l_obj; + end; + begin g_anytype_name_map(dbms_types.typecode_date) := 'DATE'; g_anytype_name_map(dbms_types.typecode_number) := 'NUMBER'; diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index b39df0039..3c13c85e8 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_compound_data_helper authid definer is +create or replace noneditionable package ut_compound_data_helper authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -134,5 +134,7 @@ create or replace package ut_compound_data_helper authid definer is function get_json_diffs_type(a_diff_id raw) return tt_json_diff_type_tab; + function get_json_object(a_json_t json) return json_element_t; + end; / diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index c860a1872..902bf29fc 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -1,9 +1,9 @@ create global temporary table ut_compound_data_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Copyright 2016 - 2026 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 627e14680..27c19455b 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_compound_data_value as +create or replace noneditionable type body ut_compound_data_value as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_compound_data_value.tps b/source/expectations/data_values/ut_compound_data_value.tps index 027b5ca26..6272e04a7 100644 --- a/source/expectations/data_values/ut_compound_data_value.tps +++ b/source/expectations/data_values/ut_compound_data_value.tps @@ -1,10 +1,10 @@ -create or replace type ut_compound_data_value force under ut_data_value( +create or replace noneditionable type ut_compound_data_value force under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_cursor_column.tpb b/source/expectations/data_values/ut_cursor_column.tpb index 13b1b3158..01ec72f41 100644 --- a/source/expectations/data_values/ut_cursor_column.tpb +++ b/source/expectations/data_values/ut_cursor_column.tpb @@ -1,5 +1,21 @@ -create or replace type body ut_cursor_column as - +create or replace noneditionable type body ut_cursor_column as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + member procedure init( self in out nocopy ut_cursor_column, a_col_name varchar2, a_col_schema_name varchar2, @@ -14,8 +30,11 @@ create or replace type body ut_cursor_column as self.column_len := a_col_max_len; --length of column self.column_precision := a_col_precision; self.column_scale := a_col_scale; - self.column_name := TRIM( BOTH '''' FROM a_col_name); --name of the column self.column_type_name := coalesce(a_col_type_name,a_col_type); --type name e.g. test_dummy_object or varchar2 + self.column_name := case when a_col_name is null and a_collection = 1 then + self.column_type_name + else TRIM( BOTH '''' FROM a_col_name) + end; --name of the column, however in nested object for collection name is not defined in cursor. self.xml_valid_name := ut_utils.get_valid_xml_name(self.column_name); self.display_path := case when a_access_path is null then self.column_name @@ -25,23 +44,25 @@ create or replace type body ut_cursor_column as self.access_path := case when a_access_path is null then self.xml_valid_name else - a_access_path||'/'||self.xml_valid_name + a_access_path||'/'||self.xml_valid_name end; --Access path used for XMLTABLE query self.filter_path := '/'||self.access_path; --Filter path will differ from access path in anydata type - self.transformed_name := case when length(self.xml_valid_name) > 30 then - '"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"' - when self.parent_name is null then + --Transformed name is used as a column alias in generated SQL. + --Nested columns and names longer than the maximum identifier length are replaced by a hash of the full access path, + -- to avoid ambiguity when there is 3 or more levels of nesting. + self.transformed_name := case when self.parent_name is null and lengthb(self.xml_valid_name) <= ora_max_name_len_supported then '"'||self.xml_valid_name||'"' - else - '"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"' - end; --when is nestd we need to hash name to make sure we dont exceed 30 char + else + '"'||ut_compound_data_helper.get_fixed_size_hash(self.access_path)||'"' + end; self.column_type := a_col_type; --column type e.g. user_defined , varchar2 self.column_schema := a_col_schema_name; -- schema name self.is_sql_diffable := case when lower(self.column_type) = 'user_defined_type' then 0 - -- Due to bug in 11g/12.1 collection fails on varchar 4000+ - when (lower(self.column_type) in ('varchar2','char')) and (self.column_len > 4000) then + -- Columns can be described as longer than SQL varchar2 allows (e.g. a dynamic bind over 4000 chars), + -- XMLTABLE rejects such a length (ORA-00910), so these values are compared by hash. + when (lower(self.column_type) in ('varchar2','char')) and (self.column_len > ut_utils.gc_max_storage_varchar2_len) then 0 else ut_utils.boolean_to_int(ut_compound_data_helper.is_sql_compare_allowed(self.column_type)) diff --git a/source/expectations/data_values/ut_cursor_column.tps b/source/expectations/data_values/ut_cursor_column.tps index c865ea64b..45c14c154 100644 --- a/source/expectations/data_values/ut_cursor_column.tps +++ b/source/expectations/data_values/ut_cursor_column.tps @@ -1,10 +1,10 @@ -create or replace type ut_cursor_column authid current_user as object ( +create or replace noneditionable type ut_cursor_column authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_cursor_column_tab.tps b/source/expectations/data_values/ut_cursor_column_tab.tps index b1b33f7fe..6dfe98824 100644 --- a/source/expectations/data_values/ut_cursor_column_tab.tps +++ b/source/expectations/data_values/ut_cursor_column_tab.tps @@ -1,10 +1,10 @@ -create or replace type ut_cursor_column_tab as +create or replace noneditionable type ut_cursor_column_tab as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_cursor_details.tpb b/source/expectations/data_values/ut_cursor_details.tpb index 20313ed96..bfbe435e5 100644 --- a/source/expectations/data_values/ut_cursor_details.tpb +++ b/source/expectations/data_values/ut_cursor_details.tpb @@ -1,9 +1,26 @@ -create or replace type body ut_cursor_details as +create or replace noneditionable type body ut_cursor_details as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + member function equals( a_other ut_cursor_details, a_match_options ut_matcher_options ) return boolean is l_diffs integer; begin - select count(1) into l_diffs + select /*+ no_parallel */ count(1) into l_diffs from table(self.cursor_columns_info) a full outer join table(a_other.cursor_columns_info) e on decode(a.parent_name,e.parent_name,1,0)= 1 @@ -91,7 +108,7 @@ create or replace type body ut_cursor_details as a_cursor_number in number ) return self as result is l_columns_count pls_integer; - l_columns_desc dbms_sql.desc_tab3; + l_columns_desc dbms_sql.desc_tab4; l_is_collection boolean; l_hierarchy_level integer := 1; begin @@ -139,7 +156,7 @@ create or replace type body ut_cursor_details as member function contains_collection return boolean is l_collection_elements number; begin - select count(1) into l_collection_elements + select /*+ no_parallel */ count(1) into l_collection_elements from table(cursor_columns_info) c where c.is_collection = 1 and rownum = 1; return l_collection_elements > 0; @@ -149,7 +166,7 @@ create or replace type body ut_cursor_details as l_result ut_varchar2_list; begin --regexp_replace(c.access_path,'^\/?([^\/]+\/){1}') - select fl.column_value + select /*+ no_parallel */ fl.column_value bulk collect into l_result from table(a_expected_columns) fl where not exists ( @@ -179,7 +196,7 @@ create or replace type body ut_cursor_details as select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names from table(a_match_options.exclude.items) ) - select value(x) + select /*+ no_parallel */ value(x) bulk collect into l_result.cursor_columns_info from table(self.cursor_columns_info) x where exists( @@ -192,7 +209,7 @@ create or replace type body ut_cursor_details as select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names from table(a_match_options.exclude.items) ) - select value(x) + select /*+ no_parallel */ value(x) bulk collect into l_result.cursor_columns_info from table(self.cursor_columns_info) x where not exists( @@ -202,7 +219,7 @@ create or replace type body ut_cursor_details as --Rewrite column order after columns been excluded for i in ( - select parent_name, access_path, display_path, has_nested_col, + select /*+ no_parallel */ parent_name, access_path, display_path, has_nested_col, transformed_name, hierarchy_level, rownum as new_position, xml_valid_name, column_name, column_type, column_type_name, column_schema, @@ -224,7 +241,7 @@ create or replace type body ut_cursor_details as member function get_xml_children(a_parent_name varchar2 := null) return xmltype is l_result xmltype; begin - select xmlagg(xmlelement(evalname t.column_name,t.column_type_name)) + select /*+ no_parallel */ xmlagg(xmlelement(evalname t.column_name,t.column_type_name)) into l_result from table(self.cursor_columns_info) t where (a_parent_name is null and parent_name is null and hierarchy_level = 1 and column_name is not null) @@ -236,7 +253,7 @@ create or replace type body ut_cursor_details as l_root varchar2(250); begin if self.cursor_columns_info.count > 0 then - select x.access_path into l_root from table(self.cursor_columns_info) x + select /*+ no_parallel */ x.access_path into l_root from table(self.cursor_columns_info) x where x.hierarchy_level = 1; else l_root := null; diff --git a/source/expectations/data_values/ut_cursor_details.tps b/source/expectations/data_values/ut_cursor_details.tps index 7092e834f..19f5b3f39 100644 --- a/source/expectations/data_values/ut_cursor_details.tps +++ b/source/expectations/data_values/ut_cursor_details.tps @@ -1,10 +1,10 @@ -create or replace type ut_cursor_details authid current_user as object ( +create or replace noneditionable type ut_cursor_details authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value.tpb b/source/expectations/data_values/ut_data_value.tpb index a644fe30e..a94e88660 100644 --- a/source/expectations/data_values/ut_data_value.tpb +++ b/source/expectations/data_values/ut_data_value.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value as +create or replace noneditionable type body ut_data_value as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value.tps b/source/expectations/data_values/ut_data_value.tps index ca7e18308..d5f00489e 100644 --- a/source/expectations/data_values/ut_data_value.tps +++ b/source/expectations/data_values/ut_data_value.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value force authid current_user as object ( +create or replace noneditionable type ut_data_value force authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,6 +16,7 @@ create or replace type ut_data_value force authid current_user as object ( limitations under the License. */ data_type varchar2(250 char), + data_type_plsql varchar2(250 char), self_type varchar2(250 char), not instantiable member function is_null return boolean, not instantiable member function to_string return varchar2, diff --git a/source/expectations/data_values/ut_data_value_anydata.tpb b/source/expectations/data_values/ut_data_value_anydata.tpb index a81b0f5c7..6794beaa9 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tpb +++ b/source/expectations/data_values/ut_data_value_anydata.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_anydata as +create or replace noneditionable type body ut_data_value_anydata as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -48,11 +48,11 @@ create or replace type body ut_data_value_anydata as begin l_status := l_value.get'||self.compound_type||'(l_data); '|| case when self.compound_type = 'collection' then - q'[ open :l_tmp_refcursor for select value(x) as "]'|| + q'[ open :l_tmp_refcursor for select /*+ no_parallel */ value(x) as "]'|| ut_metadata.get_object_name(ut_metadata.get_collection_element(a_data_value))|| q'[" from table(l_data) x;]' else - q'[ open :l_tmp_refcursor for select l_data as "]'||ut_metadata.get_object_name(self.data_type)|| + q'[ open :l_tmp_refcursor for select /*+ no_parallel */ l_data as "]'||ut_metadata.get_object_name(self.data_type)|| q'[" from dual;]' end || 'end;'; diff --git a/source/expectations/data_values/ut_data_value_anydata.tps b/source/expectations/data_values/ut_data_value_anydata.tps index 5ed0406ca..3c56ce178 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tps +++ b/source/expectations/data_values/ut_data_value_anydata.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_anydata under ut_data_value_refcursor( +create or replace noneditionable type ut_data_value_anydata under ut_data_value_refcursor( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_blob.tpb b/source/expectations/data_values/ut_data_value_blob.tpb index 11af6d2f7..bf52d4056 100644 --- a/source/expectations/data_values/ut_data_value_blob.tpb +++ b/source/expectations/data_values/ut_data_value_blob.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_blob as +create or replace noneditionable type body ut_data_value_blob as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,6 +21,7 @@ create or replace type body ut_data_value_blob as self.data_value := a_value; self.self_type := $$plsql_unit; self.data_type := 'blob'; + self.data_type_plsql := 'blob'; return; end; diff --git a/source/expectations/data_values/ut_data_value_blob.tps b/source/expectations/data_values/ut_data_value_blob.tps index f557ffbce..5c93a5fac 100644 --- a/source/expectations/data_values/ut_data_value_blob.tps +++ b/source/expectations/data_values/ut_data_value_blob.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_blob under ut_data_value( +create or replace noneditionable type ut_data_value_blob under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_boolean.tpb b/source/expectations/data_values/ut_data_value_boolean.tpb index 0645d3269..5a499afb6 100644 --- a/source/expectations/data_values/ut_data_value_boolean.tpb +++ b/source/expectations/data_values/ut_data_value_boolean.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_boolean as +create or replace noneditionable type body ut_data_value_boolean as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,6 +21,7 @@ create or replace type body ut_data_value_boolean as self.data_value := ut_utils.boolean_to_int(a_value); self.self_type := $$plsql_unit; self.data_type := 'boolean'; + self.data_type_plsql := 'boolean'; return; end; diff --git a/source/expectations/data_values/ut_data_value_boolean.tps b/source/expectations/data_values/ut_data_value_boolean.tps index a254e05c0..35c05b384 100644 --- a/source/expectations/data_values/ut_data_value_boolean.tps +++ b/source/expectations/data_values/ut_data_value_boolean.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_boolean under ut_data_value( +create or replace noneditionable type ut_data_value_boolean under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_clob.tpb b/source/expectations/data_values/ut_data_value_clob.tpb index dacb390b6..6d5a9764d 100644 --- a/source/expectations/data_values/ut_data_value_clob.tpb +++ b/source/expectations/data_values/ut_data_value_clob.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_clob as +create or replace noneditionable type body ut_data_value_clob as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,6 +21,7 @@ create or replace type body ut_data_value_clob as self.data_value := a_value; self.self_type := $$plsql_unit; self.data_type := 'clob'; + self.data_type_plsql := 'clob'; return; end; diff --git a/source/expectations/data_values/ut_data_value_clob.tps b/source/expectations/data_values/ut_data_value_clob.tps index 1ff5d5623..8027e4481 100644 --- a/source/expectations/data_values/ut_data_value_clob.tps +++ b/source/expectations/data_values/ut_data_value_clob.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_clob under ut_data_value( +create or replace noneditionable type ut_data_value_clob under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_date.tpb b/source/expectations/data_values/ut_data_value_date.tpb index dd87156bc..f6a588940 100644 --- a/source/expectations/data_values/ut_data_value_date.tpb +++ b/source/expectations/data_values/ut_data_value_date.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_date as +create or replace noneditionable type body ut_data_value_date as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,6 +21,7 @@ create or replace type body ut_data_value_date as self.data_value := a_value; self.self_type := $$plsql_unit; self.data_type := 'date'; + self.data_type_plsql := 'date'; return; end; diff --git a/source/expectations/data_values/ut_data_value_date.tps b/source/expectations/data_values/ut_data_value_date.tps index 4435a3512..7e3379f31 100644 --- a/source/expectations/data_values/ut_data_value_date.tps +++ b/source/expectations/data_values/ut_data_value_date.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_date under ut_data_value( +create or replace noneditionable type ut_data_value_date under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tpb b/source/expectations/data_values/ut_data_value_dsinterval.tpb index ff9d5fe1e..a01766425 100644 --- a/source/expectations/data_values/ut_data_value_dsinterval.tpb +++ b/source/expectations/data_values/ut_data_value_dsinterval.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_dsinterval as +create or replace noneditionable type body ut_data_value_dsinterval as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,6 +21,7 @@ create or replace type body ut_data_value_dsinterval as self.data_value := a_value; self.self_type := $$plsql_unit; self.data_type := 'interval day to second'; + self.data_type_plsql := 'dsinterval_unconstrained'; return; end; @@ -31,7 +32,7 @@ create or replace type body ut_data_value_dsinterval as overriding member function to_string return varchar2 is begin - return ut_utils.to_string(self.data_value); + return ut_utils.interval_to_text(self.data_value); end; overriding member function compare_implementation(a_other ut_data_value) return integer is diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tps b/source/expectations/data_values/ut_data_value_dsinterval.tps index 114619bf2..9fc81bb6a 100644 --- a/source/expectations/data_values/ut_data_value_dsinterval.tps +++ b/source/expectations/data_values/ut_data_value_dsinterval.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_dsinterval under ut_data_value( +create or replace noneditionable type ut_data_value_dsinterval under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,7 +15,7 @@ create or replace type ut_data_value_dsinterval under ut_data_value( See the License for the specific language governing permissions and limitations under the License. */ - data_value dsinterval_unconstrained, + data_value interval day(9) to second(9), constructor function ut_data_value_dsinterval(self in out nocopy ut_data_value_dsinterval, a_value dsinterval_unconstrained) return self as result, overriding member function is_null return boolean, overriding member function to_string return varchar2, diff --git a/source/expectations/data_values/ut_data_value_json.tpb b/source/expectations/data_values/ut_data_value_json.tpb index 83916c30e..da4f3ac79 100644 --- a/source/expectations/data_values/ut_data_value_json.tpb +++ b/source/expectations/data_values/ut_data_value_json.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_json as +create or replace noneditionable type body ut_data_value_json as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -32,6 +32,13 @@ create or replace type body ut_data_value_json as return; end; + constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json) return self as result is + l_value json_element_t := ut_compound_data_helper.get_json_object(a_value); + begin + init(l_value); + return; + end; + overriding member function is_null return boolean is begin return (ut_utils.int_to_boolean(self.is_data_null)); @@ -140,7 +147,7 @@ create or replace type body ut_data_value_json as l_result := case when ut_compound_data_helper.insert_json_diffs( - l_diff_id, self.json_tree.json_tree_info, l_other.json_tree.json_tree_info + l_diff_id, l_other.json_tree.json_tree_info, self.json_tree.json_tree_info ) > 0 then 1 else 0 end; diff --git a/source/expectations/data_values/ut_data_value_json.tps b/source/expectations/data_values/ut_data_value_json.tps index bfaccb2e2..e8778051b 100644 --- a/source/expectations/data_values/ut_data_value_json.tps +++ b/source/expectations/data_values/ut_data_value_json.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_json under ut_compound_data_value( +create or replace noneditionable type ut_data_value_json under ut_compound_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -19,6 +19,7 @@ create or replace type ut_data_value_json under ut_compound_data_value( json_tree ut_json_tree_details, member procedure init (self in out nocopy ut_data_value_json, a_value json_element_t), constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json_element_t) return self as result, + constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json) return self as result, overriding member function is_null return boolean, overriding member function is_empty return boolean, overriding member function to_string return varchar2, diff --git a/source/expectations/data_values/ut_data_value_number.tpb b/source/expectations/data_values/ut_data_value_number.tpb index b8a28a124..da17e51c9 100644 --- a/source/expectations/data_values/ut_data_value_number.tpb +++ b/source/expectations/data_values/ut_data_value_number.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_number as +create or replace noneditionable type body ut_data_value_number as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,6 +21,7 @@ create or replace type body ut_data_value_number as self.data_value := a_value; self.self_type := $$plsql_unit; self.data_type := 'number'; + self.data_type_plsql := 'number'; return; end; diff --git a/source/expectations/data_values/ut_data_value_number.tps b/source/expectations/data_values/ut_data_value_number.tps index 872ab405e..8bd590515 100644 --- a/source/expectations/data_values/ut_data_value_number.tps +++ b/source/expectations/data_values/ut_data_value_number.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_number under ut_data_value( +create or replace noneditionable type ut_data_value_number under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 801b35802..af6d1791b 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_refcursor as +create or replace noneditionable type body ut_data_value_refcursor as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -51,12 +51,8 @@ create or replace type body ut_data_value_refcursor as loop l_xml := dbms_xmlgen.getxmltype(l_ctx); exit when dbms_xmlgen.getNumRowsProcessed(l_ctx) = 0; - --Bug in oracle 12.2+ where XML binary storage trimming insignificant whitespaces. - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_xml := xmltype( replace(l_xml.getClobVal(),'= 2 or dbms_db_version.version > 12 $then - dbms_output.put_line('Object exists , dont install'); - $else - dbms_output.put_line('Installing json structures specs.'); - execute immediate q'[create or replace TYPE JSON_Element_T FORCE AUTHID CURRENT_USER AS OBJECT( - dummyobjt NUMBER, - STATIC FUNCTION parse(jsn VARCHAR2) RETURN JSON_Element_T, - STATIC FUNCTION parse(jsn CLOB) RETURN JSON_Element_T, - STATIC FUNCTION parse(jsn BLOB) RETURN JSON_Element_T, - MEMBER FUNCTION to_Clob RETURN CLOB, - MEMBER FUNCTION stringify RETURN VARCHAR2, - MEMBER FUNCTION is_Object RETURN BOOLEAN, - MEMBER FUNCTION is_Array RETURN BOOLEAN, - MEMBER FUNCTION is_Scalar RETURN BOOLEAN, - MEMBER FUNCTION is_String RETURN BOOLEAN, - MEMBER FUNCTION is_Number RETURN BOOLEAN, - MEMBER FUNCTION is_Boolean RETURN BOOLEAN, - MEMBER FUNCTION is_True RETURN BOOLEAN, - MEMBER FUNCTION is_False RETURN BOOLEAN, - MEMBER FUNCTION is_Null RETURN BOOLEAN, - MEMBER FUNCTION is_Date RETURN BOOLEAN, - MEMBER FUNCTION is_Timestamp RETURN BOOLEAN, - MEMBER FUNCTION to_string RETURN VARCHAR2, - MEMBER FUNCTION to_number RETURN NUMBER, - MEMBER FUNCTION to_boolean RETURN BOOLEAN, - MEMBER FUNCTION to_date RETURN VARCHAR2, - - MEMBER FUNCTION get_Size(self IN JSON_ELEMENT_T) RETURN NUMBER -) NOT FINAL NOT INSTANTIABLE;]'; - - execute immediate q'[create or replace TYPE JSON_KEY_LIST FORCE AS VARRAY(32767) OF VARCHAR2(4000);]'; - - execute immediate q'[create or replace TYPE JSON_Array_T FORCE AUTHID CURRENT_USER UNDER JSON_Element_T( - CONSTRUCTOR FUNCTION JSON_Array_T RETURN SELF AS RESULT, - MEMBER FUNCTION get(pos NUMBER) RETURN JSON_Element_T, - MEMBER FUNCTION get_String(pos NUMBER) RETURN VARCHAR2, - MEMBER FUNCTION get_Number(pos NUMBER) RETURN NUMBER, - MEMBER FUNCTION get_Boolean(pos NUMBER) RETURN BOOLEAN, - MEMBER FUNCTION get_Date(pos NUMBER) RETURN DATE, - MEMBER FUNCTION get_Timestamp(pos NUMBER) RETURN TIMESTAMP, - MEMBER FUNCTION get_Clob(pos NUMBER) RETURN CLOB, - MEMBER PROCEDURE get_Clob(pos NUMBER, c IN OUT NOCOPY CLOB), - MEMBER FUNCTION get_Blob(pos NUMBER) RETURN BLOB, - MEMBER PROCEDURE get_Blob(pos NUMBER, b IN OUT NOCOPY BLOB), - MEMBER FUNCTION get_Type(pos NUMBER) RETURN VARCHAR2 -) FINAL;]'; - - execute immediate q'[create or replace TYPE JSON_Object_T AUTHID CURRENT_USER UNDER JSON_Element_T( - CONSTRUCTOR FUNCTION JSON_Object_T RETURN SELF AS RESULT, - MEMBER FUNCTION get(key VARCHAR2) RETURN JSON_Element_T, - MEMBER FUNCTION get_Object(key VARCHAR2) RETURN JSON_OBJECT_T, - MEMBER FUNCTION get_Array(key VARCHAR2) RETURN JSON_ARRAY_T, - MEMBER FUNCTION get_String(key VARCHAR2) RETURN VARCHAR2, - MEMBER FUNCTION get_Number(key VARCHAR2) RETURN NUMBER, - MEMBER FUNCTION get_Boolean(key VARCHAR2) RETURN BOOLEAN, - MEMBER FUNCTION get_Date(key VARCHAR2) RETURN DATE, - MEMBER FUNCTION get_Timestamp(key VARCHAR2) RETURN TIMESTAMP, - MEMBER FUNCTION get_Clob(key VARCHAR2) RETURN CLOB, - MEMBER PROCEDURE get_Clob(key VARCHAR2, c IN OUT NOCOPY CLOB), - MEMBER FUNCTION get_Blob(key VARCHAR2) RETURN BLOB, - MEMBER PROCEDURE get_Blob(key VARCHAR2, b IN OUT NOCOPY BLOB), - MEMBER FUNCTION get_Type(key VARCHAR2) RETURN VARCHAR2, - MEMBER FUNCTION get_Keys RETURN JSON_KEY_LIST -) FINAL;]'; + null; + $if dbms_db_version.version < 21 $then + dbms_output.put_line('Installing json structures specs for native json.'); + execute immediate q'[create or replace noneditionable TYPE JSON FORCE AUTHID CURRENT_USER AS OBJECT( + dummyobjt NUMBER +) NOT FINAL NOT INSTANTIABLE;]'; $end END; diff --git a/source/expectations/matchers/ut_be_between.tpb b/source/expectations/matchers/ut_be_between.tpb index 7368ad5a7..83511755c 100644 --- a/source/expectations/matchers/ut_be_between.tpb +++ b/source/expectations/matchers/ut_be_between.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_between is +create or replace noneditionable type body ut_be_between is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_between.tps b/source/expectations/matchers/ut_be_between.tps index 7e254719e..e8f5f0d8e 100644 --- a/source/expectations/matchers/ut_be_between.tps +++ b/source/expectations/matchers/ut_be_between.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_between under ut_matcher( +create or replace noneditionable type ut_be_between under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_empty.tpb b/source/expectations/matchers/ut_be_empty.tpb index 08523fb02..7f7a4190e 100644 --- a/source/expectations/matchers/ut_be_empty.tpb +++ b/source/expectations/matchers/ut_be_empty.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_empty as +create or replace noneditionable type body ut_be_empty as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_empty.tps b/source/expectations/matchers/ut_be_empty.tps index 76af402fe..833b8b10f 100644 --- a/source/expectations/matchers/ut_be_empty.tps +++ b/source/expectations/matchers/ut_be_empty.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_empty under ut_matcher( +create or replace noneditionable type ut_be_empty under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_false.tpb b/source/expectations/matchers/ut_be_false.tpb index 671f43cbe..1256972bb 100644 --- a/source/expectations/matchers/ut_be_false.tpb +++ b/source/expectations/matchers/ut_be_false.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_false as +create or replace noneditionable type body ut_be_false as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_false.tps b/source/expectations/matchers/ut_be_false.tps index 3d4e8dda9..5c4401555 100644 --- a/source/expectations/matchers/ut_be_false.tps +++ b/source/expectations/matchers/ut_be_false.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_false under ut_matcher( +create or replace noneditionable type ut_be_false under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_greater_or_equal.tpb b/source/expectations/matchers/ut_be_greater_or_equal.tpb index 6877eb32c..c7c13c8c3 100644 --- a/source/expectations/matchers/ut_be_greater_or_equal.tpb +++ b/source/expectations/matchers/ut_be_greater_or_equal.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_greater_or_equal AS +create or replace noneditionable type body ut_be_greater_or_equal AS /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_greater_or_equal.tps b/source/expectations/matchers/ut_be_greater_or_equal.tps index facd33b3d..e0d28ae6c 100644 --- a/source/expectations/matchers/ut_be_greater_or_equal.tps +++ b/source/expectations/matchers/ut_be_greater_or_equal.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_greater_or_equal under ut_comparison_matcher( +create or replace noneditionable type ut_be_greater_or_equal under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_greater_than.tpb b/source/expectations/matchers/ut_be_greater_than.tpb index da46347af..60d6f319a 100644 --- a/source/expectations/matchers/ut_be_greater_than.tpb +++ b/source/expectations/matchers/ut_be_greater_than.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_greater_than AS +create or replace noneditionable type body ut_be_greater_than AS /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_greater_than.tps b/source/expectations/matchers/ut_be_greater_than.tps index fa19a9bd4..659274fb5 100644 --- a/source/expectations/matchers/ut_be_greater_than.tps +++ b/source/expectations/matchers/ut_be_greater_than.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_greater_than under ut_comparison_matcher( +create or replace noneditionable type ut_be_greater_than under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_less_or_equal.tpb b/source/expectations/matchers/ut_be_less_or_equal.tpb index 98c4238eb..82e011024 100644 --- a/source/expectations/matchers/ut_be_less_or_equal.tpb +++ b/source/expectations/matchers/ut_be_less_or_equal.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_less_or_equal AS +create or replace noneditionable type body ut_be_less_or_equal AS /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_less_or_equal.tps b/source/expectations/matchers/ut_be_less_or_equal.tps index 225c99b72..ab058bd93 100644 --- a/source/expectations/matchers/ut_be_less_or_equal.tps +++ b/source/expectations/matchers/ut_be_less_or_equal.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_less_or_equal under ut_comparison_matcher( +create or replace noneditionable type ut_be_less_or_equal under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_less_than.tpb b/source/expectations/matchers/ut_be_less_than.tpb index e1c5c84b1..9017c839f 100644 --- a/source/expectations/matchers/ut_be_less_than.tpb +++ b/source/expectations/matchers/ut_be_less_than.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_less_than as +create or replace noneditionable type body ut_be_less_than as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_less_than.tps b/source/expectations/matchers/ut_be_less_than.tps index 8482f0327..6b9d78f44 100644 --- a/source/expectations/matchers/ut_be_less_than.tps +++ b/source/expectations/matchers/ut_be_less_than.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_less_than under ut_comparison_matcher( +create or replace noneditionable type ut_be_less_than under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_like.tpb b/source/expectations/matchers/ut_be_like.tpb index dbcd1c798..841765290 100644 --- a/source/expectations/matchers/ut_be_like.tpb +++ b/source/expectations/matchers/ut_be_like.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_like as +create or replace noneditionable type body ut_be_like as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_like.tps b/source/expectations/matchers/ut_be_like.tps index 0c1609a98..6d7db0705 100644 --- a/source/expectations/matchers/ut_be_like.tps +++ b/source/expectations/matchers/ut_be_like.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_like under ut_matcher( +create or replace noneditionable type ut_be_like under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_not_null.tpb b/source/expectations/matchers/ut_be_not_null.tpb index 94ee0ce0a..6c40ed608 100644 --- a/source/expectations/matchers/ut_be_not_null.tpb +++ b/source/expectations/matchers/ut_be_not_null.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_not_null as +create or replace noneditionable type body ut_be_not_null as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_not_null.tps b/source/expectations/matchers/ut_be_not_null.tps index 34cc2bfd0..5688cab2b 100644 --- a/source/expectations/matchers/ut_be_not_null.tps +++ b/source/expectations/matchers/ut_be_not_null.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_not_null under ut_matcher( +create or replace noneditionable type ut_be_not_null under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_null.tpb b/source/expectations/matchers/ut_be_null.tpb index 3194f092f..629990d01 100644 --- a/source/expectations/matchers/ut_be_null.tpb +++ b/source/expectations/matchers/ut_be_null.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_null as +create or replace noneditionable type body ut_be_null as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_null.tps b/source/expectations/matchers/ut_be_null.tps index 486e11f28..bee488427 100644 --- a/source/expectations/matchers/ut_be_null.tps +++ b/source/expectations/matchers/ut_be_null.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_null under ut_matcher( +create or replace noneditionable type ut_be_null under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_true.tpb b/source/expectations/matchers/ut_be_true.tpb index 565ab590b..2cb161a44 100644 --- a/source/expectations/matchers/ut_be_true.tpb +++ b/source/expectations/matchers/ut_be_true.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_be_true as +create or replace noneditionable type body ut_be_true as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_true.tps b/source/expectations/matchers/ut_be_true.tps index b994913f5..35bf71011 100644 --- a/source/expectations/matchers/ut_be_true.tps +++ b/source/expectations/matchers/ut_be_true.tps @@ -1,10 +1,10 @@ -create or replace type ut_be_true under ut_matcher( +create or replace noneditionable type ut_be_true under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_be_within.tpb b/source/expectations/matchers/ut_be_within.tpb new file mode 100644 index 000000000..f34570673 --- /dev/null +++ b/source/expectations/matchers/ut_be_within.tpb @@ -0,0 +1,137 @@ +create or replace noneditionable type body ut_be_within as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected number) return self as result is + begin + self.init(ut_data_value_number(a_distance_from_expected), $$plsql_unit); + return; + end; + + constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained) return self as result is + begin + self.init(ut_data_value_dsinterval(a_distance_from_expected), $$plsql_unit); + return; + end; + + constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained) return self as result is + begin + self.init(ut_data_value_yminterval(a_distance_from_expected), $$plsql_unit); + return; + end; + + member procedure of_(self in ut_be_within, a_expected date) is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_date(a_expected); + if l_result.is_negated_flag = 1 then + l_result.expectation.not_to(l_result); + else + l_result.expectation.to_(l_result); + end if; + end; + + member function of_(self in ut_be_within, a_expected date) return ut_be_within is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_date(a_expected); + return l_result; + end; + + member procedure of_(self in ut_be_within, a_expected timestamp_unconstrained) is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_timestamp(a_expected); + if l_result.is_negated_flag = 1 then + l_result.expectation.not_to(l_result); + else + l_result.expectation.to_(l_result); + end if; + end; + + member function of_(self in ut_be_within, a_expected timestamp_unconstrained) return ut_be_within is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_timestamp(a_expected); + return l_result; + end; + + member procedure of_(self in ut_be_within, a_expected timestamp_tz_unconstrained) is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_timestamp_tz(a_expected); + if l_result.is_negated_flag = 1 then + l_result.expectation.not_to(l_result); + else + l_result.expectation.to_(l_result); + end if; + end; + + member function of_(self in ut_be_within, a_expected timestamp_tz_unconstrained) return ut_be_within is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_timestamp_tz(a_expected); + return l_result; + end; + + member procedure of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained) is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_timestamp_ltz(a_expected); + if l_result.is_negated_flag = 1 then + l_result.expectation.not_to(l_result); + else + l_result.expectation.to_(l_result); + end if; + end; + + member function of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained) return ut_be_within is + l_result ut_be_within := self; + begin + l_result.expected := ut_data_value_timestamp_ltz(a_expected); + return l_result; + end; + + overriding member function run_matcher(self in out nocopy ut_be_within, a_actual ut_data_value) return boolean is + l_result boolean; + begin + if self.expected.data_type = a_actual.data_type + and ( + self.expected is of (ut_data_value_date, ut_data_value_timestamp, ut_data_value_timestamp_tz, ut_data_value_timestamp_ltz) + and self.distance_from_expected is of (ut_data_value_yminterval, ut_data_value_dsinterval) + or self.expected is of (ut_data_value_number) and self.distance_from_expected is of (ut_data_value_number) + ) + then + l_result := ut_be_within_helper.values_within_abs_distance( a_actual, self.expected, self.distance_from_expected) ; + else + l_result := (self as ut_matcher).run_matcher(a_actual); + end if; + return l_result; + end; + + overriding member function failure_message(a_actual ut_data_value) return varchar2 is + begin + return (self as ut_matcher).failure_message(a_actual) || ' '||self.distance_from_expected.to_string ||' of '|| expected.to_string_report(); + end; + + overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is + begin + return (self as ut_matcher).failure_message_when_negated(a_actual) || ' '||self.distance_from_expected.to_string ||' of '|| expected.to_string_report(); + end; + +end; +/ diff --git a/source/expectations/matchers/ut_be_within.tps b/source/expectations/matchers/ut_be_within.tps new file mode 100644 index 000000000..1cef0398c --- /dev/null +++ b/source/expectations/matchers/ut_be_within.tps @@ -0,0 +1,36 @@ +create or replace noneditionable type ut_be_within force under ut_be_within_pct( + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + + constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected number) return self as result, + constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained) return self as result, + constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained) return self as result, + member procedure of_(self in ut_be_within, a_expected date), + member function of_(self in ut_be_within, a_expected date) return ut_be_within, + member procedure of_(self in ut_be_within, a_expected timestamp_unconstrained), + member function of_(self in ut_be_within, a_expected timestamp_unconstrained) return ut_be_within, + member procedure of_(self in ut_be_within, a_expected timestamp_tz_unconstrained ), + member function of_(self in ut_be_within, a_expected timestamp_tz_unconstrained) return ut_be_within, + member procedure of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained), + member function of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained) return ut_be_within, + overriding member function run_matcher(self in out nocopy ut_be_within, a_actual ut_data_value) return boolean, + overriding member function failure_message(a_actual ut_data_value) return varchar2, + overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 +) +not final +/ diff --git a/source/expectations/matchers/ut_be_within_helper.pkb b/source/expectations/matchers/ut_be_within_helper.pkb new file mode 100644 index 000000000..9630e319f --- /dev/null +++ b/source/expectations/matchers/ut_be_within_helper.pkb @@ -0,0 +1,55 @@ +create or replace noneditionable package body ut_be_within_helper as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + function values_within_abs_distance( + a_actual ut_data_value, a_expected ut_data_value, a_distance ut_data_value + ) return boolean is + l_result integer; + l_YM_conversion varchar2(50) := case when a_distance is of (ut_data_value_yminterval) then ' year to month ' end; + l_formula varchar2(4000); + l_code varchar2(4000); + begin + l_formula := + case + when a_actual is of (ut_data_value_date) + then '( cast(greatest(l_actual, l_expected) as timestamp) - cast(least(l_actual, l_expected) as timestamp) ) '||l_YM_conversion||' <= l_distance' + else '( greatest(l_actual, l_expected) - least(l_actual, l_expected) ) '||l_YM_conversion||' <= l_distance' + end; + l_code := + q'[ + declare + l_actual ]'||dbms_assert.simple_sql_name(a_actual.data_type_plsql)|| q'[ := treat(:a_actual as ]'||dbms_assert.simple_sql_name(a_actual.self_type)||q'[).data_value; + l_expected ]'||dbms_assert.simple_sql_name(a_expected.data_type_plsql)||q'[ := treat(:a_expected as ]'||dbms_assert.simple_sql_name(a_expected.self_type)||q'[).data_value; + l_distance ]'||dbms_assert.simple_sql_name(a_distance.data_type_plsql)||q'[ := treat(:a_distance as ]'||dbms_assert.simple_sql_name(a_distance.self_type)||q'[).data_value; + begin + :result := + case + when + ]'||l_formula||q'[ + then 1 + else 0 + end; + end; + ]'; + execute immediate l_code + using a_actual, a_expected, a_distance, out l_result; + return l_result > 0; + end; + +end; +/ diff --git a/source/expectations/matchers/ut_be_within_helper.pks b/source/expectations/matchers/ut_be_within_helper.pks new file mode 100644 index 000000000..ca674d3bd --- /dev/null +++ b/source/expectations/matchers/ut_be_within_helper.pks @@ -0,0 +1,24 @@ +create or replace noneditionable package ut_be_within_helper authid definer as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + function values_within_abs_distance( + a_actual ut_data_value, a_expected ut_data_value, a_distance ut_data_value + ) return boolean; + +end; +/ diff --git a/source/expectations/matchers/ut_be_within_pct.tpb b/source/expectations/matchers/ut_be_within_pct.tpb new file mode 100644 index 000000000..91364ddab --- /dev/null +++ b/source/expectations/matchers/ut_be_within_pct.tpb @@ -0,0 +1,84 @@ +create or replace noneditionable type body ut_be_within_pct as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_be_within_pct(self in out nocopy ut_be_within_pct, a_pct_of_expected number) return self as result is + begin + self.init(ut_data_value_number(a_pct_of_expected), $$plsql_unit); + return; + end; + + member procedure init(self in out nocopy ut_be_within_pct, a_distance_from_expected ut_data_value, self_type varchar2) is + begin + self.distance_from_expected := a_distance_from_expected; + self.self_type := self_type; + end; + + member procedure of_(self in ut_be_within_pct, a_expected number) is + l_result ut_be_within_pct := self; + begin + l_result.expected := ut_data_value_number(a_expected); + if l_result.is_negated_flag = 1 then + l_result.expectation.not_to(l_result); + else + l_result.expectation.to_(l_result); + end if; + end; + + member function of_(self in ut_be_within_pct, a_expected number) return ut_be_within_pct is + l_result ut_be_within_pct := self; + begin + l_result.expected := ut_data_value_number(a_expected); + return l_result; + end; + + overriding member function run_matcher(self in out nocopy ut_be_within_pct, a_actual ut_data_value) return boolean is + l_result boolean; + begin + if self.expected.data_type = a_actual.data_type then + if self.expected is of (ut_data_value_number) then + l_result := + abs(treat(self.distance_from_expected as ut_data_value_number).data_value) * treat(self.expected as ut_data_value_number).data_value + >= abs( ( treat(self.expected as ut_data_value_number).data_value - treat(a_actual as ut_data_value_number).data_value ) * 100 ); + end if; + else + l_result := (self as ut_matcher).run_matcher(a_actual); + end if; + return l_result; + end; + + overriding member function failure_message(a_actual ut_data_value) return varchar2 is + begin + return rtrim( (self as ut_matcher).failure_message(a_actual), 'pct' ) || self.distance_from_expected.to_string ||' % of '|| expected.to_string_report(); + end; + + overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is + begin + return rtrim( (self as ut_matcher).failure_message_when_negated(a_actual), 'pct' ) || self.distance_from_expected.to_string ||' % of '|| expected.to_string_report(); + end; + + overriding member function error_message(a_actual ut_data_value) return varchar2 is + l_result varchar2(32767); + begin + if ut_utils.int_to_boolean(self.is_errored) then + l_result := 'Matcher '''||self.name()||''' cannot be used to compare Actual ('||a_actual.data_type||') with Expected ('||expected.data_type||') using distance ('||self.distance_from_expected.data_type||').'; + end if; + return l_result; + end; + +end; +/ diff --git a/source/expectations/matchers/ut_be_within_pct.tps b/source/expectations/matchers/ut_be_within_pct.tps new file mode 100644 index 000000000..048301817 --- /dev/null +++ b/source/expectations/matchers/ut_be_within_pct.tps @@ -0,0 +1,34 @@ +create or replace noneditionable type ut_be_within_pct force under ut_comparison_matcher( + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /** + * Holds information about mather options + */ + distance_from_expected ut_data_value, + + constructor function ut_be_within_pct(self in out nocopy ut_be_within_pct, a_pct_of_expected number) return self as result, + member procedure init(self in out nocopy ut_be_within_pct, a_distance_from_expected ut_data_value, self_type varchar2), + member procedure of_(self in ut_be_within_pct, a_expected number), + member function of_(self in ut_be_within_pct, a_expected number) return ut_be_within_pct, + overriding member function run_matcher(self in out nocopy ut_be_within_pct, a_actual ut_data_value) return boolean, + overriding member function failure_message(a_actual ut_data_value) return varchar2, + overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2, + overriding member function error_message(a_actual ut_data_value) return varchar2 +) +not final +/ diff --git a/source/expectations/matchers/ut_comparison_matcher.tpb b/source/expectations/matchers/ut_comparison_matcher.tpb index 50f8d6050..92245d304 100644 --- a/source/expectations/matchers/ut_comparison_matcher.tpb +++ b/source/expectations/matchers/ut_comparison_matcher.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_comparison_matcher as +create or replace noneditionable type body ut_comparison_matcher as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_comparison_matcher.tps b/source/expectations/matchers/ut_comparison_matcher.tps index 76520a296..4e698348c 100644 --- a/source/expectations/matchers/ut_comparison_matcher.tps +++ b/source/expectations/matchers/ut_comparison_matcher.tps @@ -1,10 +1,10 @@ -create or replace type ut_comparison_matcher under ut_matcher( +create or replace noneditionable type ut_comparison_matcher under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_contain.tpb b/source/expectations/matchers/ut_contain.tpb index c0c4f481a..3494a3d90 100644 --- a/source/expectations/matchers/ut_contain.tpb +++ b/source/expectations/matchers/ut_contain.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_contain as +create or replace noneditionable type body ut_contain as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -47,6 +47,7 @@ create or replace type body ut_contain as overriding member function run_matcher_negated(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is begin + self.negated(); return run_matcher(a_actual); end; diff --git a/source/expectations/matchers/ut_contain.tps b/source/expectations/matchers/ut_contain.tps index 518352573..9974d3a7c 100644 --- a/source/expectations/matchers/ut_contain.tps +++ b/source/expectations/matchers/ut_contain.tps @@ -1,10 +1,10 @@ -create or replace type ut_contain under ut_equal( +create or replace noneditionable type ut_contain under ut_equal( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_equal.tpb b/source/expectations/matchers/ut_equal.tpb index afa2148f3..4bd847c1b 100644 --- a/source/expectations/matchers/ut_equal.tpb +++ b/source/expectations/matchers/ut_equal.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_equal as +create or replace noneditionable type body ut_equal as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -158,6 +158,12 @@ create or replace type body ut_equal as return; end; + constructor function ut_equal(self in out nocopy ut_equal, a_expected json, a_nulls_are_equal boolean := null) return self as result is + begin + init(ut_data_value_json(a_expected), a_nulls_are_equal); + return; + end; + member function include(a_items varchar2) return ut_equal is l_result ut_equal := self; begin @@ -172,6 +178,18 @@ create or replace type body ut_equal as return l_result; end; + member procedure include(self in ut_equal, a_items varchar2) is + begin + include( ut_varchar2_list( a_items ) ); + end; + + member procedure include(self in ut_equal, a_items ut_varchar2_list) is + l_result ut_equal := self; + begin + l_result.options.include.add_items(a_items); + l_result.expectation.to_(l_result ); + end; + member function exclude(a_items varchar2) return ut_equal is l_result ut_equal := self; begin @@ -186,6 +204,18 @@ create or replace type body ut_equal as return l_result; end; + member procedure exclude(self in ut_equal, a_items varchar2) is + begin + exclude( ut_varchar2_list( a_items ) ); + end; + + member procedure exclude(self in ut_equal, a_items ut_varchar2_list) is + l_result ut_equal := self; + begin + l_result.options.exclude.add_items(a_items); + l_result.expectation.to_(l_result ); + end; + member function unordered return ut_equal is l_result ut_equal := self; begin @@ -193,6 +223,13 @@ create or replace type body ut_equal as return l_result; end; + member procedure unordered(self in ut_equal) is + l_result ut_equal := self; + begin + l_result.options.unordered(); + l_result.expectation.to_(l_result ); + end; + member function join_by(a_columns varchar2) return ut_equal is l_result ut_equal := self; begin @@ -209,18 +246,43 @@ create or replace type body ut_equal as return l_result; end; - member function uc return ut_equal is + member procedure join_by(self in ut_equal, a_columns varchar2) is begin - return unordered_columns; + join_by( ut_varchar2_list( a_columns ) ); end; + member procedure join_by(self in ut_equal, a_columns ut_varchar2_list) is + l_result ut_equal := self; + begin + l_result.options.unordered(); + l_result.options.join_by.add_items(a_columns); + l_result.expectation.to_(l_result ); + end; + member function unordered_columns return ut_equal is l_result ut_equal := self; begin l_result.options.unordered_columns(); return l_result; end; + + member procedure unordered_columns(self in ut_equal) is + l_result ut_equal := self; + begin + l_result.options.unordered_columns(); + l_result.expectation.to_(l_result ); + end; + + member function uc return ut_equal is + begin + return unordered_columns; + end; + member procedure uc(self in ut_equal) is + begin + unordered_columns; + end; + overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean is l_result boolean; begin diff --git a/source/expectations/matchers/ut_equal.tps b/source/expectations/matchers/ut_equal.tps index 1f42324d7..b6665b784 100644 --- a/source/expectations/matchers/ut_equal.tps +++ b/source/expectations/matchers/ut_equal.tps @@ -1,10 +1,10 @@ -create or replace type ut_equal force under ut_comparison_matcher( +create or replace noneditionable type ut_equal force under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -42,18 +42,28 @@ create or replace type ut_equal force under ut_comparison_matcher( constructor function ut_equal(self in out nocopy ut_equal, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) return self as result, constructor function ut_equal(self in out nocopy ut_equal, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) return self as result, constructor function ut_equal(self in out nocopy ut_equal, a_expected json_element_t, a_nulls_are_equal boolean := null) return self as result, + constructor function ut_equal(self in out nocopy ut_equal, a_expected json, a_nulls_are_equal boolean := null) return self as result, member function include(a_items varchar2) return ut_equal, - member function include(a_items ut_varchar2_list) return ut_equal, + member function include(a_items ut_varchar2_list) return ut_equal, + member procedure include(self in ut_equal, a_items varchar2), + member procedure include(self in ut_equal, a_items ut_varchar2_list), member function exclude(a_items varchar2) return ut_equal, member function exclude(a_items ut_varchar2_list) return ut_equal, + member procedure exclude(self in ut_equal, a_items varchar2), + member procedure exclude(self in ut_equal, a_items ut_varchar2_list), member function unordered return ut_equal, + member procedure unordered(self in ut_equal), member function join_by(a_columns varchar2) return ut_equal, member function join_by(a_columns ut_varchar2_list) return ut_equal, + member procedure join_by(self in ut_equal, a_columns varchar2), + member procedure join_by(self in ut_equal, a_columns ut_varchar2_list), overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean, overriding member function failure_message(a_actual ut_data_value) return varchar2, overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2, member function unordered_columns return ut_equal, - member function uc return ut_equal + member procedure unordered_columns(self in ut_equal), + member function uc return ut_equal, + member procedure uc(self in ut_equal) ) not final / diff --git a/source/expectations/matchers/ut_have_count.tpb b/source/expectations/matchers/ut_have_count.tpb index b0f4e06d4..5abc7fd82 100644 --- a/source/expectations/matchers/ut_have_count.tpb +++ b/source/expectations/matchers/ut_have_count.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_have_count as +create or replace noneditionable type body ut_have_count as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_have_count.tps b/source/expectations/matchers/ut_have_count.tps index fb0fc76fc..5e979e35f 100644 --- a/source/expectations/matchers/ut_have_count.tps +++ b/source/expectations/matchers/ut_have_count.tps @@ -1,10 +1,10 @@ -create or replace type ut_have_count under ut_matcher( +create or replace noneditionable type ut_have_count under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_match.tpb b/source/expectations/matchers/ut_match.tpb index 57fabbaec..067bd8100 100644 --- a/source/expectations/matchers/ut_match.tpb +++ b/source/expectations/matchers/ut_match.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_match as +create or replace noneditionable type body ut_match as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_match.tps b/source/expectations/matchers/ut_match.tps index 8d6b0f73a..682632efa 100644 --- a/source/expectations/matchers/ut_match.tps +++ b/source/expectations/matchers/ut_match.tps @@ -1,10 +1,10 @@ -create or replace type ut_match under ut_matcher( +create or replace noneditionable type ut_match under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_matcher.tpb b/source/expectations/matchers/ut_matcher.tpb index 11ff1b6b6..0cbf5924d 100644 --- a/source/expectations/matchers/ut_matcher.tpb +++ b/source/expectations/matchers/ut_matcher.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_matcher as +create or replace noneditionable type body ut_matcher as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,11 +20,6 @@ create or replace type body ut_matcher as begin ut_utils.debug_log('Failure - ut_matcher.run_matcher'||'(a_actual '||a_actual.data_type||')'); self.is_errored := ut_utils.boolean_to_int(true); --- self.error_message := 'The matcher '''||name()||''' cannot be used'; --- if self.expected is not null then --- self.error_message := self.error_message ||' for comparison of data type ('||self.expected.data_type||')'; --- end if; --- self.error_message := self.error_message ||' with data type ('||a_actual.data_type||').'; return null; end; diff --git a/source/expectations/matchers/ut_matcher.tps b/source/expectations/matchers/ut_matcher.tps index 34e1742df..f991afe7d 100644 --- a/source/expectations/matchers/ut_matcher.tps +++ b/source/expectations/matchers/ut_matcher.tps @@ -1,10 +1,10 @@ -create or replace type ut_matcher authid current_user as object( +create or replace noneditionable type ut_matcher under ut_matcher_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,10 +15,9 @@ create or replace type ut_matcher authid current_user as object( See the License for the specific language governing permissions and limitations under the License. */ - self_type varchar2(250), is_errored integer, is_negated_flag number(1,0), - + expectation ut_expectation_base, /* function: run_matcher diff --git a/source/expectations/matchers/ut_matcher_base.tps b/source/expectations/matchers/ut_matcher_base.tps new file mode 100644 index 000000000..e425c8baf --- /dev/null +++ b/source/expectations/matchers/ut_matcher_base.tps @@ -0,0 +1,22 @@ +create or replace noneditionable type ut_matcher_base force authid current_user as object( + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + self_type varchar2(250) +) +not final not instantiable +/ diff --git a/source/expectations/matchers/ut_matcher_options.tpb b/source/expectations/matchers/ut_matcher_options.tpb index 6fec3dee6..d391acc30 100644 --- a/source/expectations/matchers/ut_matcher_options.tpb +++ b/source/expectations/matchers/ut_matcher_options.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_matcher_options as +create or replace noneditionable type body ut_matcher_options as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_matcher_options.tps b/source/expectations/matchers/ut_matcher_options.tps index dbdf985f0..92b4207c3 100644 --- a/source/expectations/matchers/ut_matcher_options.tps +++ b/source/expectations/matchers/ut_matcher_options.tps @@ -1,10 +1,10 @@ -create or replace type ut_matcher_options authid current_user as object( +create or replace noneditionable type ut_matcher_options authid current_user as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_matcher_options_items.tpb b/source/expectations/matchers/ut_matcher_options_items.tpb index 2c3f51d34..672acdcaf 100644 --- a/source/expectations/matchers/ut_matcher_options_items.tpb +++ b/source/expectations/matchers/ut_matcher_options_items.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_matcher_options_items is +create or replace noneditionable type body ut_matcher_options_items is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/matchers/ut_matcher_options_items.tps b/source/expectations/matchers/ut_matcher_options_items.tps index cc74650f3..bae87b5df 100644 --- a/source/expectations/matchers/ut_matcher_options_items.tps +++ b/source/expectations/matchers/ut_matcher_options_items.tps @@ -1,10 +1,10 @@ -create or replace type ut_matcher_options_items authid current_user as object( +create or replace noneditionable type ut_matcher_options_items authid current_user as object( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/ut_expectation.tpb b/source/expectations/ut_expectation.tpb index d8ed1f79a..93bd0763f 100644 --- a/source/expectations/ut_expectation.tpb +++ b/source/expectations/ut_expectation.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_expectation as +create or replace noneditionable type body ut_expectation as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,31 +15,6 @@ create or replace type body ut_expectation as See the License for the specific language governing permissions and limitations under the License. */ - member procedure to_(self in ut_expectation, a_matcher ut_matcher) is - l_expectation_result boolean; - l_matcher ut_matcher := a_matcher; - l_message varchar2(32767); - begin - if a_matcher.is_negated() then - self.not_to( a_matcher ); - else - l_expectation_result := l_matcher.run_matcher( self.actual_data ); - l_expectation_result := coalesce(l_expectation_result,false); - l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message( self.actual_data ) ); - ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) ); - end if; - end; - - member procedure not_to(self in ut_expectation, a_matcher ut_matcher) is - l_expectation_result boolean; - l_matcher ut_matcher := a_matcher; - l_message varchar2(32767); - begin - l_expectation_result := coalesce( l_matcher.run_matcher_negated( self.actual_data ), false ); - - l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) ); - ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) ); - end; member procedure to_be_null(self in ut_expectation) is begin @@ -201,6 +176,11 @@ create or replace type body ut_expectation as self.to_( ut_equal(a_expected, a_nulls_are_equal) ); end; + member procedure to_equal(self in ut_expectation, a_expected json, a_nulls_are_equal boolean := null) is + begin + self.to_( ut_equal(a_expected, a_nulls_are_equal) ); + end; + member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is begin self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); @@ -706,7 +686,7 @@ create or replace type body ut_expectation as member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor) is begin - self.not_to( ut_contain(a_expected).negated() ); + self.not_to( ut_contain(a_expected)); end; member procedure to_contain(self in ut_expectation, a_expected anydata) is @@ -716,8 +696,73 @@ create or replace type body ut_expectation as member procedure not_to_contain(self in ut_expectation, a_expected anydata) is begin - self.not_to( ut_contain(a_expected).negated() ); + self.not_to( ut_contain(a_expected)); end; + member function to_be_within(a_dist number) return ut_be_within is + l_result ut_be_within; + begin + l_result := ut_be_within(a_dist); + l_result.expectation := self; + return l_result; + end; + + member function to_be_within(a_dist dsinterval_unconstrained) return ut_be_within is + l_result ut_be_within; + begin + l_result := ut_be_within(a_dist); + l_result.expectation := self; + return l_result; + end; + + member function to_be_within(a_dist yminterval_unconstrained) return ut_be_within is + l_result ut_be_within; + begin + l_result := ut_be_within(a_dist); + l_result.expectation := self; + return l_result; + end; + + member function to_be_within_pct(a_dist number) return ut_be_within_pct is + l_result ut_be_within_pct; + begin + l_result := ut_be_within_pct(a_dist); + l_result.expectation := self; + return l_result; + end; + + member function not_to_be_within(a_dist number) return ut_be_within is + l_result ut_be_within; + begin + l_result := treat( ut_be_within(a_dist).negated() as ut_be_within); + l_result.expectation := self; + return l_result; + end; + + member function not_to_be_within(a_dist dsinterval_unconstrained) return ut_be_within is + l_result ut_be_within; + begin + l_result := treat( ut_be_within(a_dist).negated() as ut_be_within); + l_result.expectation := self; + return l_result; + end; + + member function not_to_be_within(a_dist yminterval_unconstrained) return ut_be_within is + l_result ut_be_within; + begin + l_result := treat( ut_be_within(a_dist).negated() as ut_be_within); + l_result.expectation := self; + return l_result; + end; + + member function not_to_be_within_pct(a_dist number) return ut_be_within_pct is + l_result ut_be_within_pct; + begin + l_result := treat( ut_be_within_pct(a_dist).negated() as ut_be_within_pct); + l_result.expectation := self; + return l_result; + end; + end; / + diff --git a/source/expectations/ut_expectation.tps b/source/expectations/ut_expectation.tps index 37fefd085..a04f00caf 100644 --- a/source/expectations/ut_expectation.tps +++ b/source/expectations/ut_expectation.tps @@ -1,10 +1,10 @@ -create or replace type ut_expectation authid current_user as object( +create or replace noneditionable type ut_expectation force under ut_expectation_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,13 +15,7 @@ create or replace type ut_expectation authid current_user as object( See the License for the specific language governing permissions and limitations under the License. */ - actual_data ut_data_value, - description varchar2(4000 char), - - --base matcher executors - member procedure to_(self in ut_expectation, a_matcher ut_matcher), - member procedure not_to(self in ut_expectation, a_matcher ut_matcher), - + --shortcuts member procedure to_be_null(self in ut_expectation), member procedure to_be_not_null(self in ut_expectation), @@ -55,6 +49,7 @@ create or replace type ut_expectation authid current_user as object( member procedure to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null), member procedure to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null), member procedure to_equal(self in ut_expectation, a_expected json_element_t, a_nulls_are_equal boolean := null), + member procedure to_equal(self in ut_expectation, a_expected json, a_nulls_are_equal boolean := null), member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null), member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null), @@ -168,8 +163,16 @@ create or replace type ut_expectation authid current_user as object( member procedure to_contain(self in ut_expectation, a_expected sys_refcursor), member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor), member procedure to_contain(self in ut_expectation, a_expected anydata), - member procedure not_to_contain(self in ut_expectation, a_expected anydata) + member procedure not_to_contain(self in ut_expectation, a_expected anydata), + member function to_be_within(a_dist number) return ut_be_within, + member function to_be_within(a_dist dsinterval_unconstrained) return ut_be_within, + member function to_be_within(a_dist yminterval_unconstrained) return ut_be_within, + member function to_be_within_pct(a_dist number) return ut_be_within_pct, + member function not_to_be_within(a_dist number) return ut_be_within, + member function not_to_be_within(a_dist dsinterval_unconstrained) return ut_be_within, + member function not_to_be_within(a_dist yminterval_unconstrained) return ut_be_within, + member function not_to_be_within_pct(a_dist number) return ut_be_within_pct ) not final / diff --git a/source/expectations/ut_expectation_base.tpb b/source/expectations/ut_expectation_base.tpb new file mode 100644 index 000000000..802855b23 --- /dev/null +++ b/source/expectations/ut_expectation_base.tpb @@ -0,0 +1,45 @@ +create or replace noneditionable type body ut_expectation_base as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + member procedure to_(self in ut_expectation_base, a_matcher ut_matcher_base) is + l_expectation_result boolean; + l_matcher ut_matcher := treat(a_matcher as ut_matcher); + l_message varchar2(32767); + begin + if l_matcher.is_negated() then + self.not_to( a_matcher ); + else + l_expectation_result := l_matcher.run_matcher( self.actual_data ); + l_expectation_result := coalesce(l_expectation_result,false); + l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message( self.actual_data ) ); + ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) ); + end if; + end; + + member procedure not_to(self in ut_expectation_base, a_matcher ut_matcher_base) is + l_expectation_result boolean; + l_matcher ut_matcher := treat(a_matcher as ut_matcher); + l_message varchar2(32767); + begin + l_expectation_result := coalesce( l_matcher.run_matcher_negated( self.actual_data ), false ); + + l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) ); + ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) ); + end; +end; +/ diff --git a/source/expectations/ut_expectation_base.tps b/source/expectations/ut_expectation_base.tps new file mode 100644 index 000000000..48e610054 --- /dev/null +++ b/source/expectations/ut_expectation_base.tps @@ -0,0 +1,26 @@ +create or replace noneditionable type ut_expectation_base authid current_user as object( + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + actual_data ut_data_value, + description varchar2(4000 char), + + --base matcher executors + member procedure to_(self in ut_expectation_base, a_matcher ut_matcher_base), + member procedure not_to(self in ut_expectation_base, a_matcher ut_matcher_base) +) not final not instantiable +/ diff --git a/source/expectations/ut_expectation_compound.tpb b/source/expectations/ut_expectation_compound.tpb index 5e7268bd9..067f7922c 100644 --- a/source/expectations/ut_expectation_compound.tpb +++ b/source/expectations/ut_expectation_compound.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_expectation_compound as +create or replace noneditionable type body ut_expectation_compound as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -34,162 +34,68 @@ create or replace type body ut_expectation_compound as end; - member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound is - l_result ut_expectation_compound := self; + member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal is + l_result ut_equal; begin - l_result.matcher := ut_equal(a_expected, a_nulls_are_equal); + l_result := ut_equal(a_expected, a_nulls_are_equal); + l_result.expectation := self; return l_result; end; - member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound is - l_result ut_expectation_compound := self; + member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal is + l_result ut_matcher; begin - l_result.matcher := ut_equal(a_expected, a_nulls_are_equal).negated(); - return l_result; - end; - - member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is - l_result ut_expectation_compound := self; - begin - l_result.matcher := ut_equal(a_expected, a_nulls_are_equal); - return l_result; - end; - - member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is - l_result ut_expectation_compound := self; - begin - l_result.matcher := ut_equal(a_expected, a_nulls_are_equal).negated(); - return l_result; - end; - - member function to_contain(a_expected sys_refcursor) return ut_expectation_compound is - l_result ut_expectation_compound := self; - begin - l_result.matcher := ut_contain(a_expected); - return l_result; - end; - - member function not_to_contain(a_expected sys_refcursor) return ut_expectation_compound is - l_result ut_expectation_compound := self; - begin - l_result.matcher := ut_contain(a_expected).negated(); - return l_result; - end; - - member function to_contain(a_expected anydata) return ut_expectation_compound is - l_result ut_expectation_compound := self; - begin - l_result.matcher := ut_contain(a_expected); - return l_result; + l_result := ut_equal(a_expected, a_nulls_are_equal).negated(); + l_result.expectation := self; + return treat(l_result as ut_equal); end; - member function not_to_contain(a_expected anydata) return ut_expectation_compound is - l_result ut_expectation_compound := self; + member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal is + l_result ut_equal; begin - l_result.matcher := ut_contain(a_expected).negated(); + l_result := ut_equal(a_expected, a_nulls_are_equal); + l_result.expectation := self; return l_result; end; - member function include(a_items varchar2) return ut_expectation_compound is + member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal is + l_result ut_matcher; begin - return include( ut_varchar2_list( a_items ) ); + l_result := ut_equal(a_expected, a_nulls_are_equal).negated(); + l_result.expectation := self; + return treat(l_result as ut_equal); end; - member function include(a_items ut_varchar2_list) return ut_expectation_compound is - l_result ut_expectation_compound := self; + member function to_contain(a_expected sys_refcursor) return ut_contain is + l_result ut_contain; begin - l_result.matcher := treat(l_result.matcher as ut_equal).include(a_items); + l_result := ut_contain(a_expected); + l_result.expectation := self; return l_result; end; - member procedure include(self in ut_expectation_compound, a_items varchar2) is - begin - include( ut_varchar2_list( a_items ) ); - end; - - member procedure include(self in ut_expectation_compound, a_items ut_varchar2_list) is + member function not_to_contain(a_expected sys_refcursor) return ut_contain is + l_result ut_matcher; begin - self.to_( treat(matcher as ut_equal).include(a_items) ); + l_result := ut_contain(a_expected).negated(); + l_result.expectation := self; + return treat(l_result as ut_contain); end; - - member function exclude(a_items varchar2) return ut_expectation_compound is - begin - return exclude( ut_varchar2_list( a_items ) ); - end; - - member function exclude(a_items ut_varchar2_list) return ut_expectation_compound is - l_result ut_expectation_compound := self; + + member function to_contain(a_expected anydata) return ut_contain is + l_result ut_contain; begin - l_result.matcher := treat(l_result.matcher as ut_equal).exclude(a_items); + l_result := ut_contain(a_expected); + l_result.expectation := self; return l_result; end; - member procedure exclude(self in ut_expectation_compound, a_items varchar2) is - begin - exclude( ut_varchar2_list( a_items ) ); - end; - - member procedure exclude(self in ut_expectation_compound, a_items ut_varchar2_list) is - begin - self.to_( treat(matcher as ut_equal).exclude(a_items) ); - end; - - member function unordered return ut_expectation_compound is - l_result ut_expectation_compound := self; - begin - l_result.matcher := treat(l_result.matcher as ut_equal).unordered(); - return l_result; - end; - - member procedure unordered(self in ut_expectation_compound) is - begin - self.to_( treat(matcher as ut_equal).unordered() ); - end; - - member function join_by(a_columns varchar2) return ut_expectation_compound is - begin - return join_by( ut_varchar2_list( a_columns ) ); - end; - - member function join_by(a_columns ut_varchar2_list) return ut_expectation_compound is - l_result ut_expectation_compound; - begin - l_result := self; - l_result.matcher := treat(l_result.matcher as ut_equal).join_by(a_columns); - return l_result; - end; - - member procedure join_by(self in ut_expectation_compound, a_columns varchar2) is - begin - join_by( ut_varchar2_list( a_columns ) ); - end; - - member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list) is - begin - self.to_( treat(matcher as ut_equal).join_by(a_columns) ); - end; - - member function unordered_columns return ut_expectation_compound is - l_result ut_expectation_compound; - begin - l_result := self; - l_result.matcher := treat(l_result.matcher as ut_equal).unordered_columns; - return l_result; - end; - - member procedure unordered_columns(self in ut_expectation_compound) is - begin - self.to_( treat(matcher as ut_equal).unordered_columns ); - end; - - member function uc return ut_expectation_compound is - begin - return unordered_columns; - end; - - member procedure uc(self in ut_expectation_compound) is + member function not_to_contain(a_expected anydata) return ut_contain is + l_result ut_matcher; begin - unordered_columns; + l_result := ut_contain(a_expected).negated(); + l_result.expectation := self; + return treat(l_result as ut_contain); end; end; diff --git a/source/expectations/ut_expectation_compound.tps b/source/expectations/ut_expectation_compound.tps index fc413e3fd..38d821266 100644 --- a/source/expectations/ut_expectation_compound.tps +++ b/source/expectations/ut_expectation_compound.tps @@ -1,10 +1,10 @@ -create or replace type ut_expectation_compound force under ut_expectation( +create or replace noneditionable type ut_expectation_compound under ut_expectation( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,33 +22,15 @@ create or replace type ut_expectation_compound force under ut_expectation( member procedure to_have_count(self in ut_expectation_compound, a_expected integer), member procedure not_to_have_count(self in ut_expectation_compound, a_expected integer), - member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound, - member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound, - member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound, - member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound, - member function to_contain(a_expected sys_refcursor) return ut_expectation_compound, - member function not_to_contain(a_expected sys_refcursor) return ut_expectation_compound, - member function to_contain(a_expected anydata) return ut_expectation_compound, - member function not_to_contain(a_expected anydata) return ut_expectation_compound, - - member function include(a_items varchar2) return ut_expectation_compound, - member function include(a_items ut_varchar2_list) return ut_expectation_compound, - member procedure include(self in ut_expectation_compound, a_items varchar2), - member procedure include(self in ut_expectation_compound, a_items ut_varchar2_list), - member function exclude(a_items varchar2) return ut_expectation_compound, - member function exclude(a_items ut_varchar2_list) return ut_expectation_compound, - member procedure exclude(self in ut_expectation_compound, a_items varchar2), - member procedure exclude(self in ut_expectation_compound, a_items ut_varchar2_list), - member function unordered return ut_expectation_compound, - member procedure unordered(self in ut_expectation_compound), - member function join_by(a_columns varchar2) return ut_expectation_compound, - member function join_by(a_columns ut_varchar2_list) return ut_expectation_compound, - member procedure join_by(self in ut_expectation_compound, a_columns varchar2), - member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list), - - member function unordered_columns return ut_expectation_compound, - member procedure unordered_columns(self in ut_expectation_compound), - member function uc return ut_expectation_compound, - member procedure uc(self in ut_expectation_compound) + member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal, + member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal, + member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal, + member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal, + member function to_contain(a_expected sys_refcursor) return ut_contain, + member function not_to_contain(a_expected sys_refcursor) return ut_contain, + member function to_contain(a_expected anydata) return ut_contain, + member function not_to_contain(a_expected anydata) return ut_contain ) / + + diff --git a/source/expectations/ut_expectation_json.tpb b/source/expectations/ut_expectation_json.tpb index 49c0c2e1f..9f4204ea7 100644 --- a/source/expectations/ut_expectation_json.tpb +++ b/source/expectations/ut_expectation_json.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_expectation_json as +create or replace noneditionable type body ut_expectation_json as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/ut_expectation_json.tps b/source/expectations/ut_expectation_json.tps index dd3aa5b25..fd60ccb21 100644 --- a/source/expectations/ut_expectation_json.tps +++ b/source/expectations/ut_expectation_json.tps @@ -1,10 +1,10 @@ -create or replace type ut_expectation_json under ut_expectation( +create or replace noneditionable type ut_expectation_json under ut_expectation( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -24,4 +24,4 @@ create or replace type ut_expectation_json under ut_expectation( member procedure to_have_count(self in ut_expectation_json, a_expected integer), member procedure not_to_have_count(self in ut_expectation_json, a_expected integer) ) -/ +/ \ No newline at end of file diff --git a/source/install.sql b/source/install.sql index 1f9913b0a..3feca3a7d 100644 --- a/source/install.sql +++ b/source/install.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -34,40 +34,39 @@ alter session set current_schema = &&ut3_owner; @@check_sys_grants.sql "'CREATE TYPE','CREATE VIEW','CREATE SYNONYM','CREATE SEQUENCE','CREATE PROCEDURE','CREATE TABLE', 'CREATE CONTEXT'" --set define off -begin - $if $$self_testing_install $then - execute immediate 'create or replace context &&ut3_owner._info using &&ut3_owner..ut_session_context'; - $else - execute immediate 'create or replace context ut3_info using &&ut3_owner..ut_session_context'; - $end -end; -/ +create or replace context &&ut3_owner._info using &&ut3_owner..ut_session_context; + +@@create_cbac_role.sql --dbms_output buffer cache table @@install_component.sql 'core/ut_dbms_output_cache.sql' --common utilities +-- spec @@install_component.sql 'core/types/ut_varchar2_list.tps' @@install_component.sql 'core/types/ut_varchar2_rows.tps' @@install_component.sql 'core/types/ut_integer_list.tps' @@install_component.sql 'core/types/ut_object_name.tps' -@@install_component.sql 'core/types/ut_object_name.tpb' @@install_component.sql 'core/types/ut_object_names.tps' @@install_component.sql 'core/types/ut_key_value_pair.tps' @@install_component.sql 'core/types/ut_key_value_pairs.tps' @@install_component.sql 'core/types/ut_reporter_info.tps' @@install_component.sql 'core/types/ut_reporters_info.tps' +@@install_component.sql 'core/types/ut_stack.tps' @@install_component.sql 'core/ut_utils.pks' @@install_component.sql 'core/ut_metadata.pks' @@install_component.sql 'core/ut_savepoint_seq.sql' +@@install_component.sql 'reporters/ut_ansiconsole_helper.pks' +@@install_component.sql 'api/ut_suite_item_info.tps' +@@install_component.sql 'api/ut_suite_items_info.tps' +-- body +@@install_component.sql 'core/types/ut_object_name.tpb' +@@install_component.sql 'core/types/ut_stack.tpb' @@install_component.sql 'core/ut_utils.pkb' @@install_component.sql 'core/ut_metadata.pkb' -@@install_component.sql 'reporters/ut_ansiconsole_helper.pks' @@install_component.sql 'reporters/ut_ansiconsole_helper.pkb' - -@@install_component.sql 'api/ut_suite_item_info.tps' @@install_component.sql 'api/ut_suite_item_info.tpb' -@@install_component.sql 'api/ut_suite_items_info.tps' + --event manager objects @@install_component.sql 'core/events/ut_event_item.tps' @@ -76,8 +75,8 @@ end; @@install_component.sql 'core/events/ut_event_manager.pkb' --core types +-- spec @@install_component.sql 'core/types/ut_run_info.tps' -@@install_component.sql 'core/types/ut_run_info.tpb' @@install_component.sql 'core/types/ut_expectation_result.tps' @@install_component.sql 'core/types/ut_expectation_results.tps' @@install_component.sql 'core/types/ut_results_counter.tps' @@ -96,8 +95,8 @@ end; @@install_component.sql 'core/types/ut_run.tps' @@install_component.sql 'core/types/ut_reporter_base.tps' @@install_component.sql 'core/types/ut_reporters.tps' - - +@@install_component.sql 'core/types/ut_path_item.tps' +@@install_component.sql 'core/types/ut_path_items.tps' @@install_component.sql 'expectations/json_objects_specs.sql' @@install_component.sql 'expectations/matchers/ut_matcher_options_items.tps' @@install_component.sql 'expectations/matchers/ut_matcher_options.tps' @@ -105,18 +104,24 @@ end; @@install_component.sql 'expectations/data_values/ut_key_anyval_pair.tps' @@install_component.sql 'expectations/data_values/ut_key_anyval_pairs.tps' @@install_component.sql 'expectations/data_values/ut_key_anyvalues.tps' +-- body +@@install_component.sql 'core/types/ut_run_info.tpb' + --session_context +-- spec @@install_component.sql 'core/session_context/ut_session_context.pks' -@@install_component.sql 'core/session_context/ut_session_context.pkb' @@install_component.sql 'core/session_context/ut_session_info.tps' +-- body +@@install_component.sql 'core/session_context/ut_session_context.pkb' @@install_component.sql 'core/session_context/ut_session_info.tpb' ---output buffer table +--output buffer +-- tables @@install_component.sql 'core/output_buffers/ut_output_buffer_info_tmp.sql' @@install_component.sql 'core/output_buffers/ut_output_buffer_tmp.sql' @@install_component.sql 'core/output_buffers/ut_output_clob_buffer_tmp.sql' ---output buffer base api +-- base api @@install_component.sql 'core/output_buffers/ut_output_data_row.tps' @@install_component.sql 'core/output_buffers/ut_output_data_rows.tps' @@install_component.sql 'core/output_buffers/ut_output_buffer_base.tps' @@ -126,12 +131,13 @@ end; @@install_component.sql 'core/output_buffers/ut_output_table_buffer.tpb' @@install_component.sql 'core/output_buffers/ut_output_clob_table_buffer.tps' @@install_component.sql 'core/output_buffers/ut_output_clob_table_buffer.tpb' +@@install_component.sql 'core/output_buffers/ut_output_bulk_buffer.tps' +@@install_component.sql 'core/output_buffers/ut_output_bulk_buffer.tpb' @@install_component.sql 'core/types/ut_output_reporter_base.tps' --annotations @@install_component.sql 'core/annotations/ut_trigger_check.pks' -@@install_component.sql 'core/annotations/ut_trigger_check.pkb' @@install_component.sql 'core/annotations/ut_annotation.tps' @@install_component.sql 'core/annotations/ut_annotations.tps' @@install_component.sql 'core/annotations/ut_annotated_object.tps' @@ -142,12 +148,11 @@ end; @@install_component.sql 'core/annotations/ut_annotation_cache_schema.sql' @@install_component.sql 'core/annotations/ut_annotation_cache_info.sql' @@install_component.sql 'core/annotations/ut_annotation_cache.sql' +@@install_component.sql 'core/annotations/ut_annotation_cache_macros.pks' @@install_component.sql 'core/annotations/ut_annotation_cache_manager.pks' -@@install_component.sql 'core/annotations/ut_annotation_cache_manager.pkb' @@install_component.sql 'core/annotations/ut_annotation_parser.pks' -@@install_component.sql 'core/annotations/ut_annotation_parser.pkb' @@install_component.sql 'core/annotations/ut_annotation_manager.pks' -@@install_component.sql 'core/annotations/ut_annotation_manager.pkb' + --suite builder @@install_component.sql 'core/types/ut_suite_cache_row.tps' @@ -157,14 +162,29 @@ end; @@install_component.sql 'core/ut_suite_cache_seq.sql' @@install_component.sql 'core/ut_suite_cache.sql' +@@install_component.sql 'core/ut_suite_tag_filter.pks' +@@install_component.sql 'core/ut_suite_cache_macros.pks' @@install_component.sql 'core/ut_suite_cache_manager.pks' -@@install_component.sql 'core/ut_suite_cache_manager.pkb' @@install_component.sql 'core/ut_suite_builder.pks' -@@install_component.sql 'core/ut_suite_builder.pkb' --suite manager @@install_component.sql 'core/ut_suite_manager.pks' + +--code based access control +@@ut3_cbac_modify_objects_role_grants.sql + +--bodies +@@install_component.sql 'core/annotations/ut_trigger_check.pkb' +@@install_component.sql 'core/annotations/ut_annotation_cache_macros.pkb' +@@install_component.sql 'core/annotations/ut_annotation_cache_manager.pkb' +@@install_component.sql 'core/annotations/ut_annotation_parser.pkb' +@@install_component.sql 'core/annotations/ut_annotation_manager.pkb' +@@install_component.sql 'core/ut_suite_tag_filter.pkb' +@@install_component.sql 'core/ut_suite_cache_macros.pkb' +@@install_component.sql 'core/ut_suite_cache_manager.pkb' +@@install_component.sql 'core/ut_suite_builder.pkb' @@install_component.sql 'core/ut_suite_manager.pkb' + --expectations execution state interface @@install_component.sql 'core/ut_expectation_processor.pks' @@install_component.sql 'core/ut_expectation_processor.pkb' @@ -172,9 +192,6 @@ end; prompt Installing PLSQL profiler objects into &&ut3_owner schema @@core/coverage/proftab.sql -prompt Installing PLSQL profiler objects into &&ut3_owner schema -@@core/coverage/proftab.sql - prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@core/coverage/dbms_plssqlcode.sql @@ -184,6 +201,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema --gathering coverage @@install_component.sql 'core/coverage/ut_coverage_sources_tmp.sql' +@@install_component.sql 'core/coverage/ut_coverage_runs.sql' @@install_component.sql 'core/coverage/ut_coverage_helper.pks' @@install_component.sql 'core/coverage/ut_coverage_helper_block.pks' @@install_component.sql 'core/coverage/ut_coverage_helper_profiler.pks' @@ -206,6 +224,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'core/types/ut_logical_suite.tpb' @@install_component.sql 'core/types/ut_suite.tpb' @@install_component.sql 'core/types/ut_suite_context.tpb' +@@install_component.sql 'core/types/ut_coverage_options.tpb' @@install_component.sql 'core/types/ut_run.tpb' @@install_component.sql 'core/types/ut_expectation_result.tpb' @@install_component.sql 'core/types/ut_reporter_base.tpb' @@ -215,6 +234,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'core/types/ut_executable_test.tpb' @@install_component.sql 'core/types/ut_console_reporter_base.tps' @@install_component.sql 'core/types/ut_console_reporter_base.tpb' +@@install_component.sql 'core/types/ut_path_item.tpb' --expectations and matchers @@install_component.sql 'expectations/data_values/ut_compound_data_tmp.sql' @@ -243,8 +263,14 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_xmltype.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_helper.pks' @@install_component.sql 'expectations/data_values/ut_data_value_json.tps' +@@install_component.sql 'expectations/matchers/ut_matcher_base.tps' +@@install_component.sql 'expectations/ut_expectation_base.tps' @@install_component.sql 'expectations/matchers/ut_matcher.tps' @@install_component.sql 'expectations/matchers/ut_comparison_matcher.tps' +@@install_component.sql 'expectations/matchers/ut_be_within_pct.tps' +@@install_component.sql 'expectations/matchers/ut_be_within.tps' +@@install_component.sql 'expectations/matchers/ut_be_within_helper.pks' +@@install_component.sql 'expectations/ut_expectation.tps' @@install_component.sql 'expectations/matchers/ut_be_false.tps' @@install_component.sql 'expectations/matchers/ut_be_greater_or_equal.tps' @@install_component.sql 'expectations/matchers/ut_be_greater_than.tps' @@ -260,7 +286,6 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/matchers/ut_be_between.tps' @@install_component.sql 'expectations/matchers/ut_be_empty.tps' @@install_component.sql 'expectations/matchers/ut_match.tps' -@@install_component.sql 'expectations/ut_expectation.tps' @@install_component.sql 'expectations/data_values/ut_json_leaf.tpb' @@install_component.sql 'expectations/data_values/ut_json_tree_details.tpb' @@install_component.sql 'expectations/data_values/ut_cursor_column.tpb' @@ -300,11 +325,15 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/matchers/ut_be_null.tpb' @@install_component.sql 'expectations/matchers/ut_be_true.tpb' @@install_component.sql 'expectations/matchers/ut_equal.tpb' +@@install_component.sql 'expectations/matchers/ut_be_within_pct.tpb' +@@install_component.sql 'expectations/matchers/ut_be_within.tpb' +@@install_component.sql 'expectations/matchers/ut_be_within_helper.pkb' @@install_component.sql 'expectations/matchers/ut_contain.tpb' @@install_component.sql 'expectations/matchers/ut_have_count.tpb' @@install_component.sql 'expectations/matchers/ut_be_between.tpb' @@install_component.sql 'expectations/matchers/ut_be_empty.tpb' @@install_component.sql 'expectations/matchers/ut_match.tpb' +@@install_component.sql 'expectations/ut_expectation_base.tpb' @@install_component.sql 'expectations/ut_expectation.tpb' @@install_component.sql 'expectations/ut_expectation_compound.tpb' @@install_component.sql 'expectations/ut_expectation_json.tpb' @@ -337,6 +366,8 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'reporters/ut_xunit_reporter.tpb' @@install_component.sql 'reporters/ut_sonar_test_reporter.tps' @@install_component.sql 'reporters/ut_sonar_test_reporter.tpb' +@@install_component.sql 'reporters/ut_tap_reporter.tps' +@@install_component.sql 'reporters/ut_tap_reporter.tpb' @@install_component.sql 'reporters/ut_coverage_html_reporter.tps' @@install_component.sql 'reporters/ut_coverage_report_html_helper.pks' @@ -344,8 +375,6 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'reporters/ut_coverage_html_reporter.tpb' @@install_component.sql 'reporters/ut_coverage_sonar_reporter.tps' @@install_component.sql 'reporters/ut_coverage_sonar_reporter.tpb' -@@install_component.sql 'reporters/ut_coveralls_reporter.tps' -@@install_component.sql 'reporters/ut_coveralls_reporter.tpb' @@install_component.sql 'reporters/ut_coverage_cobertura_reporter.tps' @@install_component.sql 'reporters/ut_coverage_cobertura_reporter.tpb' @@install_component.sql 'reporters/ut_realtime_reporter.tps' @@ -362,6 +391,8 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'api/be_not_null.syn' @@install_component.sql 'api/be_null.syn' @@install_component.sql 'api/be_true.syn' +@@install_component.sql 'api/be_within_pct.syn' +@@install_component.sql 'api/be_within.syn' @@install_component.sql 'api/equal.syn' @@install_component.sql 'api/have_count.syn' @@install_component.sql 'api/match.syn' diff --git a/source/install_above_12_1.sql b/source/install_above_12_1.sql deleted file mode 100644 index 69e47ce9a..000000000 --- a/source/install_above_12_1.sql +++ /dev/null @@ -1,27 +0,0 @@ -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release >= 2 - or dbms_db_version.version > 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ - -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - -set heading off -set feedback off -exec dbms_output.put_line('Installing component '||upper(regexp_substr('&&1','\/(\w*)\.',1,1,'i',1))); -@@&&SCRIPT_NAME -exec dbms_output.put_line('&&line_separator'); - - - diff --git a/source/install_component.sql b/source/install_component.sql index 857c1771c..a7394fe9a 100644 --- a/source/install_component.sql +++ b/source/install_component.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/install_ddl_trigger.sql b/source/install_ddl_trigger.sql index 843ee0c07..a9ede374f 100644 --- a/source/install_ddl_trigger.sql +++ b/source/install_ddl_trigger.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/install_headless.sql b/source/install_headless.sql index e8cf00705..04c0109b0 100644 --- a/source/install_headless.sql +++ b/source/install_headless.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/install_headless_with_trigger.sql b/source/install_headless_with_trigger.sql index 16d81f3c6..7953b0205 100644 --- a/source/install_headless_with_trigger.sql +++ b/source/install_headless_with_trigger.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_ansiconsole_helper.pkb b/source/reporters/ut_ansiconsole_helper.pkb index b015e50be..b6610b778 100644 --- a/source/reporters/ut_ansiconsole_helper.pkb +++ b/source/reporters/ut_ansiconsole_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_ansiconsole_helper as +create or replace noneditionable package body ut_ansiconsole_helper as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_ansiconsole_helper.pks b/source/reporters/ut_ansiconsole_helper.pks index 7c83ca73b..f06f96a7e 100644 --- a/source/reporters/ut_ansiconsole_helper.pks +++ b/source/reporters/ut_ansiconsole_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_ansiconsole_helper as +create or replace noneditionable package ut_ansiconsole_helper as /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_coverage_cobertura_reporter.tpb b/source/reporters/ut_coverage_cobertura_reporter.tpb index eed8e8e73..36c22c68b 100644 --- a/source/reporters/ut_coverage_cobertura_reporter.tpb +++ b/source/reporters/ut_coverage_cobertura_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_cobertura_reporter is +create or replace noneditionable type body ut_coverage_cobertura_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,7 +20,7 @@ create or replace type body ut_coverage_cobertura_reporter is self in out nocopy ut_coverage_cobertura_reporter ) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_bulk_buffer()); return; end; @@ -29,11 +29,19 @@ create or replace type body ut_coverage_cobertura_reporter is l_report_lines ut_varchar2_list; l_coverage_data ut_coverage.t_coverage; - function get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage) return clob is + function get_line_rate(a_lines_covered in integer, a_lines_hit in integer) return varchar2 is + begin + return to_char(round((case a_lines_covered when 0 then 0 else a_lines_covered/a_lines_hit end), 17), rpad('FM0.0',20,'9') , 'NLS_NUMERIC_CHARACTERS=''. '''); + end; + + procedure get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage, + a_lines_result in out nocopy clob, a_lines_hits out number, a_lines_total out number) is l_file_part varchar2(32767); l_result clob; l_line_no binary_integer; l_pct integer; + l_lines_hits integer := 0; + l_lines_total integer := 0; begin dbms_lob.createtemporary(l_result, true); l_line_no := a_unit_coverage.lines.first; @@ -41,11 +49,14 @@ create or replace type body ut_coverage_cobertura_reporter is for i in 1 .. a_unit_coverage.total_lines loop ut_utils.append_to_clob(l_result, ''||chr(10)); end loop; + l_lines_hits:=0; + l_lines_total:= a_unit_coverage.total_lines; else while l_line_no is not null loop if a_unit_coverage.lines(l_line_no).executions = 0 then l_file_part := ''||chr(10); else + l_lines_hits:= l_lines_hits+1; l_file_part := '' ); @@ -112,23 +134,32 @@ create or replace type body ut_coverage_cobertura_reporter is while l_unit is not null loop l_obj_name := a_coverage_data.objects(l_unit).name; + dbms_lob.createtemporary(l_lines_xml, true); + get_lines_xml(a_coverage_data.objects(l_unit),l_lines_xml,l_line_hits,l_line_total); + ut_utils.append_to_list( l_result, - '' + '' + ); + + ut_utils.append_to_list( + l_result, + '' ); ut_utils.append_to_list( l_result, '' + ||dbms_xmlgen.convert(l_unit)||'" line-rate="'||get_line_rate(l_line_hits,l_line_total)||'" branch-rate="0.0" complexity="0.0">' ); ut_utils.append_to_list(l_result, ''); - - ut_utils.append_to_list( l_result, get_lines_xml(a_coverage_data.objects(l_unit)) ); - + ut_utils.append_to_list( l_result,l_lines_xml); + dbms_lob.freetemporary(l_lines_xml); + ut_utils.append_to_list(l_result, c_lines_footer); ut_utils.append_to_list(l_result, c_class_footer); + ut_utils.append_to_list(l_result, c_classes_footer); ut_utils.append_to_list(l_result, c_package_footer); l_unit := a_coverage_data.objects.next(l_unit); @@ -150,10 +181,9 @@ create or replace type body ut_coverage_cobertura_reporter is overriding member function get_description return varchar2 as begin - return 'Generates a Cobertura coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for Jenkins and TFS to report coverage. ' || chr(10) || - 'Cobertura Document Type Definition can be found: http://cobertura.sourceforge.net/xml/coverage-04.dtd.'|| chr(10) || - 'Sample file: https://github.com/leobalter/testing-examples/blob/master/solutions/3/report/cobertura-coverage.xml.'; + return 'Generates Cobertura report on code coverage with line numbers. +Compatible with GitHub Actions, Jenkins, Azure Pipelines, GitLab CI, and any tool that reads the popular Cobertura format. +Cobertura Document Type Definition is located [here](https://github.com/cobertura/cobertura/blob/master/cobertura/src/site/htdocs/xml/coverage-04.dtd).'; end; end; diff --git a/source/reporters/ut_coverage_cobertura_reporter.tps b/source/reporters/ut_coverage_cobertura_reporter.tps index ec5cef2cb..8e4586c38 100644 --- a/source/reporters/ut_coverage_cobertura_reporter.tps +++ b/source/reporters/ut_coverage_cobertura_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_cobertura_reporter under ut_coverage_reporter_base( +create or replace noneditionable type ut_coverage_cobertura_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_coverage_html_reporter.tpb b/source/reporters/ut_coverage_html_reporter.tpb index 9e51b5cc2..49f412cb1 100644 --- a/source/reporters/ut_coverage_html_reporter.tpb +++ b/source/reporters/ut_coverage_html_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_html_reporter is +create or replace noneditionable type body ut_coverage_html_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,7 +22,7 @@ create or replace type body ut_coverage_html_reporter is a_html_report_assets_path varchar2 := null ) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_bulk_buffer()); self.project_name := a_project_name; assets_path := nvl(a_html_report_assets_path, ut_coverage_report_html_helper.get_default_html_assets_path()); return; @@ -39,7 +39,8 @@ create or replace type body ut_coverage_html_reporter is a_coverage_data => l_coverage_data, a_assets_path => self.assets_path, a_project_name => self.project_name, - a_charset => a_run.client_character_set + a_charset => a_run.client_character_set, + a_support_info => a_run.get_support_info_flag() ) ); end; diff --git a/source/reporters/ut_coverage_html_reporter.tps b/source/reporters/ut_coverage_html_reporter.tps index f6bdcc249..13365efe9 100644 --- a/source/reporters/ut_coverage_html_reporter.tps +++ b/source/reporters/ut_coverage_html_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_html_reporter under ut_coverage_reporter_base( +create or replace noneditionable type ut_coverage_html_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index 00a53c4c6..2ab989eea 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_report_html_helper is +create or replace noneditionable package body ut_coverage_report_html_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -90,7 +90,7 @@ create or replace package body ut_coverage_report_html_helper is function object_id(a_object_full_name varchar2) return varchar2 is begin - return rawtohex(utl_raw.cast_to_raw(dbms_obfuscation_toolkit.md5(input_string => a_object_full_name))); + return rawtohex(dbms_crypto.hash(src => utl_raw.cast_to_raw(a_object_full_name), typ => dbms_crypto.HASH_SH256)); end; function link_to_source_file(a_object_full_name varchar2) return varchar2 is @@ -134,9 +134,11 @@ create or replace package body ut_coverage_report_html_helper is l_file_part varchar2(32767); l_result ut_varchar2_rows := ut_varchar2_rows(); l_coverage_pct number(5, 2); - l_coverage_block_pct number(5, 2); l_hits varchar2(30); l_blocks varchar2(30); + l_line_text varchar2(32767); + e_buffer_too_small exception; + pragma exception_init ( e_buffer_too_small, -19011 ); begin l_coverage_pct := coverage_pct(a_coverage_unit.covered_lines, a_coverage_unit.uncovered_lines); @@ -148,10 +150,16 @@ create or replace package body ut_coverage_report_html_helper is ut_utils.append_to_list(l_result, l_file_part); for line_no in 1 .. a_source_code.count loop + begin + l_line_text := dbms_xmlgen.convert(a_source_code(line_no)); + exception + when e_buffer_too_small then + l_line_text := dbms_xmlgen.convert(to_clob(a_source_code(line_no))); + end; if not a_coverage_unit.lines.exists(line_no) then l_file_part := '
  • - ' || (dbms_xmlgen.convert(a_source_code(line_no))) || + ' || l_line_text || '
  • '; else l_hits := to_char(a_coverage_unit.lines(line_no).executions); @@ -188,7 +196,7 @@ create or replace package body ut_coverage_report_html_helper is ''; end if; l_file_part := l_file_part || ' - ' || (dbms_xmlgen.convert(a_source_code(line_no))) || + ' || l_line_text || ''; end if; ut_utils.append_to_list(l_result, l_file_part); @@ -222,9 +230,8 @@ create or replace package body ut_coverage_report_html_helper is l_file_part varchar2(32767); l_title varchar2(100) := 'All files'; l_coverage_pct number(5, 2); - l_coverage_block_pct number(5, 2); l_result ut_varchar2_rows; - l_id varchar2(50) := object_id(a_title); + l_id varchar2(100) := object_id(a_title); l_unit_coverage ut_coverage.t_unit_coverage; l_unit ut_coverage.t_object_name; begin @@ -278,7 +285,8 @@ create or replace package body ut_coverage_report_html_helper is a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null, - a_charset varchar2 := null + a_charset varchar2 := null, + a_support_info boolean := true ) return ut_varchar2_rows is l_file_part varchar2(32767); @@ -287,7 +295,7 @@ create or replace package body ut_coverage_report_html_helper is l_coverage_pct number(5, 2); l_time_str varchar2(50); l_using varchar2(1000); - l_unit ut_coverage.t_full_name; + l_unit ut_coverage.t_object_name; l_charset varchar2(1000); begin l_charset := coalesce(upper(a_charset),'UTF-8'); @@ -322,9 +330,12 @@ create or replace package body ut_coverage_report_html_helper is ut_utils.append_to_list(l_result, file_list('All files', a_coverage_data)); l_file_part := chr(10) || '
    '; ut_utils.append_to_list(l_result, l_file_part); diff --git a/source/reporters/ut_coverage_report_html_helper.pks b/source/reporters/ut_coverage_report_html_helper.pks index 48dd76acf..a6dd7eb30 100644 --- a/source/reporters/ut_coverage_report_html_helper.pks +++ b/source/reporters/ut_coverage_report_html_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_report_html_helper authid current_user is +create or replace noneditionable package ut_coverage_report_html_helper authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -36,7 +36,8 @@ create or replace package ut_coverage_report_html_helper authid current_user is a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null, - a_charset varchar2 := null + a_charset varchar2 := null, + a_support_info boolean := true ) return ut_varchar2_rows; end; diff --git a/source/reporters/ut_coverage_sonar_reporter.tpb b/source/reporters/ut_coverage_sonar_reporter.tpb index bfe0d890b..8eb4c57aa 100644 --- a/source/reporters/ut_coverage_sonar_reporter.tpb +++ b/source/reporters/ut_coverage_sonar_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_sonar_reporter is +create or replace noneditionable type body ut_coverage_sonar_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,7 +20,7 @@ create or replace type body ut_coverage_sonar_reporter is self in out nocopy ut_coverage_sonar_reporter ) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_bulk_buffer()); return; end; @@ -61,7 +61,7 @@ create or replace type body ut_coverage_sonar_reporter is a_run ut_run ) return ut_varchar2_rows is l_result ut_varchar2_rows := ut_varchar2_rows(); - l_unit ut_coverage.t_full_name; + l_unit ut_coverage.t_object_name; c_coverage_header constant varchar2(30) := ''; c_file_footer constant varchar2(30) := ''; c_coverage_footer constant varchar2(30) := ''; @@ -84,6 +84,12 @@ create or replace type body ut_coverage_sonar_reporter is end; begin +-- execute immediate 'alter session set statistics_level=all'; +-- dbms_hprof.start_profiling( +-- location => 'PLSHPROF_DIR' +-- , filename => 'profiler_utPLSQL_run_on_'||$$plsql_unit||'_'||rawtohex(self.id)||'.txt' +-- ); +-- ut_coverage.coverage_stop(); self.print_text_lines( @@ -92,13 +98,14 @@ create or replace type body ut_coverage_sonar_reporter is a_run ) ); +-- dbms_hprof.stop_profiling; end; overriding member function get_description return varchar2 as begin - return 'Generates a JSON coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for [SonarQube](https://about.sonarqube.com/) to report coverage.' || chr(10) || - 'JSON format returned conforms with the Sonar specification: https://docs.sonarqube.org/display/SONAR/Generic+Test+Data'; + return 'Generates an XML coverage report providing information on code coverage with line numbers. +Designed for [SonarQube](https://www.sonarsource.com/products/sonarqube/) to report coverage. +XML format returned conforms with the [Sonar specification](https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/test-coverage/generic-test-data).'; end; end; diff --git a/source/reporters/ut_coverage_sonar_reporter.tps b/source/reporters/ut_coverage_sonar_reporter.tps index aa21cafe3..0268fee64 100644 --- a/source/reporters/ut_coverage_sonar_reporter.tps +++ b/source/reporters/ut_coverage_sonar_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_sonar_reporter under ut_coverage_reporter_base( +create or replace noneditionable type ut_coverage_sonar_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,7 +18,7 @@ create or replace type ut_coverage_sonar_reporter under ut_coverage_reporter_bas /** * Builds a coverage XML report that follows rules described in - * https://docs.sonarqube.org/display/SONAR/Generic+Test+Data + * https://docs.sonarqube.org/latest/analysis/generic-test/ */ constructor function ut_coverage_sonar_reporter( self in out nocopy ut_coverage_sonar_reporter diff --git a/source/reporters/ut_coveralls_reporter.tpb b/source/reporters/ut_coveralls_reporter.tpb deleted file mode 100644 index 1ca317c69..000000000 --- a/source/reporters/ut_coveralls_reporter.tpb +++ /dev/null @@ -1,104 +0,0 @@ -create or replace type body ut_coveralls_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project - - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - constructor function ut_coveralls_reporter( - self in out nocopy ut_coveralls_reporter - ) return self as result is - begin - self.init($$plsql_unit); - return; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run) as - - function get_lines_json(a_unit_coverage ut_coverage.t_unit_coverage) return ut_varchar2_rows is - l_file_part varchar2(32767); - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_last_line_no binary_integer; - c_coverage_header constant varchar2(30) := '"coverage": ['; - c_null constant varchar2(4) := 'null'; - begin - ut_utils.append_to_list(l_result, c_coverage_header); - - l_last_line_no := a_unit_coverage.lines.last; - if l_last_line_no is null then - ut_utils.append_to_list( - l_result - , rpad( to_clob( '0' ), ( a_unit_coverage.total_lines * 3 ) - 2, ','||chr(10)||'0' ) - ); - else - for line_no in 1 .. l_last_line_no loop - if a_unit_coverage.lines.exists(line_no) then - l_file_part := to_char(a_unit_coverage.lines(line_no).executions); - else - l_file_part := c_null; - end if; - if line_no < l_last_line_no then - l_file_part := l_file_part ||','; - end if; - ut_utils.append_to_list(l_result, l_file_part); - end loop; - end if; - ut_utils.append_to_list(l_result, ']'); - return l_result; - end; - - function get_coverage_json( - a_coverage_data ut_coverage.t_coverage - ) return ut_varchar2_rows is - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_unit ut_coverage.t_full_name; - c_coverage_header constant varchar2(30) := '{"source_files":['; - c_coverage_footer constant varchar2(30) := ']}'||chr(10)||' '; - begin - ut_utils.append_to_list(l_result, c_coverage_header); - l_unit := a_coverage_data.objects.first; - while l_unit is not null loop - ut_utils.append_to_list(l_result, '{ "name": "'||l_unit||'",'); - - ut_utils.append_to_list(l_result,get_lines_json(a_coverage_data.objects(l_unit))); - - ut_utils.append_to_list(l_result, '}'); - - l_unit := a_coverage_data.objects.next(l_unit); - if l_unit is not null then - ut_utils.append_to_list(l_result, ','); - end if; - end loop; - ut_utils.append_to_list(l_result, c_coverage_footer); - return l_result; - end; - begin - ut_coverage.coverage_stop(); - - self.print_text_lines( - get_coverage_json( - ut_coverage.get_coverage_data(a_run.coverage_options) - ) - ); - end; - - overriding member function get_description return varchar2 as - begin - return 'Generates a JSON coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for [Coveralls](https://coveralls.io/).' || chr(10) || - 'JSON format conforms with specification: https://docs.coveralls.io/api-introduction'; - end; - -end; -/ diff --git a/source/reporters/ut_debug_reporter.tpb b/source/reporters/ut_debug_reporter.tpb index 365f77755..a2b797021 100644 --- a/source/reporters/ut_debug_reporter.tpb +++ b/source/reporters/ut_debug_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_debug_reporter is +create or replace noneditionable type body ut_debug_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -71,7 +71,7 @@ create or replace type body ut_debug_reporter is member function event_item_to_clob(a_event_item ut_event_item) return clob is l_clob clob; begin - select xmlserialize( content deletexml(xmltype(a_event_item),'/*/ITEMS|/*/ALL_EXPECTATIONS|/*/FAILED_EXPECTATIONS') as clob indent size = 2 ) into l_clob from dual; + select /*+ no_parallel */ xmlserialize( content deletexml(xmltype(a_event_item),'/*/ITEMS|/*/ALL_EXPECTATIONS|/*/FAILED_EXPECTATIONS') as clob indent size = 2 ) into l_clob from dual; return l_clob; end; diff --git a/source/reporters/ut_debug_reporter.tps b/source/reporters/ut_debug_reporter.tps index 5fbab61fb..26e42cbc4 100644 --- a/source/reporters/ut_debug_reporter.tps +++ b/source/reporters/ut_debug_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_debug_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_debug_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_documentation_reporter.tpb b/source/reporters/ut_documentation_reporter.tpb index 7210e1cb6..ad3d1fb69 100644 --- a/source/reporters/ut_documentation_reporter.tpb +++ b/source/reporters/ut_documentation_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_documentation_reporter is +create or replace noneditionable type body ut_documentation_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -68,7 +68,11 @@ create or replace type body ut_documentation_reporter is l_message := coalesce(a_test.description, a_test.name)||' ['||round(a_test.execution_time,3)||' sec]'; --if test failed, then add it to the failures list, print failure with number if a_test.result = ut_utils.gc_disabled then - self.print_yellow_text(l_message || ' (DISABLED)'); + self.print_yellow_text(l_message || ' (DISABLED'|| + case when a_test.disabled_reason is not null + then ' - '||a_test.disabled_reason + else null + end || ')'); elsif a_test.result = ut_utils.gc_success then self.print_green_text(l_message); elsif a_test.result > ut_utils.gc_success then @@ -198,7 +202,7 @@ create or replace type body ut_documentation_reporter is begin print_failures_details(a_run); print_warnings(a_run); - self.print_text('Finished in ' || a_run.execution_time || ' seconds'); + self.print_text('Finished in ' || ut_utils.interval_to_text(numtodsinterval(a_run.execution_time,'second')) ); l_summary_text := a_run.results_count.total_count || ' tests, ' @@ -212,13 +216,16 @@ create or replace type body ut_documentation_reporter is if a_run.random_test_order_seed is not null then self.print_text('Tests were executed with random order seed '''||a_run.random_test_order_seed||'''.'); end if; + if a_run.get_support_info_flag() then + self.print_cyan_text(ut_utils.gc_support_text || ': ' || ut_utils.gc_support_url); + end if; self.print_text(' '); (self as ut_reporter_base).after_calling_run(a_run); end; overriding member function get_description return varchar2 as begin - return 'A textual pretty-print of unit test results (usually use for console output)'; + return 'Creates a textual, pretty-print, human-readable report mirroring the suite hierarchy. Used for console runs, interactive development and log review.'; end; end; diff --git a/source/reporters/ut_documentation_reporter.tps b/source/reporters/ut_documentation_reporter.tps index 08097e7d4..52a7911ce 100644 --- a/source/reporters/ut_documentation_reporter.tps +++ b/source/reporters/ut_documentation_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_documentation_reporter under ut_console_reporter_base( +create or replace noneditionable type ut_documentation_reporter under ut_console_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb index aa6786f6f..e7741926d 100644 --- a/source/reporters/ut_junit_reporter.tpb +++ b/source/reporters/ut_junit_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_junit_reporter is +create or replace noneditionable type body ut_junit_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,7 +18,7 @@ create or replace type body ut_junit_reporter is constructor function ut_junit_reporter(self in out nocopy ut_junit_reporter) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_bulk_buffer()); return; end; @@ -44,7 +44,13 @@ create or replace type body ut_junit_reporter is ' status="' || ut_utils.test_result_to_char(a_test.result) || '"' end || '>' ); if a_test.result = ut_utils.gc_disabled then - ut_utils.append_to_list( l_results, '' ); + if a_test.disabled_reason is not null then + ut_utils.append_to_list( l_results, '' ); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.disabled_reason ) ); + ut_utils.append_to_list( l_results, '' ); + else + ut_utils.append_to_list( l_results, '' ); + end if; end if; if a_test.result = ut_utils.gc_error then ut_utils.append_to_list( l_results, ''); diff --git a/source/reporters/ut_junit_reporter.tps b/source/reporters/ut_junit_reporter.tps index ca6cf505b..88292acbb 100644 --- a/source/reporters/ut_junit_reporter.tps +++ b/source/reporters/ut_junit_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_junit_reporter force under ut_output_reporter_base( +create or replace noneditionable type ut_junit_reporter force under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_realtime_reporter.tpb b/source/reporters/ut_realtime_reporter.tpb index 64eb343e5..b0ec5d2e2 100644 --- a/source/reporters/ut_realtime_reporter.tpb +++ b/source/reporters/ut_realtime_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_realtime_reporter is +create or replace noneditionable type body ut_realtime_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -43,6 +43,7 @@ create or replace type body ut_realtime_reporter is self.print_node('objectName', a_test.item.object_name); self.print_node('procedureName', a_test.item.procedure_name); self.print_node('disabled', case when a_test.get_disabled_flag() then 'true' else 'false' end); + self.print_node('disabledReason', a_test.disabled_reason); self.print_node('name', a_test.name); self.print_node('description', a_test.description); self.print_node('testNumber', to_char(total_number_of_tests)); @@ -203,11 +204,6 @@ create or replace type body ut_realtime_reporter is self.flush_print_buffer('post-test'); end after_calling_test; - overriding member function get_description return varchar2 is - begin - return 'Provides test results in a XML format, for clients such as SQL Developer interested in showing progressing details.'; - end get_description; - member procedure print_start_node( self in out nocopy ut_realtime_reporter, a_node_name in varchar2, @@ -252,7 +248,7 @@ create or replace type body ut_realtime_reporter is ) is begin if a_content is not null then - self.print_xml_fragment('<' || a_name || '>'); + self.print_xml_fragment('<' || a_name || '>' || ut_utils.to_cdata(a_content) || ''); end if; end print_cdata_node; @@ -283,5 +279,10 @@ create or replace type body ut_realtime_reporter is print_buffer.delete; end flush_print_buffer; + overriding member function get_description return varchar2 is + begin + return 'Provides live test execution progress that can be consumed from another session, enabling clients such as SQL Developer to show progress in real time as tests run.'; + end get_description; + end; / diff --git a/source/reporters/ut_realtime_reporter.tps b/source/reporters/ut_realtime_reporter.tps index 99efed387..7efdd1bb3 100644 --- a/source/reporters/ut_realtime_reporter.tps +++ b/source/reporters/ut_realtime_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_realtime_reporter force under ut_output_reporter_base( +create or replace noneditionable type ut_realtime_reporter force under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb index 6d76b5d41..6b8003ecb 100644 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ b/source/reporters/ut_sonar_test_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_sonar_test_reporter is +create or replace noneditionable type body ut_sonar_test_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,7 +20,7 @@ create or replace type body ut_sonar_test_reporter is self in out nocopy ut_sonar_test_reporter ) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_bulk_buffer()); return; end; @@ -47,7 +47,7 @@ create or replace type body ut_sonar_test_reporter is begin ut_utils.append_to_list( l_results, ''); if a_test.result = ut_utils.gc_disabled then - ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ''); elsif a_test.result = ut_utils.gc_error then ut_utils.append_to_list( l_results, ''); ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) ); @@ -106,9 +106,9 @@ create or replace type body ut_sonar_test_reporter is overriding member function get_description return varchar2 as begin - return 'Generates a JSON report providing detailed information on test execution.' || chr(10) || - 'Designed for [SonarQube](https://about.sonarqube.com/) to report test execution.' || chr(10) || - 'JSON format returned conforms with the Sonar specification: https://docs.sonarqube.org/display/SONAR/Generic+Test+Data'; + return 'Generates an XML report providing detailed information on test execution. +Designed for [SonarQube](https://www.sonarsource.com/products/sonarqube/) to report test execution. +XML format returned conforms with the [Sonar specification](https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/test-coverage/generic-test-data).'; end; end; diff --git a/source/reporters/ut_sonar_test_reporter.tps b/source/reporters/ut_sonar_test_reporter.tps index 8bdb067df..f7f5aeb39 100644 --- a/source/reporters/ut_sonar_test_reporter.tps +++ b/source/reporters/ut_sonar_test_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_sonar_test_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_sonar_test_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_tap_reporter.tpb b/source/reporters/ut_tap_reporter.tpb new file mode 100644 index 000000000..e1b3b617d --- /dev/null +++ b/source/reporters/ut_tap_reporter.tpb @@ -0,0 +1,142 @@ +create or replace noneditionable type body ut_tap_reporter is + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_tap_reporter(self in out nocopy ut_tap_reporter) return self as result is + begin + self.init($$plsql_unit); + self.lvl := 0; + return; + end ut_tap_reporter; + + member procedure print_comment(self in out nocopy ut_tap_reporter, a_comment clob) as + begin + self.print_clob(regexp_replace(a_comment, '^(.+)', '# \1', 1, 0, 'm')); + end print_comment; + + member function escape_special_chars(self in out nocopy ut_tap_reporter, a_string_to_escape clob) return clob as + begin + return regexp_replace(a_string_to_escape, '([\\#])', '\\\1'); + end escape_special_chars; + + overriding member procedure before_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite) as + begin + self.print_text('# Subtest: ' || self.escape_special_chars(coalesce(a_suite.description, a_suite.name))); + lvl := lvl + 2; + self.print_text('1..' || a_suite.items.count); + end before_calling_suite; + + + overriding member procedure after_calling_test(self in out nocopy ut_tap_reporter, a_test ut_test) as + l_message varchar2(4000); + l_test_name varchar2(4000) := self.escape_special_chars(coalesce(a_test.description, a_test.name)); + + procedure print_failed_expectation(a_test ut_test) is + l_lines ut_varchar2_list; + l_failed boolean; + begin + if a_test.get_error_stack_traces().count = 0 then + -- If no error occurred, print failed expectation + l_lines := a_test.all_expectations(a_test.all_expectations.last).get_result_lines(); + l_failed := a_test.all_expectations(a_test.all_expectations.last).status >= ut_utils.gc_success; + if l_failed then + self.print_text('message: ''' || l_lines(1) || ''''); + self.print_text('severity: fail'); + end if; + else + -- Print multi-line YAML-String with implicit newline characters + self.print_text('message: |'); + self.lvl := self.lvl + 1; + self.print_text(ut_utils.table_to_clob(a_test.get_error_stack_traces())); + self.lvl := self.lvl - 1; + self.print_text('severity: error'); + end if; + end print_failed_expectation; + + begin + + if a_test.result = ut_utils.gc_disabled then + self.print_text('ok - ' || l_test_name || ' # SKIP'|| + case when a_test.disabled_reason is not null + then ': '|| self.escape_special_chars(a_test.disabled_reason) + else null + end ); + elsif a_test.result = ut_utils.gc_success then + self.print_text('ok - ' || l_test_name); + elsif a_test.result > ut_utils.gc_success then + if self.lvl = 0 then + self.print_text(ut_ansiconsole_helper.red('not ok') || ' - ' || l_test_name); + else + self.print_text('not ok - ' || l_test_name); + end if; + self.lvl := self.lvl + 1; + self.print_text('---'); + print_failed_expectation(a_test); + self.print_text('...'); + self.lvl := self.lvl - 1; + end if; + + self.print_comment(a_test.get_serveroutputs); + + end after_calling_test; + + overriding member procedure after_calling_before_all(self in out nocopy ut_tap_reporter, a_executable in ut_executable) is + begin + if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then + self.print_comment(a_executable.serveroutput); + end if; + end after_calling_before_all; + + overriding member procedure after_calling_after_all(self in out nocopy ut_tap_reporter, a_executable in ut_executable) is + begin + if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then + self.print_comment(a_executable.serveroutput); + end if; + end after_calling_after_all; + + overriding member procedure after_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite) as + l_suite_name varchar2(4000) := coalesce(a_suite.description, a_suite.name); + begin + lvl := lvl - 2; + if lvl = 0 then + if a_suite.result = ut_utils.gc_success or a_suite.result = ut_utils.gc_disabled then + self.print_text('ok - ' || self.escape_special_chars(l_suite_name)); + elsif a_suite.result > ut_utils.gc_success then + self.print_text(ut_ansiconsole_helper.red('not ok') || ' - ' || self.escape_special_chars(l_suite_name)); + end if; + + self.print_text(' '); + end if; + + end after_calling_suite; + + overriding member procedure before_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) as + begin + self.print_text('TAP version 14'); + self.print_text('1..' || a_run.items.count); + self.print_text(' '); + end before_calling_run; + + overriding member procedure after_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) as + begin + self.lvl := 0; + if a_run.get_support_info_flag() then + self.print_comment(ut_utils.gc_support_text || ': ' || ut_utils.gc_support_url); + end if; + end; +end; +/ diff --git a/source/reporters/ut_tap_reporter.tps b/source/reporters/ut_tap_reporter.tps new file mode 100644 index 000000000..127256cf8 --- /dev/null +++ b/source/reporters/ut_tap_reporter.tps @@ -0,0 +1,34 @@ +create or replace noneditionable type ut_tap_reporter under ut_documentation_reporter( + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_tap_reporter(self in out nocopy ut_tap_reporter) return self as result, + member procedure print_comment(self in out nocopy ut_tap_reporter, a_comment clob), + member function escape_special_chars(self in out nocopy ut_tap_reporter, a_string_to_escape clob) return clob, + overriding member procedure before_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite), + + overriding member procedure after_calling_test(self in out nocopy ut_tap_reporter, a_test ut_test), + + overriding member procedure after_calling_before_all (self in out nocopy ut_tap_reporter, a_executable in ut_executable), + overriding member procedure after_calling_after_all (self in out nocopy ut_tap_reporter, a_executable in ut_executable), + overriding member procedure before_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run), + overriding member procedure after_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite), + overriding member procedure after_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) + +) +not final +/ diff --git a/source/reporters/ut_teamcity_reporter.tpb b/source/reporters/ut_teamcity_reporter.tpb index ee0a53098..2e76e3e3f 100644 --- a/source/reporters/ut_teamcity_reporter.tpb +++ b/source/reporters/ut_teamcity_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_teamcity_reporter is +create or replace noneditionable type body ut_teamcity_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -74,7 +74,7 @@ create or replace type body ut_teamcity_reporter is begin l_idx := a_executables.first; while l_idx is not null loop - l_message := l_message || add_error_message(a_executables(l_idx).error_backtrace, a_message_name); + l_message := l_message || add_error_message( a_executables(l_idx).get_error_stack_trace(), a_message_name ); l_idx := a_executables.next(l_idx); end loop; return l_message; @@ -84,7 +84,7 @@ create or replace type body ut_teamcity_reporter is lower(a_test.item.procedure_name); if a_test.result = ut_utils.gc_disabled then - ut_utils.append_to_list( l_results, ut_teamcity_reporter_helper.test_disabled(l_test_full_name)); + ut_utils.append_to_list( l_results, ut_teamcity_reporter_helper.test_disabled(l_test_full_name,a_test.disabled_reason)); else ut_utils.append_to_list( l_results, a_test.get_serveroutputs()); @@ -92,7 +92,7 @@ create or replace type body ut_teamcity_reporter is if a_test.result = ut_utils.gc_error then l_std_err_msg := l_std_err_msg || add_error_messages(a_test.before_each_list, 'Before each exception:'); l_std_err_msg := l_std_err_msg || add_error_messages(a_test.before_test_list, 'Before test exception:'); - l_std_err_msg := l_std_err_msg || add_error_message(a_test.item.error_backtrace, 'Test exception:'); + l_std_err_msg := l_std_err_msg || add_error_message(a_test.item.get_error_stack_trace(), 'Test exception:'); l_std_err_msg := l_std_err_msg || add_error_messages(a_test.after_test_list, 'After test exception:'); l_std_err_msg := l_std_err_msg || add_error_messages(a_test.after_each_list, 'After each exception:'); @@ -108,23 +108,28 @@ create or replace type body ut_teamcity_reporter is ut_teamcity_reporter_helper.test_failed( a_test_name => l_test_full_name, a_msg => 'Error occured', - a_details => - trim(l_std_err_msg) - || case when a_test.failed_expectations is not null - and a_test.failed_expectations.count>0 - then a_test.failed_expectations(1).message end + a_details => trim(l_std_err_msg) ) ); + for i in 1 .. a_test.failed_expectations.count loop + ut_utils.append_to_list( + l_results, + ut_teamcity_reporter_helper.test_failed( + a_test_name => l_test_full_name, + a_msg => a_test.failed_expectations(i).description, + a_details => a_test.failed_expectations(i).message ) + ); + end loop; elsif a_test.failed_expectations is not null and a_test.failed_expectations.count > 0 then - -- Teamcity supports only a single failure message - - ut_utils.append_to_list( - l_results, - ut_teamcity_reporter_helper.test_failed( - a_test_name => l_test_full_name, - a_msg => a_test.failed_expectations(a_test.failed_expectations.first).description, - a_details => a_test.failed_expectations(a_test.failed_expectations.first).message ) - ); + for i in 1 .. a_test.failed_expectations.count loop + ut_utils.append_to_list( + l_results, + ut_teamcity_reporter_helper.test_failed( + a_test_name => l_test_full_name, + a_msg => a_test.failed_expectations(i).description, + a_details => a_test.failed_expectations(i).message ) + ); + end loop; elsif a_test.result = ut_utils.gc_failure then ut_utils.append_to_list( l_results, diff --git a/source/reporters/ut_teamcity_reporter.tps b/source/reporters/ut_teamcity_reporter.tps index 2738ec00e..e70ad4a4b 100644 --- a/source/reporters/ut_teamcity_reporter.tps +++ b/source/reporters/ut_teamcity_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_teamcity_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_teamcity_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_teamcity_reporter_helper.pkb b/source/reporters/ut_teamcity_reporter_helper.pkb index 2d165d7a3..ac9d4b567 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pkb +++ b/source/reporters/ut_teamcity_reporter_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_teamcity_reporter_helper is +create or replace noneditionable package body ut_teamcity_reporter_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -73,8 +73,6 @@ create or replace package body ut_teamcity_reporter_helper is 'true' when false then 'false' - else - null end; l_props('flowId') := a_flow_id; return message('testStarted', l_props); @@ -89,10 +87,13 @@ create or replace package body ut_teamcity_reporter_helper is return message('testFinished', l_props); end; - function test_disabled(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2 is + function test_disabled(a_test_name varchar2,a_msg varchar2 default null, a_flow_id varchar2 default null) return varchar2 is l_props t_props; begin l_props('name') := a_test_name; + if a_msg is not null then + l_props('message') := a_msg; + end if; l_props('flowId') := a_flow_id; return message('testIgnored', l_props); end; diff --git a/source/reporters/ut_teamcity_reporter_helper.pks b/source/reporters/ut_teamcity_reporter_helper.pks index 7258999e1..03c655c33 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pks +++ b/source/reporters/ut_teamcity_reporter_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_teamcity_reporter_helper is +create or replace noneditionable package ut_teamcity_reporter_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,7 +21,7 @@ create or replace package ut_teamcity_reporter_helper is function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2; function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2; - function test_disabled(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2; + function test_disabled(a_test_name varchar2,a_msg varchar2 default null, a_flow_id varchar2 default null) return varchar2; function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2; function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2; diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb index 5262ac687..38aa41bfa 100644 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ b/source/reporters/ut_tfs_junit_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_tfs_junit_reporter is +create or replace noneditionable type body ut_tfs_junit_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,7 +18,7 @@ create or replace type body ut_tfs_junit_reporter is constructor function ut_tfs_junit_reporter(self in out nocopy ut_tfs_junit_reporter) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_bulk_buffer()); return; end; @@ -51,11 +51,12 @@ create or replace type body ut_tfs_junit_reporter is return regexp_substr(a_path_with_name, '(.*)\.' ||a_name||'$',subexpression=>1); end; - procedure print_test_results(a_test ut_test) is + function add_test_results(a_test ut_test) return ut_varchar2_rows is l_results ut_varchar2_rows := ut_varchar2_rows(); begin - self.print_text(''); + /* According to specs : - A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. @@ -69,6 +70,12 @@ create or replace type body ut_tfs_junit_reporter is ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) ); ut_utils.append_to_list( l_results, ''); -- Do not count error as failure + elsif a_test.result = ut_utils.gc_disabled then + if a_test.disabled_reason is not null then + ut_utils.append_to_list( l_results, ''); + else + ut_utils.append_to_list( l_results, '' ); + end if; elsif a_test.result = ut_utils.gc_failure then ut_utils.append_to_list( l_results, ''); ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) ); @@ -77,73 +84,96 @@ create or replace type body ut_tfs_junit_reporter is ut_utils.append_to_list( l_results, ''); - self.print_text_lines(l_results); + return l_results; end; - procedure print_suite_results(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is + procedure print_suite_results(a_suite ut_logical_suite, a_suite_id in out nocopy integer, a_nested_tests in out nocopy ut_varchar2_rows) is l_tests_count integer := a_suite.results_count.disabled_count + a_suite.results_count.success_count + a_suite.results_count.failure_count + a_suite.results_count.errored_count; l_results ut_varchar2_rows := ut_varchar2_rows(); l_suite ut_suite; l_outputs clob; l_errors ut_varchar2_list; - begin - + l_tests ut_varchar2_list; + begin for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_logical_suite) then - print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_suite_id); + if a_suite.items(i) is of(ut_suite_context) then + print_suite_results(treat(a_suite.items(i) as ut_suite_context), a_suite_id, a_nested_tests); + elsif a_suite.items(i) is of(ut_suite) then + print_suite_results(treat(a_suite.items(i) as ut_suite), a_suite_id, a_nested_tests); + elsif a_suite.items(i) is of(ut_logical_suite) then + print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_suite_id, a_nested_tests); end if; end loop; - - if a_suite is of(ut_suite) then - a_suite_id := a_suite_id + 1; - self.print_text(''); - self.print_text(''); + --Due to fact tha TFS and junit5 accepts only flat structure we have to report in suite level only. + if a_suite is of(ut_suite_context) then for i in 1 .. a_suite.items.count loop if a_suite.items(i) is of(ut_test) then - print_test_results(treat(a_suite.items(i) as ut_test)); + ut_utils.append_to_list( a_nested_tests,(add_test_results(treat(a_suite.items(i) as ut_test)))); end if; end loop; - l_suite := treat(a_suite as ut_suite); - l_outputs := l_suite.get_serveroutputs(); - if l_outputs is not null and l_outputs != empty_clob() then - ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ut_utils.to_cdata( l_suite.get_serveroutputs() ) ); - ut_utils.append_to_list( l_results, ''); - else - ut_utils.append_to_list( l_results, ''); - end if; - - l_errors := l_suite.get_error_stack_traces(); - if l_errors is not empty then - ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( l_errors ) ) ); - ut_utils.append_to_list( l_results, ''); - else - ut_utils.append_to_list( l_results, ''); - end if; - ut_utils.append_to_list( l_results, ''); - - self.print_text_lines(l_results); + elsif a_suite is of(ut_suite) then + for i in 1 .. a_suite.items.count loop + if a_suite.items(i) is of(ut_test) then + ut_utils.append_to_list( a_nested_tests,(add_test_results(treat(a_suite.items(i) as ut_test)))); + end if; + end loop; + --TFS doesnt report on empty test suites, however all we want to make sure is that we dont pring parents suites + -- showing test count but not tests. + if (a_nested_tests.count > 0 and l_tests_count > 0) or (a_nested_tests.count = 0 and l_tests_count = 0) then + a_suite_id := a_suite_id + 1; + ut_utils.append_to_list( l_results,''); + ut_utils.append_to_list( l_results,''); + ut_utils.append_to_list(l_results,a_nested_tests); + l_suite := treat(a_suite as ut_suite); + l_outputs := l_suite.get_serveroutputs(); + if l_outputs is not null and l_outputs != empty_clob() then + ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( l_suite.get_serveroutputs() ) ); + ut_utils.append_to_list( l_results, ''); + else + ut_utils.append_to_list( l_results, ''); + end if; + + l_errors := l_suite.get_error_stack_traces(); + if l_errors is not empty then + ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( l_errors ) ) ); + ut_utils.append_to_list( l_results, ''); + else + ut_utils.append_to_list( l_results, ''); + end if; + ut_utils.append_to_list( l_results, ''); + + self.print_text_lines(l_results); + --We have resolved a context and we now reset value. + a_nested_tests := ut_varchar2_rows(); + end if; end if; end; + + procedure get_suite_results(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is + l_nested_tests ut_varchar2_rows:= ut_varchar2_rows(); + begin + print_suite_results(a_suite, l_suite_id,l_nested_tests); + end; begin l_suite_id := 0; self.print_text(ut_utils.get_xml_header(a_run.client_character_set)); self.print_text(''); for i in 1 .. a_run.items.count loop - print_suite_results(treat(a_run.items(i) as ut_logical_suite), l_suite_id); + get_suite_results(treat(a_run.items(i) as ut_logical_suite), l_suite_id); end loop; self.print_text(''); end; overriding member function get_description return varchar2 as begin - return 'Provides outcomes in a format conforming with JUnit version for TFS / VSTS. - As defined by specs :https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts - Version is based on windy road junit https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd.'; + return 'Provides outcomes in a format conforming with JUnit version for TFS / VSTS +as defined by [specification](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-test-results-v2?view=azure-pipelines) +The implementation is based on [windyroad junit schema](https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd).'; end; end; diff --git a/source/reporters/ut_tfs_junit_reporter.tps b/source/reporters/ut_tfs_junit_reporter.tps index ecf422bd3..3212085ea 100644 --- a/source/reporters/ut_tfs_junit_reporter.tps +++ b/source/reporters/ut_tfs_junit_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_tfs_junit_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_tfs_junit_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_xunit_reporter.tpb b/source/reporters/ut_xunit_reporter.tpb index b06c20810..4b6007994 100644 --- a/source/reporters/ut_xunit_reporter.tpb +++ b/source/reporters/ut_xunit_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_xunit_reporter is +create or replace noneditionable type body ut_xunit_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,7 +18,7 @@ create or replace type body ut_xunit_reporter is constructor function ut_xunit_reporter(self in out nocopy ut_xunit_reporter) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_bulk_buffer()); return; end; diff --git a/source/reporters/ut_xunit_reporter.tps b/source/reporters/ut_xunit_reporter.tps index b09205171..2e7a84f95 100644 --- a/source/reporters/ut_xunit_reporter.tps +++ b/source/reporters/ut_xunit_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_xunit_reporter under ut_junit_reporter( +create or replace noneditionable type ut_xunit_reporter under ut_junit_reporter( /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/set_install_params.sql b/source/set_install_params.sql index 4dc33c367..1d58ab09a 100644 --- a/source/set_install_params.sql +++ b/source/set_install_params.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/uninstall.sql b/source/uninstall.sql index 760bf89b7..ba1582844 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/uninstall_all.sql b/source/uninstall_all.sql index 32180d762..af94716c1 100644 --- a/source/uninstall_all.sql +++ b/source/uninstall_all.sql @@ -1,9 +1,9 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/uninstall_coverage_tables.sql b/source/uninstall_coverage_tables.sql index 8de75b51e..6912330ae 100644 --- a/source/uninstall_coverage_tables.sql +++ b/source/uninstall_coverage_tables.sql @@ -1,3 +1,20 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + set echo off set feedback off begin @@ -11,7 +28,7 @@ begin and owner = sys_context( 'USERENV', 'CURRENT_SCHEMA' ) ) loop - execute immediate 'drop table '||to_be_dopped.table_name||' cascade constraints'; + execute immediate 'drop table '||to_be_dopped.table_name||' cascade constraints purge'; dbms_output.put_line('Table '||to_be_dopped.table_name||' dropped'); end loop; end; diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql index c905153f4..5c6e41dc3 100644 --- a/source/uninstall_objects.sql +++ b/source/uninstall_objects.sql @@ -1,5 +1,21 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + set echo off -set serverout on declare procedure drop_if_exists(a_object_type varchar2, a_object_name varchar2) is l_count integer; @@ -54,7 +70,9 @@ drop synonym be_true; drop synonym equal; -drop type ut_coveralls_reporter force; +drop synonym be_within; + +drop synonym be_within_pct; drop type ut_coverage_sonar_reporter force; @@ -74,6 +92,8 @@ drop package ut_coverage_helper; drop table ut_coverage_sources_tmp purge; +drop table ut_coverage_runs purge; + drop package ut_teamcity_reporter_helper; drop package ut_runner; @@ -82,12 +102,20 @@ drop type ut_suite_items_info force; drop type ut_suite_item_info force; +drop type ut_path_items force; + +drop type ut_path_item force; + drop package ut_suite_manager; drop package ut_suite_builder; +drop package ut_suite_tag_filter; + drop package ut_suite_cache_manager; +drop package ut_suite_cache_macros; + drop table ut_suite_cache purge; drop type ut_suite_cache_rows force; @@ -140,10 +168,20 @@ drop type ut_be_less_than force; drop type ut_be_false force; +drop type ut_be_within_pct force; + +drop type ut_be_within force; + +drop package ut_be_within_helper; + drop type ut_comparison_matcher force; drop type ut_matcher force; +drop type ut_expectation_base force; + +drop type ut_matcher_base force; + drop type ut_data_value_yminterval force; drop type ut_data_value_varchar2 force; @@ -196,7 +234,7 @@ drop table ut_compound_data_tmp purge; drop table ut_compound_data_diff_tmp purge; -drop table ut_json_data_diff_tmp; +drop table ut_json_data_diff_tmp purge; drop package ut_annotation_manager; @@ -204,6 +242,8 @@ drop package ut_annotation_parser; drop package ut_annotation_cache_manager; +drop package ut_annotation_cache_macros; + drop table ut_annotation_cache cascade constraints purge; drop table ut_annotation_cache_info cascade constraints purge; @@ -233,18 +273,21 @@ drop package ut_metadata; drop package ut_ansiconsole_helper; begin - $if dbms_db_version.version = 12 and dbms_db_version.release = 1 or dbms_db_version.version < 12 $then - execute immediate 'drop type json_element_t force'; - $else - dbms_output.put_line('Nothing to drop'); + null; + $if dbms_db_version.version < 21 $then + begin execute immediate 'drop type json force'; exception when others then null; end; $end end; / drop package ut_utils; +drop type ut_stack force; + drop sequence ut_savepoint_seq; +drop type ut_tap_reporter force; + drop type ut_documentation_reporter force; drop type ut_debug_reporter force; @@ -299,12 +342,18 @@ drop type ut_output_table_buffer force; drop type ut_output_clob_table_buffer force; +drop type ut_output_bulk_buffer force; + drop type ut_output_buffer_base force; drop table ut_output_buffer_tmp purge; +drop sequence ut_output_buffer_tmp_seq; + drop table ut_output_clob_buffer_tmp purge; +drop sequence ut_output_clob_buffer_tmp_seq; + drop table ut_output_buffer_info_tmp purge; drop package ut_session_context; @@ -366,7 +415,7 @@ set feedback off declare i integer := 0; begin - dbms_output.put_line('Dropping packages created for 12.2+ ' || upper('&&ut3_owner')); + dbms_output.put_line('Dropping block coverage packages ' || upper('&&ut3_owner')); for pkg in ( select object_name, owner from all_objects @@ -393,3 +442,15 @@ begin dbms_output.put_line(i || ' packages dropped'); end; / + +declare + e_role_not_exists exception; + pragma exception_init(e_role_not_exists, -1919); +begin + execute immediate 'drop role &&ut3_owner._cbac_modify_objects_role'; + dbms_output.put_line('Role ' || upper('&&ut3_owner._cbac_modify_objects_role') || ' dropped'); +exception + when e_role_not_exists then + dbms_output.put_line('Role ' || upper('&&ut3_owner._cbac_modify_objects_role') || ' does not exist'); +end; +/ diff --git a/source/uninstall_synonyms.sql b/source/uninstall_synonyms.sql index 569e5057d..783ac51e8 100644 --- a/source/uninstall_synonyms.sql +++ b/source/uninstall_synonyms.sql @@ -1,3 +1,20 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + set echo off set feedback off declare @@ -15,10 +32,10 @@ begin and not exists (select 1 from all_objects o where o.owner = s.table_owner and o.object_name = s.table_name) ) loop - i := i + 1; begin execute immediate 'drop '||syn.syn_name; dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); + i := i + 1; exception when others then dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); @@ -32,7 +49,7 @@ end; declare i integer := 0; begin - dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects on 12.2 ' || upper('&&ut3_owner')); + dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects ' || upper('&&ut3_owner')); for syn in ( select case when owner = 'PUBLIC' then 'public synonym ' diff --git a/source/ut3_cbac_modify_objects_role_grants.sql b/source/ut3_cbac_modify_objects_role_grants.sql new file mode 100644 index 000000000..b8748c46a --- /dev/null +++ b/source/ut3_cbac_modify_objects_role_grants.sql @@ -0,0 +1,62 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Code based access control for the invoker rights packages ut_annotation_cache_manager, ut_annotation_manager, + ut_suite_cache_manager and ut_suite_manager. + The packages access the annotation and suite cache tables through the role _cbac_modify_objects_role, + directly or through the SQL macros of ut_annotation_cache_macros and ut_suite_cache_macros, + so the users calling the framework do not need any privileges on those tables. + The types and packages used in SQL statements of those packages are granted to the role too, + so they do not need to be granted to the users calling the framework. +*/ + +prompt Granting privileges to role &&ut3_owner._cbac_modify_objects_role + +--annotation cache +grant select, insert, update, delete on &&ut3_owner..ut_annotation_cache to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_annotation_cache_info to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_annotation_cache_schema to &&ut3_owner._cbac_modify_objects_role; +grant select on &&ut3_owner..ut_annotation_cache_seq to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotated_object to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotation to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotations to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotation_cache_macros to &&ut3_owner._cbac_modify_objects_role; + +--suite cache +grant select, insert, update, delete on &&ut3_owner..ut_suite_cache to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_suite_cache_package to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_suite_cache_schema to &&ut3_owner._cbac_modify_objects_role; +grant select on &&ut3_owner..ut_suite_cache_seq to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_cache_row to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_item_info to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_test to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_executables to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_executable_test to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_varchar2_rows to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_integer_list to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_path_item to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_object_name to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_utils to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_tag_filter to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_cache_macros to &&ut3_owner._cbac_modify_objects_role; + +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_annotation_cache_manager; +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_annotation_manager; +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_suite_cache_manager; +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_suite_manager; + diff --git a/test/install_above_12_1.sql b/test/install_above_12_1.sql deleted file mode 100644 index fe20cf816..000000000 --- a/test/install_above_12_1.sql +++ /dev/null @@ -1,28 +0,0 @@ -set termout off -set echo off -spool dummy.sql -prompt whenever sqlerror exit failure rollback -spool off - - -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release >= 2 - or dbms_db_version.version > 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - - -@@&&SCRIPT_NAME - diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh index 04f51fb3c..24932d663 100755 --- a/test/install_and_run_tests.sh +++ b/test/install_and_run_tests.sh @@ -1,9 +1,11 @@ #!/bin/bash -set -ev +set -e #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" +. ./development/env.sh +set -v cd test -time . ./${DIR}/install_tests.sh -time . ./${DIR}/run_tests.sh +time . ./install_tests.sh +time . ./run_tests.sh diff --git a/test/install_below_12_2.sql b/test/install_below_12_2.sql deleted file mode 100644 index 669ae75fc..000000000 --- a/test/install_below_12_2.sql +++ /dev/null @@ -1,28 +0,0 @@ -set termout off -set echo off -spool dummy.sql -prompt whenever sqlerror exit failure rollback -spool off - - -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release < 2 - or dbms_db_version.version < 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - - -@@&&SCRIPT_NAME - diff --git a/test/install_tests.sh b/test/install_tests.sh index e07b4d2b3..1b97ec33d 100755 --- a/test/install_tests.sh +++ b/test/install_tests.sh @@ -1,13 +1,13 @@ #!/bin/bash set -ev -#goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" -cd test +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd ${SCRIPT_DIR} -"$SQLCLI" ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_helper.sql -"$SQLCLI" ${UT3_USER}/${UT3_USER_PASSWORD}@//${CONNECTION_STR} @install_ut3_user_tests.sql +"$SQLCLI" UT3_TESTER_HELPER/ut3@//${CONNECTION_STR} @install_ut3_tester_helper.sql -"$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_tests.sql +"$SQLCLI" UT3_USER/ut3@//${CONNECTION_STR} @install_ut3_user_tests.sql + +"$SQLCLI" UT3_TESTER/ut3@//${CONNECTION_STR} @install_ut3_tester_tests.sql diff --git a/test/install_ut3_tester_helper.sql b/test/install_ut3_tester_helper.sql index c6244fd39..b78221627 100644 --- a/test/install_ut3_tester_helper.sql +++ b/test/install_ut3_tester_helper.sql @@ -6,9 +6,15 @@ alter session set plsql_optimize_level=0; --Install ut3_tester_helper @@ut3_tester_helper/test_dummy_object.tps @@ut3_tester_helper/other_dummy_object.tps +@@ut3_tester_helper/test_dummy_nested_object.tps +@@ut3_tester_helper/test_dummy_double_nested_object.tps @@ut3_tester_helper/test_dummy_object_list.tps +@@ut3_tester_helper/test_dummy_nested_object_list.tps +@@ut3_tester_helper/test_dummy_double_nested_list.tps +@@ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps @@ut3_tester_helper/test_tab_varchar2.tps @@ut3_tester_helper/test_tab_varray.tps +@@ut3_tester_helper/test_nested_tab_varray.tps @@ut3_tester_helper/test_dummy_number.tps @@ut3_tester_helper/ut_test_table.sql @@ut3_tester_helper/test_event_object.tps @@ -26,6 +32,11 @@ alter session set plsql_optimize_level=0; @@ut3_tester_helper/expectations_helper.pkb @@ut3_tester_helper/ut_example_tests.pkb +@@ut3_tester_helper/annotation_cache_helper.pks +@@ut3_tester_helper/annotation_cache_helper.pkb +create or replace synonym ut3_tester.annotation_cache_helper for ut3_tester_helper.annotation_cache_helper; +create or replace synonym ut3_user.coverage_helper for ut3_tester_helper.coverage_helper; + set linesize 200 set define on set verify off diff --git a/test/install_ut3_tester_tests.sql b/test/install_ut3_tester_tests.sql index 6b3a5356c..fa1331e00 100644 --- a/test/install_ut3_tester_tests.sql +++ b/test/install_ut3_tester_tests.sql @@ -13,8 +13,11 @@ alter session set plsql_optimize_level=0; @@ut3_tester/core/annotations/test_annotation_parser.pks @@ut3_tester/core/annotations/test_annot_throws_exception.pks @@ut3_tester/core/annotations/test_annotation_manager.pks +@@ut3_tester/core/annotations/test_annotation_cache.pks +@@ut3_tester/core/annotations/test_annot_disabled_reason.pks @@ut3_tester/core/expectations/test_expectation_processor.pks @@ut3_tester/core/test_ut_utils.pks +@@ut3_tester/core/test_ut_suite_tag_filter.pks @@ut3_tester/core/test_ut_test.pks @@ut3_tester/core/test_ut_suite.pks @@ut3_tester/core/test_ut_executable.pks @@ -22,15 +25,20 @@ alter session set plsql_optimize_level=0; @@ut3_tester/core/test_file_mapper.pks @@ut3_tester/core/test_output_buffer.pks @@ut3_tester/core/test_suite_builder.pks +@@ut3_tester/core/test_ut_metadata.pks +@@ut3_tester/core/test_coverage_report_html_helper.pks @@ut3_tester/core.pkb @@ut3_tester/core/annotations/test_before_after_annotations.pkb @@ut3_tester/core/annotations/test_annotation_parser.pkb -@@ut3_tester/core/expectations/test_expectation_processor.pkb @@ut3_tester/core/annotations/test_annotation_manager.pkb @@ut3_tester/core/annotations/test_annot_throws_exception.pkb +@@ut3_tester/core/annotations/test_annotation_cache.pkb +@@ut3_tester/core/annotations/test_annot_disabled_reason.pkb +@@ut3_tester/core/expectations/test_expectation_processor.pkb @@ut3_tester/core/test_ut_utils.pkb +@@ut3_tester/core/test_ut_suite_tag_filter.pkb @@ut3_tester/core/test_ut_test.pkb @@ut3_tester/core/test_ut_suite.pkb @@ut3_tester/core/test_ut_executable.pkb @@ -38,6 +46,8 @@ alter session set plsql_optimize_level=0; @@ut3_tester/core/test_file_mapper.pkb @@ut3_tester/core/test_output_buffer.pkb @@ut3_tester/core/test_suite_builder.pkb +@@ut3_tester/core/test_ut_metadata.pkb +@@ut3_tester/core/test_coverage_report_html_helper.pkb diff --git a/test/install_ut3_user_tests.sql b/test/install_ut3_user_tests.sql index 05f2634e8..36966b3f6 100644 --- a/test/install_ut3_user_tests.sql +++ b/test/install_ut3_user_tests.sql @@ -25,12 +25,12 @@ prompt Install user tests @@ut3_user/expectations/binary/test_be_less_or_equal.pks @@ut3_user/expectations/binary/test_be_greater_or_equal.pks @@ut3_user/expectations/binary/test_be_greater_than.pks +@@ut3_user/expectations/binary/test_to_be_within.pks +@@ut3_user/expectations/binary/test_to_be_within_pct.pks @@ut3_user/expectations/test_matchers.pks @@ut3_user/expectations/test_expectation_anydata.pks @@ut3_user/expectations/test_expectations_cursor.pks -set define on -@@install_above_12_1.sql 'ut3_user/expectations/test_expectations_json.pks' -set define off +@@ut3_user/expectations/test_expectations_json.pks @@ut3_user/api/test_ut_runner.pks @@ut3_user/api/test_ut_run.pks @@ut3_user/reporters.pks @@ -41,17 +41,17 @@ set define off @@ut3_user/reporters/test_documentation_reporter.pks @@ut3_user/reporters/test_debug_reporter.pks @@ut3_user/reporters/test_realtime_reporter.pks +@@ut3_user/reporters/test_tap_reporter.pks @@ut3_user/reporters/test_coverage.pks +@@ut3_user/reporters/test_coverage/test_coverage_standalone.pks set define on -@@install_above_12_1.sql 'ut3_user/reporters/test_extended_coverage.pks' -@@install_above_12_1.sql 'ut3_user/reporters/test_coverage/test_html_extended_reporter.pks' +@@ut3_user/reporters/test_coverage/test_extended_coverage.pks +@@ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks set define off -@@ut3_user/reporters/test_coverage/test_coveralls_reporter.pks @@ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks @@ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks set define on -@@install_below_12_2.sql 'ut3_user/reporters/test_proftab_coverage.pks' -@@install_below_12_2.sql 'ut3_user/reporters/test_coverage/test_html_proftab_reporter.pks' +@@ut3_user/reporters/test_coverage/test_proftab_coverage.pks set define off @@ut3_user/test_user.pkb @@ -66,12 +66,12 @@ set define off @@ut3_user/expectations/binary/test_be_less_or_equal.pkb @@ut3_user/expectations/binary/test_be_greater_or_equal.pkb @@ut3_user/expectations/binary/test_be_greater_than.pkb +@@ut3_user/expectations/binary/test_to_be_within.pkb +@@ut3_user/expectations/binary/test_to_be_within_pct.pkb @@ut3_user/expectations/test_matchers.pkb @@ut3_user/expectations/test_expectation_anydata.pkb @@ut3_user/expectations/test_expectations_cursor.pkb -set define on -@@install_above_12_1.sql 'ut3_user/expectations/test_expectations_json.pkb' -set define off +@@ut3_user/expectations/test_expectations_json.pkb @@ut3_user/api/test_ut_runner.pkb @@ut3_user/api/test_ut_run.pkb @@ut3_user/reporters.pkb @@ -82,17 +82,16 @@ set define off @@ut3_user/reporters/test_documentation_reporter.pkb @@ut3_user/reporters/test_debug_reporter.pkb @@ut3_user/reporters/test_realtime_reporter.pkb -@@ut3_user/reporters/test_coverage.pkb +@@ut3_user/reporters/test_tap_reporter.pkb +@@ut3_user/reporters/test_coverage/test_coverage_standalone.pkb set define on -@@install_above_12_1.sql 'ut3_user/reporters/test_extended_coverage.pkb' -@@install_above_12_1.sql 'ut3_user/reporters/test_coverage/test_html_extended_reporter.pkb' +@@ut3_user/reporters/test_coverage/test_extended_coverage.pkb +@@ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb set define off -@@ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb @@ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb @@ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb set define on -@@install_below_12_2.sql 'ut3_user/reporters/test_proftab_coverage.pkb' -@@install_below_12_2.sql 'ut3_user/reporters/test_coverage/test_html_proftab_reporter.pkb' +@@ut3_user/reporters/test_coverage/test_proftab_coverage.pkb set define off diff --git a/test/run_tests.sh b/test/run_tests.sh index 29086f5f7..1a6970283 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -2,16 +2,21 @@ set -ev #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" -time utPLSQL-cli/bin/utplsql run ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@${CONNECTION_STR} \ --source_path=source -owner=ut3 \ --p='ut3_tester,ut3$user#' \ +export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 + +time utPLSQL-cli/bin/utplsql run UT3_TESTER_HELPER/ut3@//${CONNECTION_STR} -D \ +-source_path=source -owner=ut3_develop \ +-p='ut3_tester,ut3_user' \ -test_path=test -c \ + -regex_expression="test/(\w+)(/(\w+))*/(\w+)\.(.{3})$" \ + -owner_subexpression=1 \ + -type_subexpression=5 \ + -name_subexpression=4 \ -f=ut_coverage_sonar_reporter -o=coverage.xml \ -f=ut_coverage_cobertura_reporter -o=cobertura.xml \ -f=ut_coverage_html_reporter -o=coverage.html \ --f=ut_coveralls_reporter -o=coverage.json \ -f=ut_sonar_test_reporter -o=test_results.xml \ -f=ut_junit_reporter -o=junit_test_results.xml \ -f=ut_tfs_junit_reporter -o=tfs_test_results.xml \ diff --git a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb new file mode 100644 index 000000000..7f1e068a8 --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb @@ -0,0 +1,484 @@ +create or replace package body test_annot_disabled_reason +is + + + procedure compile_dummy_packages is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_package_1 is + + --%suite + --%displayname(disable_test_suite_level) + --%suitepath(tests) + --%rollback(manual) + + --%disabled( Tests are disabled on suite level ) + + --%context( First context ) + + --%test(Test1 from test package 1) + procedure test1; + + --%test(Test2 from test package 1) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%test(Test3 from test package 1) + procedure test3; + + --%test(Test4 from test package 1) + procedure test4; + + --%endcontext + +end test_package_1;]'; + + execute immediate q'[create or replace package body test_package_1 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_1;]'; + + execute immediate q'[create or replace package test_package_2 is + + --%suite + --%displayname(Disable on context level) + --%suitepath(tests) + --%rollback(manual) + + --%context( First context ) + + --%disabled( Tests and disabled on first context level ) + + --%test(Test1 from test package 2) + procedure test1; + + --%test(Test2 from test package 2) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%test(Test3 from test package 2) + procedure test3; + + --%test(Test4 from test package 3) + procedure test4; + + --%endcontext + +end test_package_2;]'; + + execute immediate q'[create or replace package body test_package_2 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_2;]'; + + execute immediate q'[create or replace package testing_package_3 is + + --%suite + --%displayname(Disable tests on test level) + --%suitepath(tests) + --%rollback(manual) + + --%context( First context ) + + --%test(Test1 from test package 3) + --%disabled( Test1 disabled from first context ) + procedure test1; + + --%test(Test2 from test package 3) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%test(Test3 from test package 3) + procedure test3; + + --%test(Test4 from test package 3) + --%disabled( Test4 disabled from second context ) + procedure test4; + + --%endcontext + +end testing_package_3;]'; + + execute immediate q'[create or replace package body testing_package_3 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end testing_package_3;]'; + + execute immediate q'[create or replace package test_package_4 is + + --%suite + --%displayname(Disable reason is very long or have special characters) + --%suitepath(tests) + --%rollback(manual) + + + --%test(Test1 from test package 4) + --%disabled( $#?!%*&-/\^ ) + procedure test1; + + --%test(Test2 from test package 4) + --%disabled(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) + procedure test2; + +end test_package_4;]'; + + execute immediate q'[create or replace package body test_package_4 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_4;]'; + + execute immediate q'[create or replace package test_package_5 is + + --%suite + --%displayname(Disable tests on suite level overriding rest) + --%suitepath(tests) + --%rollback(manual) + + --%disabled( Disable on suite level ) + + --%context( First context ) + + --%disabled( Disable on 1st context level ) + + --%test(Test1 from test package 3) + --%disabled( Disable on 1st test level ) + procedure test1; + + --%test(Test2 from test package 3) + --%disabled( Disable on 2nd test level ) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%disabled( Disable on 2nd context level ) + + --%test(Test3 from test package 3) + --%disabled( Disable on 3rd test level ) + procedure test3; + + --%test(Test4 from test package 3) + --%disabled( Disable on 4th test level ) + procedure test4; + + --%endcontext + +end test_package_5;]'; + + execute immediate q'[create or replace package body test_package_5 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_5;]'; + + execute immediate q'[create or replace package test_package_6 is + + --%suite + --%displayname(Disable tests on each of ctx level overriding rest) + --%suitepath(tests) + --%rollback(manual) + + --%context( First context ) + + --%disabled( Disable on 1st context level ) + + --%test(Test1 from test package 3) + --%disabled( Disable on 1st test level ) + procedure test1; + + --%test(Test2 from test package 3) + --%disabled( Disable on 2nd test level ) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%disabled( Disable on 2nd context level ) + + --%test(Test3 from test package 3) + --%disabled( Disable on 3rd test level ) + procedure test3; + + --%test(Test4 from test package 3) + --%disabled( Disable on 4th test level ) + procedure test4; + + --%endcontext + +end test_package_6;]'; + + execute immediate q'[create or replace package body test_package_6 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_6;]'; + + end; + + + procedure drop_dummy_packages is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_package_1'; + execute immediate 'drop package test_package_2'; + execute immediate 'drop package testing_package_3'; + execute immediate 'drop package test_package_4'; + execute immediate 'drop package test_package_5'; + execute immediate 'drop package test_package_6'; + end; + + procedure test_disable_on_suite_level is + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Act + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%disable_test_suite_level +%First context +%Test1 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) +%Test2 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) +%Second context +%Test3 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) +%Test4 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level)%]'; + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure test_dis_on_1st_ctx_level is + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Act + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable on context level +%First context +%Test1 from test package 2 [0 sec] (DISABLED - Tests and disabled on first context level) +%Test2 from test package 2 [0 sec] (DISABLED - Tests and disabled on first context level) +%Second context +%Test3 from test package 2 [% sec] +%Test4 from test package 3 [% sec]%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure test_disable_tests_level is + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Act + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.testing_package_3'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable tests on test level +%First context +%Test1 from test package 3 [0 sec] (DISABLED - Test1 disabled from first context) +%Test2 from test package 3 [% sec] +%Second context +%Test3 from test package 3 [% sec] +%Test4 from test package 3 [0 sec] (DISABLED - Test4 disabled from second context)%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); + + + end; + + procedure test_long_text_spec_chr is + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Act + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_4'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable reason is very long or have special characters +%Test1 from test package 4 [0 sec] (DISABLED - $#?!%*&-/\^) +%Test2 from test package 4 [0 sec] (DISABLED - verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext)%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure test_disable_suite_ctx_tst is + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Act + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_5'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable tests on suite level overriding rest +%First context +%Test1 from test package 3 [0 sec] (DISABLED - Disable on suite level) +%Test2 from test package 3 [0 sec] (DISABLED - Disable on suite level) +%Second context +%Test3 from test package 3 [0 sec] (DISABLED - Disable on suite level) +%Test4 from test package 3 [0 sec] (DISABLED - Disable on suite level)%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); + + + end; + + procedure test_disable_ctx_tst is + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Act + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_6'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable tests on each of ctx level overriding rest +%First context +%Test1 from test package 3 [0 sec] (DISABLED - Disable on 1st context level) +%Test2 from test package 3 [0 sec] (DISABLED - Disable on 1st context level) +%Second context +%Test3 from test package 3 [0 sec] (DISABLED - Disable on 2nd context level) +%Test4 from test package 3 [0 sec] (DISABLED - Disable on 2nd context level)%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + +end; +/ diff --git a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks new file mode 100644 index 000000000..cae5da1ee --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks @@ -0,0 +1,31 @@ +create or replace package test_annot_disabled_reason +is + --%suite(annotations - disabled) + --%suitepath(utplsql.ut3_tester.core.annotations) + + --%beforeall + procedure compile_dummy_packages; + + --%afterall + procedure drop_dummy_packages; + + --%test(Disable all tests under the suite displaying suite level reason) + procedure test_disable_on_suite_level; + + --%test(Disable all tests under one of two contexts displaying context level reason) + procedure test_dis_on_1st_ctx_level; + + --%test(Disable a single tests from each of the contexts displaying test level reason) + procedure test_disable_tests_level; + + --%test(Disable tests with reason using special characters and long reason) + procedure test_long_text_spec_chr; + + --%test(Disable tests on suite , context and test level and display suite level reason) + procedure test_disable_suite_ctx_tst; + + --%test(Disable tests on context and test level and display context level reason) + procedure test_disable_ctx_tst; + +end; +/ diff --git a/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb b/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb index 1ad4f19a5..761377765 100644 --- a/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb +++ b/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb @@ -1,6 +1,7 @@ create or replace package body test_annot_throws_exception is g_tests_results clob; + g_results_other_schema clob; procedure recollect_tests_results is pragma autonomous_transaction; @@ -8,7 +9,7 @@ is l_package_spec varchar2(32737); l_package_body varchar2(32737); l_exception_spec varchar2(32737); - l_test_results ut3.ut_varchar2_list; + l_test_results ut3_develop.ut_varchar2_list; begin l_exception_spec := q'[ create or replace package exc_pkg is @@ -20,212 +21,292 @@ is c_e_diff_exc constant number := -20204; c_e_mix_list constant number := -20205; c_e_mix_missin constant number := -20206; - + c_e_positive constant number := 20207; + e_some_exception exception; pragma exception_init(e_some_exception, -20207); - end;]'; + end; + ]'; - l_package_spec := ' - create package annotated_package_with_throws is - --%suite(Dummy package to test annotation throws) - - --%test(Throws same annotated exception) - --%throws(-20145) - procedure raised_same_exception; - - --%test(Throws one of the listed exceptions) - --%throws(-20145,-20146, -20189 ,-20563) - procedure raised_one_listed_exception; - - --%test(Leading zero is ignored in exception list) - --%throws(-01476) - procedure leading_0_exception_no; - - --%test(Throws diff exception) - --%throws(-20144) - procedure raised_diff_exception; - - --%test(Throws empty) - --%throws() - procedure empty_throws; - - --%test(Ignores annotation and fails when exception was thrown) - --%throws(hello,784#,0-=234,,u1234) - procedure bad_paramters_with_except; - - --%test(Ignores annotation and succeeds when no exception thrown) - --%throws(hello,784#,0-=234,,u1234) - procedure bad_paramters_without_except; - - --%test(Detects a valid exception number within many invalid ones) - --%throws(7894562, operaqk, -=1, -1, pow74d, posdfk3) - procedure one_valid_exception_number; - - --%test(Gives failure when a exception is expected and nothing is thrown) - --%throws(-20459, -20136, -20145) - procedure nothing_thrown; - - --%test(Single exception defined as a constant number in package) - --%throws(exc_pkg.c_e_single_exc) - procedure single_exc_const_pkg; - - --%test(Gives success when one of annotated exception using constant is thrown) - --%throws(exc_pkg.c_e_list_1,exc_pkg.c_e_list_2) - procedure list_of_exc_constant; - - --%test(Gives failure when the raised exception is different that the annotated one using variable) - --%throws(exc_pkg.c_e_diff_exc) - procedure fail_not_match_exc; - - --%test(Success when one of exception from mixed list of number and constant is thrown) - --%throws(exc_pkg.c_e_mix_list,-20105) - procedure mixed_exc_list; - - --%test(Success when match exception even if other variable on list dont exists) - --%throws(exc_pkg.c_e_mix_missin,utter_rubbish) - procedure mixed_list_notexi; - - --%test(Success resolve and match named exception defined in pragma exception init) - --%throws(exc_pkg.e_some_exception) - procedure named_exc_pragma; - - --%test(Success resolve and match oracle named exception) - --%throws(NO_DATA_FOUND) - procedure named_exc_ora; - - --%test(Success resolve and match oracle named exception dup val index) - --%throws(DUP_VAL_ON_INDEX) - procedure named_exc_ora_dup_ind; - - --%test(Success map no data 100 to -1403) - --%throws(-1403) - procedure nodata_exc_ora; - - --%test(Success for exception defined as varchar) - --%throws(exc_pkg.c_e_varch_exc) - procedure defined_varchar_exc; - - --%test(Non existing constant exception) - --%throws(dummy.c_dummy); - procedure non_existing_const; - - --%test(Bad exception constant) - --%throws(exc_pkg.c_e_dummy); - procedure bad_exc_const; - - end; - '; + l_package_spec := q'[ + create or replace package annotated_package_with_throws is + + c_local_error_no constant number := -20211; + e_some_local_exception exception; + pragma exception_init(e_some_local_exception, -20212); + + e_uninitialized_exception_variable exception; + + --%suite(Dummy package to test annotation throws) + + --%test(Throws same annotated exception) + --%throws(-20145) + procedure raised_same_exception; + + --%test(Throws one of the listed exceptions) + --%throws(-20145,-20146, -20189 ,-20563) + procedure raised_one_listed_exception; + + --%test(Leading zero is ignored in exception list) + --%throws(-01476) + procedure leading_0_exception_no; + + --%test(Throws diff exception) + --%throws(-20144) + procedure raised_diff_exception; + + --%test(Throws empty) + --%throws() + procedure empty_throws; + + --%test(Ignores annotation and fails when exception was thrown) + --%throws(hello,784#,0-=234,,u1234) + procedure bad_paramters_with_except; + + --%test(Ignores annotation and succeeds when no exception thrown) + --%throws(hello,784#,0-=234,,u1234) + procedure bad_paramters_without_except; + + --%test(Ignores annotation for positive exception number value) + --%throws(20001) + procedure positive_exception_number; + + --%test(Ignores annotation for positive exception number variable) + --%throws(exc_pkg.c_e_positive) + procedure positive_exception_number_var; + + --%test(Detects a valid exception number within many invalid ones) + --%throws(7894562, operaqk, -=1, -1, pow74d, posdfk3) + procedure one_valid_exception_number; + + --%test(Gives failure when a exception is expected and nothing is thrown) + --%throws(-20459, -20136, -20145) + procedure nothing_thrown; + + --%test(Single exception defined as a constant number in package) + --%throws(exc_pkg.c_e_single_exc) + procedure single_exc_const_pkg; + + --%test(Gives success when one of annotated exception using constant is thrown) + --%throws(exc_pkg.c_e_list_1,exc_pkg.c_e_list_2) + procedure list_of_exc_constant; + + --%test(Gives failure when the raised exception is different that the annotated one using variable) + --%throws(exc_pkg.c_e_diff_exc) + procedure fail_not_match_exc; + + --%test(Success when one of exception from mixed list of number and constant is thrown) + --%throws(exc_pkg.c_e_mix_list,-20105) + procedure mixed_exc_list; + + --%test(Success when match exception even if other variable on list dont exists) + --%throws(exc_pkg.c_e_mix_missin,utter_rubbish) + procedure mixed_list_notexi; + + --%test(Success referencing an exception variable when running from another schema) + --%throws(exc_pkg.e_some_exception) + procedure named_exc_pragma_run_from_another_schema; + + --%test(Success referencing a numeric exception variable when running from another schema) + --%throws(exc_pkg.c_e_list_1) + procedure exc_number_var_run_from_another_schema; + + --%test(Success referencing an exception variable without package name when running from another schema) + --%throws(e_some_local_exception) + procedure named_exc_pragma_run_from_another_schema_no_package_name; + + --%test(Success referencing a numeric exception variable without package name when running from another schema) + --%throws(c_local_error_no) + procedure exc_number_var_run_from_another_schema_no_package_name; + + --%test(Success resolve and match named exception defined in pragma exception init) + --%throws(exc_pkg.e_some_exception) + procedure named_exc_pragma; + + --%test(Success resolve and match oracle named exception) + --%throws(NO_DATA_FOUND) + procedure named_exc_ora; + + --%test(Success resolve and match oracle named exception dup val index) + --%throws(DUP_VAL_ON_INDEX) + procedure named_exc_ora_dup_ind; + + --%test(Success map no data 100 to -1403) + --%throws(-1403) + procedure nodata_exc_ora; + + --%test(Success for exception defined as varchar) + --%throws(exc_pkg.c_e_varch_exc) + procedure defined_varchar_exc; + + --%test(Non existing constant exception) + --%throws(dummy.c_dummy); + procedure non_existing_const; + + --%test(Bad exception constant) + --%throws(exc_pkg.c_e_dummy); + procedure bad_exc_const; + + --%test(Uninitialized exception variable can be used successfully in a test) + --%throws(e_uninitialized_exception_variable) + procedure referencing_uninitialized_exception; + + --%test(Failure report shows all expected exceptions) + --%throws(c_local_error_no,e_some_local_exception,e_uninitialized_exception_variable) + procedure not_throwing_expected_exceptions; + + end; + ]'; l_package_body := ' - create package body annotated_package_with_throws is - procedure raised_same_exception is - begin - raise_application_error(-20145, ''Test error''); - end; - - procedure raised_one_listed_exception is - begin - raise_application_error(-20189, ''Test error''); - end; - - procedure leading_0_exception_no is - x integer; - begin - x := 1 / 0; - end; - - procedure raised_diff_exception is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure empty_throws is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure bad_paramters_with_except is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure bad_paramters_without_except is - begin - null; - end; - - procedure one_valid_exception_number is - begin - raise dup_val_on_index; - end; - - procedure nothing_thrown is - begin - null; - end; - - procedure single_exc_const_pkg is - begin - raise_application_error(exc_pkg.c_e_single_exc,''Test''); - end; - - procedure list_of_exc_constant is - begin - raise_application_error(exc_pkg.c_e_list_1,''Test''); - end; - - procedure fail_not_match_exc is - begin - raise NO_DATA_FOUND; - end; - - procedure mixed_exc_list is - begin - raise_application_error(exc_pkg.c_e_mix_list,''Test''); - end; - - procedure mixed_list_notexi is - begin - raise_application_error(exc_pkg.c_e_mix_missin,''Test''); - end; - - procedure named_exc_pragma is - begin - raise exc_pkg.e_some_exception; - end; - - procedure named_exc_ora is - begin - raise NO_DATA_FOUND; - end; - - procedure named_exc_ora_dup_ind is - begin - raise DUP_VAL_ON_INDEX; - end; - - procedure nodata_exc_ora is - begin - raise NO_DATA_FOUND; - end; - - procedure defined_varchar_exc is - begin - raise_application_error(exc_pkg.c_e_varch_exc,''Test''); - end; - - procedure non_existing_const is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure bad_exc_const is - begin - raise_application_error(-20143, ''Test error''); - end; + create or replace package body annotated_package_with_throws is + procedure raised_same_exception is + begin + raise_application_error(-20145, ''Test error''); + end; + + procedure raised_one_listed_exception is + begin + raise_application_error(-20189, ''Test error''); + end; + + procedure leading_0_exception_no is + x integer; + begin + x := 1 / 0; + end; + + procedure raised_diff_exception is + begin + raise_application_error(-20143, ''Test error''); + end; + + procedure empty_throws is + begin + raise_application_error(-20143, ''Test error''); + end; + + procedure bad_paramters_with_except is + begin + raise_application_error(-20143, ''Test error''); + end; + + procedure bad_paramters_without_except is + begin + null; + end; + + procedure positive_exception_number is + begin + null; + end; + + procedure positive_exception_number_var is + begin + null; + end; + + procedure one_valid_exception_number is + begin + raise dup_val_on_index; + end; + + procedure nothing_thrown is + begin + null; + end; + + procedure single_exc_const_pkg is + begin + raise_application_error(exc_pkg.c_e_single_exc,''Test''); + end; + + procedure list_of_exc_constant is + begin + raise_application_error(exc_pkg.c_e_list_1,''Test''); + end; + + procedure fail_not_match_exc is + begin + raise NO_DATA_FOUND; + end; + + procedure mixed_exc_list is + begin + raise_application_error(exc_pkg.c_e_mix_list,''Test''); + end; + + procedure mixed_list_notexi is + begin + raise_application_error(exc_pkg.c_e_mix_missin,''Test''); + end; + + procedure named_exc_pragma_run_from_another_schema is + begin + raise exc_pkg.e_some_exception; + end; + + procedure exc_number_var_run_from_another_schema is + begin + raise_application_error(exc_pkg.c_e_list_1,''Test''); + end; + + procedure named_exc_pragma_run_from_another_schema_no_package_name is + begin + raise e_some_local_exception; + end; + + procedure exc_number_var_run_from_another_schema_no_package_name is + begin + raise_application_error(c_local_error_no,''Test''); + end; + + procedure named_exc_pragma is + begin + raise exc_pkg.e_some_exception; + end; + + procedure named_exc_ora is + begin + raise NO_DATA_FOUND; + end; + + procedure named_exc_ora_dup_ind is + begin + raise DUP_VAL_ON_INDEX; + end; + + procedure nodata_exc_ora is + begin + raise NO_DATA_FOUND; + end; + + procedure defined_varchar_exc is + begin + raise_application_error(exc_pkg.c_e_varch_exc,''Test''); + end; + + procedure non_existing_const is + begin + raise_application_error(-20143, ''Test error''); + end; + + procedure bad_exc_const is + begin + raise_application_error(-20143, ''Test error''); + end; + procedure referencing_uninitialized_exception is + begin + raise e_uninitialized_exception_variable; end; + + procedure not_throwing_expected_exceptions is + begin + raise_application_error(-20143, ''Test error''); + end; + end; '; execute immediate l_exception_spec; @@ -233,11 +314,19 @@ is execute immediate l_package_body; - select * bulk collect into l_test_results from table(ut3.ut.run(('annotated_package_with_throws'))); + select * bulk collect into l_test_results from table(ut3_develop.ut.run(('annotated_package_with_throws'))); - g_tests_results := ut3.ut_utils.table_to_clob(l_test_results); + g_tests_results := ut3_develop.ut_utils.table_to_clob(l_test_results); + end; + + procedure drop_test_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package annotated_package_with_throws'; + execute immediate 'drop package exc_pkg'; end; + procedure throws_same_annotated_except is begin ut.expect(g_tests_results).to_match('^\s*Throws same annotated exception \[[,\.0-9]+ sec\]\s*$','m'); @@ -277,13 +366,25 @@ is procedure bad_paramters_without_except is begin ut.expect(g_tests_results).to_match('^\s*Ignores annotation and succeeds when no exception thrown \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('bad_paramters_without_except'); + ut.expect(g_tests_results).to_match('bad_paramters_without_except\s*Invalid parameter value ".*" for "--%throws" annotation. Parameter ignored.','m'); + end; + + procedure positive_exception_number is + begin + ut.expect(g_tests_results).to_match('^\s*Ignores annotation for positive exception number value \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).to_match('positive_exception_number\s*Invalid parameter value "20001" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.','m'); + end; + + procedure positive_exception_number_var is + begin + ut.expect(g_tests_results).to_match('^\s*Ignores annotation for positive exception number variable \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).to_match('positive_exception_number_var\s*Invalid parameter value ".*" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.','m'); end; procedure one_valid_exception_number is begin - ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('one_valid_exception_number'); + ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).to_match('one_valid_exception_number\s*Invalid parameter value ".*" for "--%throws" annotation. Parameter ignored.','m'); end; procedure nothing_thrown is @@ -319,15 +420,45 @@ is procedure mixed_list_notexi is begin ut.expect(g_tests_results).to_match('^\s*Success when match exception even if other variable on list dont exists \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('mixed_list_notexi'); + ut.expect(g_tests_results).to_match('mixed_list_notexi\s*Invalid parameter value "utter_rubbish" for "--%throws" annotation. Parameter ignored.','m'); end; procedure named_exc_pragma is begin ut.expect(g_tests_results).to_match('^\s*Success resolve and match named exception defined in pragma exception init \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('mixed_list_notexi'); + ut.expect(g_tests_results).not_to_match('named_exc_pragma'); end; - + + procedure run_from_another_schema is + begin + ut3_tester_helper.run_helper.run(('ut3_tester.annotated_package_with_throws')); + g_results_other_schema := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + end; + + procedure named_exc_pragma_run_from_another_schema is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing an exception variable when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('named_exc_pragma_run_from_another_schema'); + end; + + procedure named_exc_pragma_run_from_another_schema_no_package_name is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing an exception variable without package name when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('named_exc_pragma_run_from_another_schema_no_package_name'); + end; + + procedure exc_number_var_run_from_another_schema_no_package_name is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing a numeric exception variable without package name when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('exc_number_var_run_from_another_schema_no_package_name'); + end; + + procedure exc_number_var_run_from_another_schema is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing a numeric exception variable when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('exc_number_var_run_from_another_schema'); + end; + procedure named_exc_ora is begin ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception \[[,\.0-9]+ sec\]\s*$','m'); @@ -362,13 +493,23 @@ is begin ut.expect(g_tests_results).to_match('^\s*Bad exception constant \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); ut.expect(g_tests_results).to_match('bad_exc_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure drop_test_package is - pragma autonomous_transaction; + end; + + procedure referencing_uninitialized_exception is + l_test_results ut3_develop.ut_varchar2_list; + l_actual clob; begin - execute immediate 'drop package annotated_package_with_throws'; - execute immediate 'drop package exc_pkg'; + select * bulk collect into l_test_results from table(ut3_develop.ut.run(('annotated_package_with_throws.referencing_uninitialized_exception'))); + + l_actual := ut3_develop.ut_utils.table_to_clob(l_test_results); + ut.expect(l_actual).to_match('^\s*Uninitialized exception variable can be used successfully in a test \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect(l_actual).not_to_match('referencing_uninitialized_exception'); + end; + + procedure not_throwing_expected_exceptions is + begin + ut.expect(g_tests_results).to_match('not_throwing_expected_exceptions'); + ut.expect(g_tests_results).to_match('Actual: -20143 was expected to be one of: \(annotated_package_with_throws.e_some_local_exception, annotated_package_with_throws.e_uninitialized_exception_variable, -20211\)'); end; end; diff --git a/test/ut3_tester/core/annotations/test_annot_throws_exception.pks b/test/ut3_tester/core/annotations/test_annot_throws_exception.pks index ce2e6ba7a..a41c18d2b 100644 --- a/test/ut3_tester/core/annotations/test_annot_throws_exception.pks +++ b/test/ut3_tester/core/annotations/test_annot_throws_exception.pks @@ -5,7 +5,11 @@ is --%beforeall procedure recollect_tests_results; - + + --%afterall + procedure drop_test_package; + + --%test(Gives success when annotated number exception is thrown) procedure throws_same_annotated_except; @@ -18,7 +22,7 @@ is --%test(Gives failure when the raised exception is different that the annotated one) procedure throws_diff_annotated_except; - --%test(Ignores when the annotation throws is empty) + --%test(Ignores the throws annotation when it is empty) procedure throws_empty; --%test(Ignores when only bad parameters are passed, the test raise a exception and it shows errored test) @@ -26,11 +30,17 @@ is --%test(Ignores when only bad parameters are passed, the test does not raise a exception and it shows successful test) procedure bad_paramters_without_except; - + + --%test(Ignores annotation for positive exception number value) + procedure positive_exception_number; + + --%test(Ignores annotation for positive exception number variable) + procedure positive_exception_number_var; + --%test(Detects a valid exception number within many invalid ones) procedure one_valid_exception_number; - --%test(Gives failure when a exception is expected and nothing is thrown) + --%test(Gives failure when an exception is expected and nothing is thrown) procedure nothing_thrown; --%test(Single exception defined as a constant number in package) @@ -39,19 +49,19 @@ is --%test(Gives success when one of annotated exception using constant is thrown) procedure list_of_exc_constant; - --%test(Gives failure when the raised exception is different that the annotated one using variable) + --%test(Gives failure when the raised exception is different than the annotated one using variable) procedure fail_not_match_exc; - --%test(Success when one of exception from mixed list of number and constant is thrown) + --%test(Success when one of exception from a mixed list of number and constant is thrown) procedure mixed_exc_list; - --%test(Success when match exception even if other variable on list dont exists) + --%test(Success when match exception even if another variable on list doesn't exists) procedure mixed_list_notexi; --%test(Success resolve and match named exception defined in pragma exception init) procedure named_exc_pragma; - - --%test(Success resolve and match oracle named exception no data) + + --%test(Success resolve and match oracle named exception no data) procedure named_exc_ora; --%test(Success resolve and match oracle named exception dup val index) @@ -67,10 +77,32 @@ is procedure non_existing_const; --%test(Bad exception constant) - procedure bad_exc_const; + procedure bad_exc_const; + + --%test(Uninitialized exception variable can be used successfully in a test) + procedure referencing_uninitialized_exception; + + --%test(a Failure report shows all expected exceptions) + procedure not_throwing_expected_exceptions; - --%afterall - procedure drop_test_package; + --%context(referencing exceptions when running from another schema) + + --%beforeall + procedure run_from_another_schema; + + --%test(Success referencing an exception variable when running from another schema) + procedure named_exc_pragma_run_from_another_schema; + + --%test(Success referencing a numeric exception variable when running from another schema) + procedure exc_number_var_run_from_another_schema; + + --%test(Success referencing an exception variable without a package name when running from another schema) + procedure named_exc_pragma_run_from_another_schema_no_package_name; + + --%test(Success referencing a numeric exception variable without a package name when running from another schema) + procedure exc_number_var_run_from_another_schema_no_package_name; + + --%endcontext end; / diff --git a/test/ut3_tester/core/annotations/test_annotation_cache.pkb b/test/ut3_tester/core/annotations/test_annotation_cache.pkb new file mode 100644 index 000000000..36f8f983d --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annotation_cache.pkb @@ -0,0 +1,650 @@ +create or replace package body test_annotation_cache is + + procedure cache_populated_for_packages(a_packages ut_varchar2_rows) is + l_actual_cache_info sys_refcursor; + l_expected_cache_info sys_refcursor; + begin + open l_actual_cache_info for + select * + from ut3_develop.ut_annotation_cache_info + where object_owner = 'UT3_CACHE_TEST_OWNER'; + open l_expected_cache_info for + select 'UT3_CACHE_TEST_OWNER' as object_owner, upper( column_value ) as object_name + from table (a_packages) x; + ut.expect( l_actual_cache_info ).to_equal( l_expected_cache_info ).exclude( 'CACHE_ID,PARSE_TIME,OBJECT_TYPE' ).JOIN_BY('OBJECT_NAME'); + end; + + procedure cant_run_any_packages(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + + --Assert - no suites are + ut.expect( l_actual ).to_be_like( '%0 tests, 0 failed%' ); + rollback; + end; + + procedure can_run_one_package(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + + --Assert - only granted_test_suite is invoked + ut.expect( l_actual ).to_be_like( 'granted_test_suite%2 tests, 0 failed%' ); + rollback; + end; + + procedure can_run_new_package(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Arrange + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.add_new_suite( ); + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + --Assert -Both granted_test_suite and new_suite are invoked + ut.expect( l_actual ).to_be_like( 'granted_test_suite%new_suite%4 tests, 0 failed%' ); + rollback; + end ; + + procedure cant_run_revoked_package(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Arrange + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.add_new_suite( ); + annotation_cache_helper.revoke_granted_suite( ); + + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + --Assert -Only new_suite gets invoked + ut.expect( l_actual ).to_be_like( 'new_suite%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); + ut.expect( l_actual ).not_to_be_like( '%granted_test_suite%' ); + rollback; + end; + + procedure cant_run_dropped_package(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Arrange + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.add_new_suite( ); + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.revoke_granted_suite( ); + annotation_cache_helper.cleanup_new_suite( ); + + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + --Assert - no test suites are invoked + ut.expect( l_actual ).to_be_like( '%0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); + ut.expect( l_actual ).not_to_be_like( '%new_suite%' ); + ut.expect( l_actual ).not_to_be_like( '%granted_test_suite%' ); + rollback; + end; + + procedure can_run_all_packages(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + + --Assert - only granted_test_suite is invoked + ut.expect( l_actual ).to_be_like( 'granted_test_suite%not_granted_test_suite%4 tests, 0 failed%' ); + rollback; + end; + + procedure can_run_all_new_packages(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Arrange + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.add_new_suite( ); + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + + --Assert - only granted_test_suite is invoked + ut.expect( l_actual ).to_be_like( 'granted_test_suite%new_suite%not_granted_test_suite% tests, 0 failed%' ); + rollback; + end; + + procedure can_run_revoked_packages(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Arrange + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.add_new_suite( ); + annotation_cache_helper.revoke_granted_suite( ); + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + + --Assert - only granted_test_suite is invoked + ut.expect( l_actual ).to_be_like( 'granted_test_suite%new_suite%not_granted_test_suite% tests, 0 failed%' ); + rollback; + end; + + procedure can_run_all_but_dropped(a_user varchar2) is + l_actual clob; + l_current_time date := sysdate; + pragma autonomous_transaction; + begin + --Arrange + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.add_new_suite( ); + l_actual := annotation_cache_helper.run_tests_as( a_user ); + annotation_cache_helper.revoke_granted_suite( ); + annotation_cache_helper.cleanup_new_suite( ); + + --Act + l_actual := annotation_cache_helper.run_tests_as( a_user ); + --Assert - no test suites are invoked + ut.expect( l_actual ).to_be_like( 'granted_test_suite%not_granted_test_suite%4 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%new_suite%' ); + rollback; + end; + + + procedure user_can_run_one_package is + begin + can_run_one_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure user_can_run_new_package is + begin + can_run_new_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure user_cant_run_revoked_package is + begin + cant_run_revoked_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure user_cant_run_dropped_package is + begin + cant_run_dropped_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure sel_cat_user_can_run_one is + begin + can_run_one_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure sel_cat_user_can_run_new is + begin + can_run_new_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure sel_cat_user_cant_run_revoked is + begin + cant_run_revoked_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure sel_cat_user_cant_run_dropped is + begin + cant_run_dropped_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure sel_any_user_can_run_one is + begin + can_run_one_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure sel_any_user_can_run_new is + begin + can_run_new_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure sel_any_user_cant_run_revoked is + begin + cant_run_revoked_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure sel_any_user_cant_run_dropped is + begin + cant_run_dropped_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure exe_any_user_can_run_all is + begin + can_run_all_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure exe_any_user_can_run_new is + begin + can_run_all_new_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure exe_any_user_can_run_revoked is + begin + can_run_revoked_packages('ut3_execute_any_proc_user'); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure exe_any_user_cant_run_dropped is + begin + can_run_all_but_dropped('ut3_execute_any_proc_user'); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure owner_user_can_run_all is + begin + can_run_all_packages( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + + procedure owner_user_can_run_new is + begin + can_run_all_new_packages( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure owner_user_cant_run_dropped is + begin + can_run_all_but_dropped('ut3_cache_test_owner'); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + + procedure t_user_can_run_one_package is + begin + can_run_one_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_user_can_run_new_package is + begin + can_run_new_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_user_cant_run_revoked_pkg is + begin + cant_run_revoked_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_user_cant_run_dropped_pkg is + begin + cant_run_dropped_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_sel_cat_user_can_run_one is + begin + can_run_one_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_sel_cat_user_can_run_new is + begin + can_run_new_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_sel_cat_user_cant_run_revokd is + begin + cant_run_revoked_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_sel_cat_user_cant_run_dropd is + begin + cant_run_dropped_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + + procedure t_sel_any_user_can_run_one is + begin + can_run_one_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_sel_any_user_can_run_new is + begin + can_run_new_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_sel_any_user_cant_run_revokd is + begin + cant_run_revoked_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_sel_any_user_cant_run_dropd is + begin + cant_run_dropped_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + + procedure t_exe_any_user_can_run_all is + begin + can_run_all_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_exe_any_user_can_run_new is + begin + can_run_all_new_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_exe_any_user_can_run_revokd is + begin + can_run_revoked_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_exe_any_user_cant_run_dropd is + begin + can_run_all_but_dropped( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_owner_user_can_run_all is + begin + can_run_all_packages( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_owner_user_can_run_new is + begin + can_run_all_new_packages( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_owner_user_cant_run_dropd is + begin + can_run_all_but_dropped( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure t_ut_owner_cannot_run_tests is + begin + cant_run_any_packages( 'ut3_develop' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + + + procedure p_user_can_run_one_package is + begin + can_run_one_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure p_user_can_run_new_package is + begin + can_run_new_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure p_user_cant_run_revoked_pack is + begin + cant_run_revoked_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure p_user_cant_run_dropped_pack is + begin + cant_run_dropped_package( 'ut3_no_extra_priv_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + + + procedure p_sel_cat_user_can_run_one is + begin + can_run_one_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure p_sel_cat_user_can_run_new is + begin + can_run_new_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure p_sel_cat_user_cant_run_revokd is + begin + cant_run_revoked_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure p_sel_cat_user_cant_run_dropd is + begin + cant_run_dropped_package( 'ut3_select_catalog_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure p_sel_any_user_can_run_one is + begin + can_run_one_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure p_sel_any_user_can_run_new is + begin + can_run_new_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure p_sel_any_user_cant_run_revokd is + begin + cant_run_revoked_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); + end; + + procedure p_sel_any_user_cant_run_dropd is + begin + cant_run_dropped_package( 'ut3_select_any_table_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); + end; + + procedure p_exe_any_user_can_run_all is + begin + can_run_all_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure p_exe_any_user_can_run_new is + begin + can_run_all_new_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure p_exe_any_user_can_run_revokd is + begin + can_run_revoked_packages( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure p_exe_any_user_cant_run_dropd is + begin + can_run_all_but_dropped( 'ut3_execute_any_proc_user' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure p_owner_user_can_run_all is + begin + can_run_all_packages( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure p_owner_user_can_run_new is + begin + can_run_all_new_packages( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure p_owner_user_cant_run_dropped is + begin + can_run_all_but_dropped( 'ut3_cache_test_owner' ); + cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); + end; + + procedure user_runs_child_of_hidden_suite is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.child_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( '%parent_suite%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_warned_about_hidden_parent is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.child_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( + '%Warnings:%parent_suite%Suite ut3_cache_test_owner.parent_suite is not run, as it does not exist or you have no EXECUTE privilege on it.%' + ); + ut.expect( l_actual ).to_be_like( '%1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s)%' ); + rollback; + end; + + procedure user_runs_child_without_parent_tags is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - child_suite inherits parent_tag only when parent_suite is accessible + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner', '!parent_tag' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_cache_test_owner', 'ut3_cache_test_owner', '!parent_tag' ); + --Assert + ut.expect( l_actual ).not_to_be_like( '%child_test%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_runs_hidden_suite_path is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:parent_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_no_empty_logical_suites is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.get_suites_info_as( 'ut3_no_extra_priv_user' ); + --Assert + ut.expect( l_actual ).to_be_like( '%UT_TEST parent_suite.child_suite.child_test%' ); + ut.expect( l_actual ).not_to_be_like( '%hidden_path%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_runs_granted_by_wildcard is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches child_suite (granted) and lone_suite (not granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.*l*_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%lone_test%' ); + rollback; + end; + + procedure user_runs_granted_tests_by_wildcard is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches child_suite.child_test (granted) and lone_suite.lone_test (not granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.*l*_suite.*_test' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%lone_test%' ); + rollback; + end; + + procedure user_runs_granted_by_path_wildcard is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches parent_suite (not granted) and parent_suite.child_suite (granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:parent*' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_hidden_path_wildcard_not_found is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches only hidden_path.sub.lone_suite (not granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:hidden*' ); + rollback; + exception + when others then + rollback; + raise; + end; + + procedure user_hidden_path_not_found is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:hidden_path' ); + rollback; + exception + when others then + rollback; + raise; + end; + +end; +/ diff --git a/test/ut3_tester/core/annotations/test_annotation_cache.pks b/test/ut3_tester/core/annotations/test_annotation_cache.pks new file mode 100644 index 000000000..fec89cf3b --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annotation_cache.pks @@ -0,0 +1,319 @@ +create or replace package test_annotation_cache is + + --%suite(annotation cache) + --%suitepath(utplsql.ut3_tester.core.annotations) + --%beforeall(annotation_cache_helper.create_run_function_for_users) + --%afterall(annotation_cache_helper.drop_run_function_for_users) + + --%context(With DDL trigger enabled) + + --%beforeall(annotation_cache_helper.enable_ddl_trigger) + --%beforeeach(annotation_cache_helper.setup_two_suites) + --%aftereach(annotation_cache_helper.cleanup_new_suite) + --%afterall(annotation_cache_helper.cleanup_two_suites) + + --%context(User without elevated privileges) + + --%test(Can only execute granted packages) + procedure t_user_can_run_one_package; + + --%test(Can see newly created packages as they are added) + procedure t_user_can_run_new_package; + + --%test(Cannot execute revoked packages) + procedure t_user_cant_run_revoked_pkg; + + --%test(Cannot execute dropped unit test packages) + procedure t_user_cant_run_dropped_pkg; + + --%endcontext + + --%context(User with select_catalog_role) + + --%test(Can only execute granted packages) + procedure t_sel_cat_user_can_run_one; + + --%test(Can see newly created packages as they are added) + procedure t_sel_cat_user_can_run_new; + + --%test(Cannot execute revoked packages) + procedure t_sel_cat_user_cant_run_revokd; + + --%test(Cannot execute dropped unit test packages) + procedure t_sel_cat_user_cant_run_dropd; + + --%endcontext + + --%context(User with select any table privilege) + + --%test(Can only execute granted packages) + procedure t_sel_any_user_can_run_one; + + --%test(Can see newly created packages as they are added) + procedure t_sel_any_user_can_run_new; + + --%test(Cannot execute revoked packages) + procedure t_sel_any_user_cant_run_revokd; + + --%test(Cannot execute dropped unit test packages) + procedure t_sel_any_user_cant_run_dropd; + + --%endcontext + + --%context(User with execute any procedure) + + --%test(Can execute and see all unit test packages) + procedure t_exe_any_user_can_run_all; + + --%test(Can see newly created packages as they are added) + procedure t_exe_any_user_can_run_new; + + --%test(Can execute revoked packages) + procedure t_exe_any_user_can_run_revokd; + + --%test(Cannot execute dropped unit test packages) + procedure t_exe_any_user_cant_run_dropd; + + --%endcontext + + --%context(User owning test packages) + + --%test(Can execute and see all unit test packages) + procedure t_owner_user_can_run_all; + + --%test(Can see newly created packages as they are added) + procedure t_owner_user_can_run_new; + + --%test(Cannot execute dropped unit test packages) + procedure t_owner_user_cant_run_dropd; + + --%endcontext + + --%context(utPLSQL framework owner) + + --%test(Cannot see any tests and doesn't impact annotation cache ) + procedure t_ut_owner_cannot_run_tests; + + --%endcontext + + --%endcontext + + --%context(With DDL trigger disabled) + + --%beforeall(annotation_cache_helper.disable_ddl_trigger) + --%beforeeach(annotation_cache_helper.setup_two_suites) + --%beforeeach(annotation_cache_helper.purge_annotation_cache) + --%aftereach(annotation_cache_helper.cleanup_new_suite) + --%afterall(annotation_cache_helper.enable_ddl_trigger) + --%afterall(annotation_cache_helper.cleanup_two_suites) + + --%context(User without elevated privileges) + + --%test(Can only execute granted packages) + procedure user_can_run_one_package; + + --%test(Can see newly created packages as they are added) + procedure user_can_run_new_package; + + --%test(Cannot execute revoked packages) + procedure user_cant_run_revoked_package; + + --%test(Cannot execute dropped unit test packages) + procedure user_cant_run_dropped_package; + + --%endcontext + + --%context(User with select_catalog_role) + + --%test(Can only execute granted packages) + procedure sel_cat_user_can_run_one; + + --%test(Can see newly created packages as they are added) + procedure sel_cat_user_can_run_new; + + --%test(Cannot execute revoked packages) + procedure sel_cat_user_cant_run_revoked; + + --%test(Cannot execute dropped unit test packages) + procedure sel_cat_user_cant_run_dropped; + + --%endcontext + + --%context(User with select any table privilege) + + --%test(Can only execute granted packages) + procedure sel_any_user_can_run_one; + + --%test(Can see newly created packages as they are added) + procedure sel_any_user_can_run_new; + + --%test(Cannot execute revoked packages) + procedure sel_any_user_cant_run_revoked; + + --%test(Cannot execute dropped unit test packages) + procedure sel_any_user_cant_run_dropped; + + --%endcontext + + --%context(User with execute any procedure) + + --%test(Can execute and see all unit test packages) + procedure exe_any_user_can_run_all; + + --%test(Can see newly created packages as they are added) + procedure exe_any_user_can_run_new; + + --%test(Can execute revoked packages) + procedure exe_any_user_can_run_revoked; + + --%test(Cannot execute dropped unit test packages) + procedure exe_any_user_cant_run_dropped; + + --%endcontext + + --%context(User owning test packages) + + --%test(Can execute and see all unit test packages) + procedure owner_user_can_run_all; + + --%test(Can see newly created packages as they are added) + procedure owner_user_can_run_new; + + --%test(Cannot execute dropped unit test packages) + procedure owner_user_cant_run_dropped; + + --%endcontext + + --%endcontext + + --%context(With DDL trigger enabled and cache purged) + + --%beforeall(annotation_cache_helper.enable_ddl_trigger) + + --%beforeeach(annotation_cache_helper.setup_two_suites) + --%beforeeach(annotation_cache_helper.purge_annotation_cache) + + --%aftereach(annotation_cache_helper.cleanup_new_suite) + --%aftereach(annotation_cache_helper.cleanup_two_suites) + + --%context(User without elevated privileges) + + --%test(Can only execute granted packages) + procedure p_user_can_run_one_package; + + --%test(Can see newly created packages as they are added) + procedure p_user_can_run_new_package; + + --%test(Cannot execute revoked packages) + procedure p_user_cant_run_revoked_pack; + + --%test(Cannot execute dropped unit test packages) + procedure p_user_cant_run_dropped_pack; + + --%endcontext + + --%context(User with select_catalog_role) + + --%test(Can only execute granted packages) + procedure p_sel_cat_user_can_run_one; + + --%test(Can see newly created packages as they are added) + procedure p_sel_cat_user_can_run_new; + + --%test(Cannot execute revoked packages) + procedure p_sel_cat_user_cant_run_revokd; + + --%test(Cannot execute dropped unit test packages) + procedure p_sel_cat_user_cant_run_dropd; + + --%endcontext + + --%context(User with select any table privilege) + + --%test(Can only execute granted packages) + procedure p_sel_any_user_can_run_one; + + --%test(Can see newly created packages as they are added) + procedure p_sel_any_user_can_run_new; + + --%test(Cannot execute revoked packages) + procedure p_sel_any_user_cant_run_revokd; + + --%test(Cannot execute dropped unit test packages) + procedure p_sel_any_user_cant_run_dropd; + + --%endcontext + + --%context(User with execute any procedure) + + --%test(Can execute and see all unit test packages) + procedure p_exe_any_user_can_run_all; + + --%test(Can see newly created packages as they are added) + procedure p_exe_any_user_can_run_new; + + --%test(Can execute revoked packages) + procedure p_exe_any_user_can_run_revokd; + + --%test(Cannot execute dropped unit test packages) + procedure p_exe_any_user_cant_run_dropd; + + --%endcontext + + --%context(User owning test packages) + + --%test(Can execute and see all unit test packages) + procedure p_owner_user_can_run_all; + + --%test(Can see newly created packages as they are added) + procedure p_owner_user_can_run_new; + + --%test(Cannot execute dropped unit test packages) + procedure p_owner_user_cant_run_dropped; + + --%endcontext + + + --%endcontext + + --%context(Suites spread across packages, user without elevated privileges) + --%beforeall(annotation_cache_helper.enable_ddl_trigger) + --%beforeall(annotation_cache_helper.setup_suite_hierarchy) + --%afterall(annotation_cache_helper.cleanup_suite_hierarchy) + + --%test(Runs a granted package whose parent suite is in a package that is not granted) + procedure user_runs_child_of_hidden_suite; + + --%test(Warns that the parent suite in a package that is not granted is not run) + procedure user_warned_about_hidden_parent; + + --%test(Does not apply tags of the parent suite in a package that is not granted) + procedure user_runs_child_without_parent_tags; + + --%test(Runs a granted package when its parent suitepath is given) + procedure user_runs_hidden_suite_path; + + --%test(Lists no logical suites without granted packages below them) + procedure user_no_empty_logical_suites; + + --%test(Raises an error for a suitepath without granted packages below it) + --%throws(-20204) + procedure user_hidden_path_not_found; + + --%test(Runs only granted packages matched by a package name with wildcards) + procedure user_runs_granted_by_wildcard; + + --%test(Runs only tests of granted packages matched by procedure name with wildcards) + procedure user_runs_granted_tests_by_wildcard; + + --%test(Runs granted packages below a suitepath with wildcards) + procedure user_runs_granted_by_path_wildcard; + + --%test(Raises an error for a suitepath with wildcards without granted packages below it) + --%throws(-20204) + procedure user_hidden_path_wildcard_not_found; + + --%endcontext + +end; +/ diff --git a/test/ut3_tester/core/annotations/test_annotation_manager.pkb b/test/ut3_tester/core/annotations/test_annotation_manager.pkb index d564e5d57..8eb3c2f6d 100644 --- a/test/ut3_tester/core/annotations/test_annotation_manager.pkb +++ b/test/ut3_tester/core/annotations/test_annotation_manager.pkb @@ -1,45 +1,34 @@ create or replace package body test_annotation_manager is - procedure disable_ddl_trigger is + procedure exec_autonomous(a_sql varchar2) is pragma autonomous_transaction; begin - execute immediate 'alter trigger ut3.ut_trigger_annotation_parsing disable'; - execute immediate 'begin ut3.ut_trigger_check.is_alive(); end;'; - end; - - procedure enable_ddl_trigger is - pragma autonomous_transaction; - begin - execute immediate 'alter trigger ut3.ut_trigger_annotation_parsing enable'; + execute immediate a_sql; end; procedure create_dummy_package is - pragma autonomous_transaction; begin - execute immediate q'[create or replace package dummy_package as + exec_autonomous(q'[create or replace package dummy_package as procedure some_dummy_procedure; - end;]'; + end;]'); end; procedure drop_dummy_package is - pragma autonomous_transaction; begin - execute immediate q'[drop package dummy_package]'; + exec_autonomous(q'[drop package dummy_package]'); exception when others then null; end; procedure recompile_dummy_package is - pragma autonomous_transaction; begin - execute immediate q'[alter package dummy_package compile]'; + exec_autonomous(q'[alter package dummy_package compile]'); end; procedure create_dummy_test_package is - pragma autonomous_transaction; begin - execute immediate q'[ + exec_autonomous(q'[ /* * Some multiline comments before package spec create or replace package dummy_test_package dummy comment to prove that we pick the right piece of code @@ -55,49 +44,46 @@ create or replace package body test_annotation_manager is --%test(dummy_test) --%beforetest(some_procedure) procedure some_dummy_test_procedure; - end;]'; - execute immediate q'[grant execute on dummy_test_package to public]'; + end;]'); + exec_autonomous(q'[grant execute on dummy_test_package to public]'); end; procedure modify_dummy_test_package is - pragma autonomous_transaction; begin - execute immediate q'[create or replace package dummy_test_package as + exec_autonomous(q'[create or replace package dummy_test_package as --%suite(dummy_test_suite) --%test(dummy_test) procedure some_dummy_test_procedure; - end;]'; + end;]'); end; procedure drop_dummy_test_package is - pragma autonomous_transaction; begin - execute immediate q'[drop package dummy_test_package]'; + exec_autonomous(q'[drop package dummy_test_package]'); exception when others then null; end; procedure recompile_dummy_test_package is - pragma autonomous_transaction; begin - execute immediate q'[alter package dummy_test_package compile]'; + exec_autonomous(q'[alter package dummy_test_package compile]'); end; - procedure create_parse_proc_as_ut3$user# is + procedure create_parse_proc_as_ut3_user is begin - ut3_tester_helper.main_helper.create_parse_proc_as_ut3$user#(); + ut3_tester_helper.main_helper.create_parse_proc_as_ut3_user(); end; - procedure parse_dummy_test_as_ut3$user# is + procedure parse_dummy_test_as_ut3_user is begin - ut3_tester_helper.main_helper.parse_dummy_test_as_ut3$user#(); + ut3_tester_helper.main_helper.parse_dummy_test_as_ut3_user(); end; - procedure drop_parse_proc_as_ut3$user# is + procedure drop_parse_proc_as_ut3_user is begin - ut3_tester_helper.main_helper.drop_parse_proc_as_ut3$user#(); + ut3_tester_helper.main_helper.drop_parse_proc_as_ut3_user(); exception when others then null; @@ -115,48 +101,44 @@ create or replace package body test_annotation_manager is begin select max(cache_id) into l_actual_cache_id - from ut3.ut_annotation_cache_info + from ut3_develop.ut_annotation_cache_info where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE' and parse_time >= a_start_date; ut.expect(l_actual_cache_id).to_be_not_null; open l_actual for select annotation_position, annotation_name, annotation_text, subobject_name - from ut3.ut_annotation_cache where cache_id = l_actual_cache_id + from ut3_develop.ut_annotation_cache where cache_id = l_actual_cache_id order by annotation_position; ut.expect(l_actual).to_be_empty(); end; - procedure assert_dummy_test_package(a_start_date date) is + procedure assert_dummy_test_package(a_start_time timestamp) is l_actual_cache_id integer; + l_data ut3_develop.ut_annotated_objects; + l_result sys_refcursor; l_actual sys_refcursor; l_expected sys_refcursor; begin - select max(cache_id) - into l_actual_cache_id - from ut3.ut_annotation_cache_info - where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE' - and parse_time >= a_start_date; - ut.expect(l_actual_cache_id).to_be_not_null; - - open l_actual for - select annotation_position, annotation_name, annotation_text, subobject_name - from ut3.ut_annotation_cache where cache_id = l_actual_cache_id - order by annotation_position; - open l_expected for - select 2 as annotation_position, 'suite' as annotation_name, - 'dummy_test_suite' as annotation_text, '' as subobject_name - from dual union all - select 3, 'rollback' , 'manual', '' as subobject_name - from dual union all - select 7, 'test' , 'dummy_test', 'some_dummy_test_procedure' as subobject_name - from dual union all - select 8, 'beforetest' , 'some_procedure', 'some_dummy_test_procedure' as subobject_name - from dual; - - ut.expect(l_actual).to_equal(l_expected); + select + ut3_develop.ut_annotated_object( + sys_context('USERENV', 'CURRENT_USER'), + 'DUMMY_TEST_PACKAGE', 'PACKAGE', a_start_time, + ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', 'dummy_test_suite', null ), + ut3_develop.ut_annotation( 3, 'rollback', 'manual', null ), + ut3_develop.ut_annotation( 7, 'test', 'dummy_test', 'some_dummy_test_procedure' ), + ut3_develop.ut_annotation( 8, 'beforetest', 'some_procedure', 'some_dummy_test_procedure' ) + ) + ) annotated_object + from dual; + + l_result := ut3_develop.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE', a_start_time); + fetch l_result bulk collect into l_data; + open l_actual for select value(x) as annotated_object from table(l_data) x where object_name = 'DUMMY_TEST_PACKAGE'; + ut.expect(l_actual).to_equal(l_expected).exclude('ANNOTATED_OBJECT/PARSE_TIME').join_by('ANNOTATED_OBJECT/OBJECT_NAME'); end; @@ -164,14 +146,14 @@ create or replace package body test_annotation_manager is l_actual_cache_id integer; begin --Arrange - disable_ddl_trigger(); + annotation_cache_helper.disable_ddl_trigger(); create_dummy_test_package(); --Act - enable_ddl_trigger(); + annotation_cache_helper.enable_ddl_trigger(); --Assert select max(cache_id) into l_actual_cache_id - from ut3.ut_annotation_cache_info + from ut3_develop.ut_annotation_cache_info where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; ut.expect(l_actual_cache_id).to_be_null; @@ -182,10 +164,10 @@ create or replace package body test_annotation_manager is l_start_date date; begin --Arrange - disable_ddl_trigger(); + annotation_cache_helper.disable_ddl_trigger(); create_dummy_test_package(); --Act - enable_ddl_trigger(); + annotation_cache_helper.enable_ddl_trigger(); l_start_date := sysdate; recompile_dummy_test_package(); --Assert @@ -197,13 +179,13 @@ create or replace package body test_annotation_manager is l_start_date date; begin --Arrange - disable_ddl_trigger(); + annotation_cache_helper.disable_ddl_trigger(); create_dummy_test_package(); create_dummy_package(); --Act - enable_ddl_trigger(); + annotation_cache_helper.enable_ddl_trigger(); l_start_date := sysdate; - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); --Assert assert_dummy_test_package(l_start_date); assert_dummy_package(l_start_date); @@ -215,7 +197,7 @@ create or replace package body test_annotation_manager is --Arrange open l_actual for select * - from ut3.ut_annotation_cache_info + from ut3_develop.ut_annotation_cache_info where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE'; ut.expect(l_actual).to_be_empty(); @@ -225,7 +207,7 @@ create or replace package body test_annotation_manager is --Assert open l_actual for select * - from ut3.ut_annotation_cache_info + from ut3_develop.ut_annotation_cache_info where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE'; ut.expect(l_actual).to_be_empty(); @@ -251,7 +233,7 @@ create or replace package body test_annotation_manager is --Assert open l_actual for select * - from ut3.ut_annotation_cache_info + from ut3_develop.ut_annotation_cache_info where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; @@ -259,74 +241,123 @@ create or replace package body test_annotation_manager is end; - --%test(Updates annotation cache when package recompiled) - procedure trg_update_modified_package is + procedure trg_populate_cache_after_purge is + l_start_date date; begin - null; + --Arrange + create_dummy_test_package(); + l_start_date := sysdate; + ut3_develop.ut_annotation_manager.purge_cache(sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE'); + --Act & Assert + assert_dummy_test_package(l_start_date); end; - procedure add_new_package is - l_actual_cache_id integer; - l_actual sys_refcursor; - l_start_date date; + procedure add_annotated_package is + l_start_time timestamp := systimestamp; + begin + --Arrange + create_dummy_test_package(); + --Act & Assert + assert_dummy_test_package( l_start_time ); + end; + + procedure remove_annotated_package is + l_start_time timestamp := systimestamp; begin + --Arrange + create_dummy_test_package(); + assert_dummy_test_package( l_start_time ); + --Act - l_start_date := sysdate; - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + drop_dummy_test_package(); + --Assert - select max(cache_id) - into l_actual_cache_id - from ut3.ut_annotation_cache_info - where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE' - and parse_time >= l_start_date; + ut.expect( + ut3_develop.ut_annotation_manager.get_annotated_objects( + sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time + ), + 'Annotations are empty after package was dropped' + ).to_be_empty(); + end; - ut.expect(l_actual_cache_id).to_be_not_null; + procedure add_not_annotated_package is + l_start_time timestamp := systimestamp; + begin + --Arrange + create_dummy_package(); + --Act & Assert + ut.expect( + ut3_develop.ut_annotation_manager.get_annotated_objects( + sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time + ), + 'Annotations are empty for not annotated package' + ).to_be_empty(); + end; - open l_actual for - select * - from ut3.ut_annotation_cache - where cache_id = l_actual_cache_id; + procedure remove_not_annotated_package is + l_start_time timestamp := systimestamp; + begin + --Arrange + create_dummy_package(); + ut.expect( + ut3_develop.ut_annotation_manager.get_annotated_objects( + sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time + ), + 'Annotations are empty for non annotated package' + ).to_be_empty(); - ut.expect(l_actual).to_be_empty(); + --Act + drop_dummy_package(); + --Assert + ut.expect( + ut3_develop.ut_annotation_manager.get_annotated_objects( + sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time + ), + 'Annotations are empty after non annoteted package was dropped' + ).to_be_empty(); end; - procedure update_modified_package is - l_actual integer; - l_start_date date; + procedure remove_annotations_from_pkg is + l_start_time timestamp := systimestamp; begin --Arrange - l_start_date := sysdate; - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); - recompile_dummy_package(); - l_start_date := sysdate; - $if dbms_db_version.version >= 18 $then - dbms_session.sleep(1); - $else - dbms_lock.sleep(1); - $end + create_dummy_test_package(); + assert_dummy_test_package( l_start_time ); --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + exec_autonomous(q'[create or replace package dummy_test_package as + procedure some_dummy_test_procedure; + end;]'); + --Assert - assert_dummy_package(l_start_date); + ut.expect( + ut3_develop.ut_annotation_manager.get_annotated_objects( + sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time + ) + ).to_be_empty(); end; - - procedure add_new_test_package is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_start_date date; + procedure add_annotations_to_package is + l_start_time timestamp := systimestamp; begin --Arrange - l_start_date := sysdate; + exec_autonomous(q'[create or replace package dummy_test_package as + procedure some_dummy_test_procedure; + end;]'); + ut.expect( + ut3_develop.ut_annotation_manager.get_annotated_objects( + sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time + ) + ).to_be_empty(); + --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + create_dummy_test_package(); + --Assert - assert_dummy_test_package(l_start_date); + assert_dummy_test_package( l_start_time ); end; - procedure update_modified_test_package is l_actual_cache_id integer; l_actual sys_refcursor; @@ -334,15 +365,15 @@ create or replace package body test_annotation_manager is l_start_date date; begin --Arrange - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); l_start_date := sysdate; modify_dummy_test_package(); --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); --Assert select max(cache_id) into l_actual_cache_id - from ut3.ut_annotation_cache_info + from ut3_develop.ut_annotation_cache_info where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE' and parse_time >= l_start_date; @@ -350,7 +381,7 @@ create or replace package body test_annotation_manager is open l_actual for select annotation_position, annotation_name, annotation_text, subobject_name - from ut3.ut_annotation_cache where cache_id = l_actual_cache_id + from ut3_develop.ut_annotation_cache where cache_id = l_actual_cache_id order by annotation_position; open l_expected for @@ -365,29 +396,35 @@ create or replace package body test_annotation_manager is procedure keep_dropped_data_in_cache is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_start_date date; + l_cache_count integer; + l_start_date date; begin - parse_dummy_test_as_ut3$user#(); l_start_date := sysdate; + parse_dummy_test_as_ut3_user(); drop_dummy_test_package(); --Act - parse_dummy_test_as_ut3$user#(); + parse_dummy_test_as_ut3_user(); --Assert - assert_dummy_test_package(l_start_date); + select count(1) + into l_cache_count + from ut3_develop.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') + and object_type = 'PACKAGE' + and object_name = 'DUMMY_TEST_PACKAGE' + and parse_time > l_start_date; + ut.expect( l_cache_count ).to_equal(1); end; procedure no_data_for_dropped_object is - l_result sys_refcursor; - l_data ut3.ut_annotated_objects; - l_actual sys_refcursor; + l_result sys_refcursor; + l_data ut3_develop.ut_annotated_objects; + l_actual sys_refcursor; + l_start_time timestamp := systimestamp; begin --Arrange - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); drop_dummy_test_package(); --Act - l_result := ut3.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + l_result := ut3_develop.ut_annotation_manager.get_annotated_objects( sys_context('USERENV', 'CURRENT_USER'),'PACKAGE', l_start_time ); fetch l_result bulk collect into l_data; open l_actual for select object_name from table(l_data) where object_name = 'DUMMY_TEST_PACKAGE'; --Assert @@ -396,20 +433,16 @@ create or replace package body test_annotation_manager is procedure cleanup_dropped_data_in_cache is l_cache_count integer; - l_actual sys_refcursor; - l_expected sys_refcursor; - l_start_date date; begin --Arrange - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); - l_start_date := sysdate; + ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); drop_dummy_test_package(); --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); --Assert select count(1) into l_cache_count - from ut3.ut_annotation_cache_info + from ut3_develop.ut_annotation_cache_info where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; @@ -418,5 +451,16 @@ create or replace package body test_annotation_manager is end; + procedure populate_cache_after_purge is + l_start_date date; + begin + --Arrange + create_dummy_test_package(); + l_start_date := sysdate; + ut3_develop.ut_annotation_manager.purge_cache(sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE'); + --Act & Assert + assert_dummy_test_package(l_start_date); + end; + end test_annotation_manager; / diff --git a/test/ut3_tester/core/annotations/test_annotation_manager.pks b/test/ut3_tester/core/annotations/test_annotation_manager.pks index fd5bc3410..7207917f3 100644 --- a/test/ut3_tester/core/annotations/test_annotation_manager.pks +++ b/test/ut3_tester/core/annotations/test_annotation_manager.pks @@ -3,22 +3,20 @@ create or replace package test_annotation_manager is --%suite(ut_annotation_manager) --%suitepath(utplsql.ut3_tester.core.annotations) + --%afterall(drop_dummy_test_package) + --%aftereach procedure cleanup_annotation_cache; - procedure disable_ddl_trigger; - - procedure enable_ddl_trigger; - procedure create_dummy_package; procedure drop_dummy_package; procedure create_dummy_test_package; - procedure create_parse_proc_as_ut3$user#; + procedure create_parse_proc_as_ut3_user; - procedure drop_parse_proc_as_ut3$user#; + procedure drop_parse_proc_as_ut3_user; procedure drop_dummy_test_package; @@ -45,37 +43,50 @@ create or replace package test_annotation_manager is --%beforetest(create_dummy_test_package) procedure trg_no_data_for_dropped_object; - --%test(Updates annotation cache when package recompiled) - procedure trg_update_modified_package; + --%test(Objects are populated on scan after cache was purged) + --%beforetest(annotation_cache_helper.disable_ddl_trigger) + --%aftertest(annotation_cache_helper.enable_ddl_trigger) + procedure trg_populate_cache_after_purge; --%endcontext - --%context(Without DDL trigger enabled) + --%context(Without DDL trigger) - --%beforeall(disable_ddl_trigger) + --%beforeall(annotation_cache_helper.disable_ddl_trigger) - --%afterall(enable_ddl_trigger) + --%afterall(annotation_cache_helper.enable_ddl_trigger) --%beforeeach(create_dummy_package) --%aftereach(drop_dummy_package) - --%test(Adds new package to annotation cache info when it is not unit test package) - procedure add_new_package; + --%test(Returns annotations when annotated package was created) + --%aftertest(drop_dummy_test_package) + procedure add_annotated_package; - --%test(Updates annotation cache info for modified package) - procedure update_modified_package; + --%test(Doesn't return annotations when annotated package was removed) + --%aftertest(drop_dummy_test_package) + procedure remove_annotated_package; - --%test(Adds annotations to cache for unit test package) - --%beforetest(create_dummy_test_package) + --%test(Doesn't return annotations when package doesn't contain annotations) + procedure add_not_annotated_package; + + --%test(Doesn't return annotations when package without annotations was dropped) + procedure remove_not_annotated_package; + + --%test(Doesn't return annotations when annotations removed from package) --%aftertest(drop_dummy_test_package) - procedure add_new_test_package; + procedure remove_annotations_from_pkg; + + --%test(Returns annotations when annotations were added to package) + --%aftertest(drop_dummy_test_package) + procedure add_annotations_to_package; --%test(Updates annotations in cache for modified test package) procedure update_modified_test_package; --%test(Keeps annotations in cache when object was removed but user can't see whole schema) - --%beforetest(create_dummy_test_package,create_parse_proc_as_ut3$user#) - --%aftertest(drop_parse_proc_as_ut3$user#) + --%beforetest(create_dummy_test_package,create_parse_proc_as_ut3_user) + --%aftertest(drop_parse_proc_as_ut3_user) procedure keep_dropped_data_in_cache; --%test(Does not return data for dropped object) @@ -84,6 +95,9 @@ create or replace package test_annotation_manager is --%test(Remove object from cache when object dropped and user can see whole schema) procedure cleanup_dropped_data_in_cache; + --%test(Objects are populated on scan after cache was purged) + procedure populate_cache_after_purge; + --%endcontext end test_annotation_manager; diff --git a/test/ut3_tester/core/annotations/test_annotation_parser.pkb b/test/ut3_tester/core/annotations/test_annotation_parser.pkb index c4c90c046..beb526863 100644 --- a/test/ut3_tester/core/annotations/test_annotation_parser.pkb +++ b/test/ut3_tester/core/annotations/test_annotation_parser.pkb @@ -1,75 +1,79 @@ create or replace package body test_annotation_parser is procedure test_proc_comments is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; - + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - -- %ann1(Name of suite) - -- wrong line - -- %ann2(some_value) - procedure foo; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' -- %ann1(Name of suite)' || chr(10), + ' -- wrong line' || chr(10), + ' -- %ann2(some_value)' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - - l_expected := ut3.ut_annotations( - ut3.ut_annotation(2,'suite',null, null), - ut3.ut_annotation(3,'displayname','Name of suite',null), - ut3.ut_annotation(4,'suitepath','all.globaltests',null), - ut3.ut_annotation(6,'ann1','Name of suite',null), - ut3.ut_annotation(8,'ann2','some_value','foo') + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2,'suite',null, null), + ut3_develop.ut_annotation(3,'displayname','Name of suite',null), + ut3_develop.ut_annotation(4,'suitepath','all.globaltests',null), + ut3_develop.ut_annotation(6,'ann1','Name of suite',null), + ut3_develop.ut_annotation(8,'ann2','some_value','foo') ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; procedure include_floating_annotations is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - -- %ann1(Name of suite) - -- %ann2(all.globaltests) - - --%test - procedure foo; - - -- %ann3(Name of suite) - -- %ann4(all.globaltests) - - --%test - procedure bar; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' -- %ann1(Name of suite)' || chr(10), + ' -- %ann2(all.globaltests)' || chr(10), + '' || chr(10), + ' --%test' || chr(10), + ' procedure foo;' || chr(10), + '' || chr(10), + ' -- %ann3(Name of suite)' || chr(10), + ' -- %ann4(all.globaltests)' || chr(10), + '' || chr(10), + ' --%test' || chr(10), + ' procedure bar;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3.ut_annotation( 6, 'ann1', 'Name of suite', null ), - ut3.ut_annotation( 7, 'ann2', 'all.globaltests', null ), - ut3.ut_annotation( 9, 'test', null, 'foo'), - ut3.ut_annotation( 12, 'ann3', 'Name of suite', null ), - ut3.ut_annotation( 13, 'ann4', 'all.globaltests', null ), - ut3.ut_annotation( 15, 'test', null, 'bar') + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), + ut3_develop.ut_annotation( 6, 'ann1', 'Name of suite', null ), + ut3_develop.ut_annotation( 7, 'ann2', 'all.globaltests', null ), + ut3_develop.ut_annotation( 9, 'test', null, 'foo'), + ut3_develop.ut_annotation( 12, 'ann3', 'Name of suite', null ), + ut3_develop.ut_annotation( 13, 'ann4', 'all.globaltests', null ), + ut3_develop.ut_annotation( 15, 'test', null, 'bar') ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -77,50 +81,51 @@ create or replace package body test_annotation_parser is end; procedure parse_complex_with_functions is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - --%test - procedure foo; - - - --%beforeeach - procedure foo2; - - --test comment - -- wrong comment - - - /* - describtion of the procedure - */ - --%beforeeach(key=testval) - PROCEDURE foo3(a_value number default null); - - --%all - function foo4(a_val number default null - , a_par varchar2 default := ''asdf''); - END;'; + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' --%test' || chr(10), + ' procedure foo;' || chr(10), + '' || chr(10), + '' || chr(10), + ' --%beforeeach' || chr(10), + ' procedure foo2;' || chr(10), + '' || chr(10), + ' --test comment' || chr(10), + ' -- wrong comment' || chr(10), + '' || chr(10), + '' || chr(10), + '/*' || chr(10), + ' describtion of the procedure' || chr(10), + ' */' || chr(10), + ' --%beforeeach(key=testval)' || chr(10), + ' PROCEDURE foo3(a_value number default null);' || chr(10), + '' || chr(10), + ' --%all' || chr(10), + ' function foo4(a_val number default null' || chr(10), + ' , a_par varchar2 default := ''asdf'');' || chr(10), + 'END;')); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3.ut_annotation( 6, 'test', null, 'foo' ), - ut3.ut_annotation( 10, 'beforeeach', null,'foo2' ), - ut3.ut_annotation( 20, 'beforeeach', 'key=testval','foo3' ), - ut3.ut_annotation( 23, 'all', null,'foo4' ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), + ut3_develop.ut_annotation( 6, 'test', null, 'foo' ), + ut3_develop.ut_annotation( 10, 'beforeeach', null,'foo2' ), + ut3_develop.ut_annotation( 20, 'beforeeach', 'key=testval','foo3' ), + ut3_develop.ut_annotation( 23, 'all', null,'foo4' ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -128,27 +133,30 @@ create or replace package body test_annotation_parser is end; procedure no_procedure_annotation is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -156,27 +164,30 @@ create or replace package body test_annotation_parser is end; procedure parse_accessible_by is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt accessible by (foo) AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt accessible by (foo) AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -184,30 +195,33 @@ create or replace package body test_annotation_parser is end; procedure complex_package_declaration is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt - ACCESSIBLE BY (calling_proc) - authid current_user - AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt' || chr(10), + ' ACCESSIBLE BY (calling_proc)' || chr(10), + ' authid current_user' || chr(10), + ' AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 5, 'suite', null, null ), - ut3.ut_annotation( 6, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 7, 'suitepath', 'all.globaltests', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 5, 'suite', null, null ), + ut3_develop.ut_annotation( 6, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 7, 'suitepath', 'all.globaltests', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -215,27 +229,30 @@ create or replace package body test_annotation_parser is end; procedure complex_text is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %suite - --%displayname(name = Name of suite) - -- %suitepath(key=all.globaltests,key2=foo,"--%some text") - - procedure foo; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' --%displayname(name = Name of suite)' || chr(10), + ' -- %suitepath(key=all.globaltests,key2=foo,"--%some text")' || chr(10), + '' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'name = Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'key=all.globaltests,key2=foo,"--%some text"', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'name = Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'key=all.globaltests,key2=foo,"--%some text"', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -243,32 +260,35 @@ create or replace package body test_annotation_parser is end; procedure ignore_annotations_in_comments is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - /* - Some comment - -- inlined - -- %ignored - */ - -- %suite - --%displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' /*' || chr(10), + ' Some comment' || chr(10), + ' -- inlined' || chr(10), + ' -- %ignored' || chr(10), + ' */' || chr(10), + ' -- %suite' || chr(10), + ' --%displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 7, 'suite', null, null ), - ut3.ut_annotation( 8, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 9, 'suitepath', 'all.globaltests', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 7, 'suite', null, null ), + ut3_develop.ut_annotation( 8, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 9, 'suitepath', 'all.globaltests', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -277,7 +297,7 @@ create or replace package body test_annotation_parser is procedure ignore_wrapped_package is l_source dbms_preprocessor.source_lines_t; - l_actual ut3.ut_annotations; + l_actual ut3_develop.ut_annotations; begin --Arrange l_source(1) := 'create or replace PACKAGE tst_wrapped_pck wrapped @@ -305,56 +325,61 @@ v58yvbLAXLi9gYHwoIvAgccti+Cmpg0DKLY= -- %some_annotation_like_text '; --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source,'PACKAGE'); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source,'PACKAGE'); --Assert ut.expect(anydata.convertCollection(l_actual)).to_be_empty(); end; procedure brackets_in_desc is - - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %suite(Name of suite (including some brackets) and some more text) -END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite(Name of suite (including some brackets) and some more text)' || chr(10), + 'END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', 'Name of suite (including some brackets) and some more text', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', 'Name of suite (including some brackets) and some more text', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; procedure test_space_before_annot_params is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - /* - Some comment - -- inlined - */ - -- %suite - -- %suitepath (all.globaltests) - - procedure foo; -END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' /*' || chr(10), + ' Some comment' || chr(10), + ' -- inlined' || chr(10), + ' */' || chr(10), + ' -- %suite' || chr(10), + ' -- %suitepath (all.globaltests)'|| chr(10), + '' || chr(10), + ' procedure foo;' || chr(10), + 'END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 6, 'suite', null, null ), - ut3.ut_annotation( 7, 'suitepath', 'all.globaltests', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 6, 'suite', null, null ), + ut3_develop.ut_annotation( 7, 'suitepath', 'all.globaltests', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -362,24 +387,27 @@ END;'; procedure test_windows_newline as - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite)' || chr(13) || chr(10) - || ' -- %suitepath(all.globaltests) - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(13) || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); @@ -387,75 +415,490 @@ END;'; procedure test_annot_very_long_name as - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - --%test - procedure very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_dit_it; - END;'; + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(Name of suite)' || chr(10), + ' -- %suitepath(all.globaltests)' || chr(10), + '' || chr(10), + ' --%test' || chr(10), + ' procedure very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_dit_it;' || chr(10), + ' END;' || chr(10) + )); --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3.ut_annotation( 6, 'test', null, 'very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_dit_it' ) + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), + ut3_develop.ut_annotation( 6, 'test', null, 'very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_dit_it' ) ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; procedure test_upper_annot is - l_source clob; - l_actual ut3.ut_annotations; - l_expected ut3.ut_annotations; + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; begin - l_source := 'PACKAGE test_tt AS - -- %SUITE - -- %DISPLAYNAME(Name of suite) - -- %SUITEPATH(all.globaltests) + --Arrange + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %SUITE' || chr(10), + ' -- %DISPLAYNAME(Name of suite)' || chr(10), + ' -- %SUITEPATH(all.globaltests)' || chr(10), + '' || chr(10), + ' -- %ANN1(Name of suite)' || chr(10), + ' -- %ANN2(all.globaltests)' || chr(10), + '' || chr(10), + ' --%TEST' || chr(10), + ' procedure foo;' || chr(10), + '' || chr(10), + ' -- %ANN3(Name of suite)' || chr(10), + ' -- %ANN4(all.globaltests)' || chr(10), + '' || chr(10), + ' --%TEST' || chr(10), + ' procedure bar;' || chr(10), + ' END;' || chr(10) + )); - -- %ANN1(Name of suite) - -- %ANN2(all.globaltests) + --Act + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); - --%TEST - procedure foo; + --Assert + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), + ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), + ut3_develop.ut_annotation( 6, 'ann1', 'Name of suite', null ), + ut3_develop.ut_annotation( 7, 'ann2', 'all.globaltests', null ), + ut3_develop.ut_annotation( 9, 'test', null, 'foo'), + ut3_develop.ut_annotation( 12, 'ann3', 'Name of suite', null ), + ut3_develop.ut_annotation( 13, 'ann4', 'all.globaltests', null ), + ut3_develop.ut_annotation( 15, 'test', null, 'bar') + ); - -- %ANN3(Name of suite) - -- %ANN4(all.globaltests) + ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - --%TEST - procedure bar; - END;'; + end; + + ------------------------------------------------------------ + -- replace_multiline_comments coverage tests + ------------------------------------------------------------ + procedure test_rmc_empty_source is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); --Assert - l_expected := ut3.ut_annotations( - ut3.ut_annotation( 2, 'suite', null, null ), - ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3.ut_annotation( 6, 'ann1', 'Name of suite', null ), - ut3.ut_annotation( 7, 'ann2', 'all.globaltests', null ), - ut3.ut_annotation( 9, 'test', null, 'foo'), - ut3.ut_annotation( 12, 'ann3', 'Name of suite', null ), - ut3.ut_annotation( 13, 'ann4', 'all.globaltests', null ), - ut3.ut_annotation( 15, 'test', null, 'bar') - ); + ut.expect(l_result.count).to_equal(0); + end; + + procedure test_rmc_no_ml_comment_marker is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'procedure foo is' || chr(10), + 'begin' || chr(10), + ' null;' || chr(10), + 'end;' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(ut3_tester_helper.main_helper.lines_to_str(l_result)).to_equal(ut3_tester_helper.main_helper.lines_to_str(l_input)); + end; + + procedure test_rmc_line_inside_ml_comment is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'x := 1; /* start' || chr(10), + 'this whole line is comment' || chr(10), + 'end comment */ x := 2;' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('x := 1; ' || chr(10)); + ut.expect(l_result(2)).to_equal(''); + ut.expect(l_result(3)).to_equal(' x := 2;' || chr(10)); + end; + + procedure test_rmc_ml_comment_closed_midline is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + '/* open' || chr(10), + 'still inside' || chr(10), + '*/ code /* remove this too */ kept' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(2)).to_equal(''); + ut.expect(l_result(3)).to_equal(' code kept' || chr(10)); + end; + + procedure test_rmc_fast_path_no_tokens is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + -- line 2 has none of / - ' so hits fast path B; line 1 needed to pass pre-scan + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + '/* comment */' || chr(10), + 'begin' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(2)).to_equal('begin' || chr(10)); + end; + + procedure test_rmc_ml_comment_single_line is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'x := /* inline comment */ 42;' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('x := 42;' || chr(10)); + end; + + procedure test_rmc_single_line_comment_preserved is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + '/* marker */' || chr(10), + ' -- %test annotation' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(2)).to_equal(' -- %test annotation' || chr(10)); + end; + + procedure test_rmc_string_literal_protects_markers is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'v := ''val /* not a comment */ here'';' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('v := ''val /* not a comment */ here'';' || chr(10)); + end; + + procedure test_rmc_string_literal_escaped_quotes is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'v := ''it''''s a /* test */'';' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('v := ''it''''s a /* test */'';' || chr(10)); + end; + + procedure test_rmc_q_quoted_string_literal is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'v := q''[/* not a comment */]'';' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('v := q''[/* not a comment */]'';' || chr(10)); + end; + + procedure test_rmc_unclosed_string_literal is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'v := ''hello /* inside unclosed' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('v := ''hello /* inside unclosed' || chr(10)); + end; + + procedure test_rmc_unclosed_q_string is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + c_line constant varchar2(100) := q'(v := q'[/* unclosed q-string)' || chr(10); + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list(c_line)); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal(c_line); + end; + + procedure test_rmc_multiple_ml_comments_one_line is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'a /* one */ := /* two */ 1;' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('a := 1;' || chr(10)); + end; + + procedure test_rmc_comment_after_string_with_slash is + l_input dbms_preprocessor.source_lines_t; + l_result dbms_preprocessor.source_lines_t; + begin + --Arrange + l_input := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'v := ''a/b''; -- this is /* not */ a ml comment' || chr(10) + )); + + --Act + l_result := ut3_develop.ut_utils.replace_multiline_comments(l_input); + + --Assert + ut.expect(l_result(1)).to_equal('v := ''a/b''; -- this is /* not */ a ml comment' || chr(10)); + end; + + procedure test_multiline_proc_header_lines is + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; + begin + --Arrange + -- procedure header spans multiple lines before terminating ; + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + '' || chr(10), + ' --%test' || chr(10), + ' procedure foo(' || chr(10), + ' a_param1 varchar2' || chr(10), + ' ,a_param2 number default null' || chr(10), + ' );' || chr(10), + ' END;' || chr(10) + )); + + --Act + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); + + --Assert + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 4, 'test', null, 'foo' ) + ); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + end; + + procedure test_non_comment_line_resets_block_lines is + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; + begin + --Arrange + -- a non-comment non-proc line between annotation and procedure breaks the association + -- %test becomes a floating top-level annotation with no subobject + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + '' || chr(10), + ' --%test' || chr(10), + ' pragma serially_reusable;' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); + + --Act + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); + + --Assert + -- %test is NOT associated with foo — accumulator was reset by pragma line + -- it surfaces as a top-level annotation with no subobject_name + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 4, 'test', null, null ) + ); + + ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + end; + + procedure test_annotation_not_at_line_start_ignored_lines is + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; + begin + --Arrange + -- code before -- means it is not at start of line and must be ignored + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' x := 1; -- %not_an_annotation' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); + + --Act + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); + + --Assert + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ) + ); + + ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + end; + + procedure test_whitespace_line_between_comment_and_proc_lines is + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; + begin + --Arrange + -- space-only line between annotation comment and procedure declaration is tolerated + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + '' || chr(10), + ' --%test' || chr(10), + ' ' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); + + --Act + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); + + --Assert + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 4, 'test', null, 'foo' ) + ); + + ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + end; + procedure test_space_between_dashes_and_qualifier_lines is + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; + begin + --Arrange + -- spaces between -- and % are skipped and annotation is still recognised + -- annotations are not adjacent to a procedure so they are top-level + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' -- %displayname(my suite)' || chr(10), + '' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); + + --Act + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); + + --Assert + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ), + ut3_develop.ut_annotation( 3, 'displayname', 'my suite', null ) + ); + + ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + end; + + procedure test_percent_not_after_dashes_ignored_lines is + l_source dbms_preprocessor.source_lines_t; + l_actual ut3_develop.ut_annotations; + l_expected ut3_develop.ut_annotations; + begin + --Arrange + -- -- present and % present on line but % is not immediately after -- + -- e.g. a regular comment that happens to mention 100% + l_source := ut3_tester_helper.main_helper.make_source(ut3_develop.ut_varchar2_list( + 'PACKAGE test_tt AS' || chr(10), + ' -- %suite' || chr(10), + ' -- coverage is 100% on this module' || chr(10), + ' procedure foo;' || chr(10), + ' END;' || chr(10) + )); + + --Act + l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source, 'PACKAGE'); + + --Assert + l_expected := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 2, 'suite', null, null ) + ); + + ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; end test_annotation_parser; -/ +/ \ No newline at end of file diff --git a/test/ut3_tester/core/annotations/test_annotation_parser.pks b/test/ut3_tester/core/annotations/test_annotation_parser.pks index a4fe3ed70..c61c14d3a 100644 --- a/test/ut3_tester/core/annotations/test_annotation_parser.pks +++ b/test/ut3_tester/core/annotations/test_annotation_parser.pks @@ -19,24 +19,57 @@ create or replace package test_annotation_parser is procedure complex_text; --%test(Ignores content of multi-line comments) procedure ignore_annotations_in_comments; - - --%test(Ignores wrapped package and does not raise exception) + -- %test(ignore wrapped package source) procedure ignore_wrapped_package; - --%test(Parses package level annotations with annotation params containing brackets) procedure brackets_in_desc; - --%test(Parses annotation text even with spaces before brackets) procedure test_space_before_annot_params; - -- %test(Parses source-code with Windows-style newline) procedure test_windows_newline; - - -- %test(Parses annotations with very long object names) + -- %test(parse annotations with very long procedure name) procedure test_annot_very_long_name; - -- %test(Parses upper case annotations) procedure test_upper_annot; + -- %test(empty source returns immediately without processing) + procedure test_rmc_empty_source; + -- %test(source with no multiline comment markers returned unchanged) + procedure test_rmc_no_ml_comment_marker; + -- %test(line entirely inside multiline comment is blanked) + procedure test_rmc_line_inside_ml_comment; + -- %test(closing delimiter mid-line falls through to scan remainder) + procedure test_rmc_ml_comment_closed_midline; + -- %test(fast path line with no slash dash or quote copied unchanged) + procedure test_rmc_fast_path_no_tokens; + -- %test(single-line block comment removed on same line) + procedure test_rmc_ml_comment_single_line; + -- %test(single-line comment preserved intact) + procedure test_rmc_single_line_comment_preserved; + -- %test(string literal containing comment markers not stripped) + procedure test_rmc_string_literal_protects_markers; + -- %test(string literal with escaped quotes handled correctly) + procedure test_rmc_string_literal_escaped_quotes; + -- %test(q-quoted string literal protects interior comment markers) + procedure test_rmc_q_quoted_string_literal; + -- %test(unclosed string literal copies remainder and exits scan) + procedure test_rmc_unclosed_string_literal; + -- %test(unclosed q-quoted string copies remainder and exits scan) + procedure test_rmc_unclosed_q_string; + -- %test(multiple block comments on single line all removed) + procedure test_rmc_multiple_ml_comments_one_line; + -- %test(comment markers after string with slash handled correctly) + procedure test_rmc_comment_after_string_with_slash; + --%test(Procedure header spanning multiple lines is handled correctly) + procedure test_multiline_proc_header_lines; + --%test(Non-comment line between annotation and procedure resets association) + procedure test_non_comment_line_resets_block_lines; + --%test(Comment with non-whitespace before dashes is not treated as annotation) + procedure test_annotation_not_at_line_start_ignored_lines; + --%test(Spaces between dashes and annotation qualifier are skipped correctly) + procedure test_space_between_dashes_and_qualifier_lines; + --%test(Percent sign not immediately after dashes is not treated as annotation) + procedure test_percent_not_after_dashes_ignored_lines; + end test_annotation_parser; -/ +/ \ No newline at end of file diff --git a/test/ut3_tester/core/annotations/test_before_after_annotations.pkb b/test/ut3_tester/core/annotations/test_before_after_annotations.pkb index e2f34e847..75bbadcc0 100644 --- a/test/ut3_tester/core/annotations/test_before_after_annotations.pkb +++ b/test/ut3_tester/core/annotations/test_before_after_annotations.pkb @@ -28,7 +28,7 @@ create or replace package body test_before_after_annotations is l_dummy_utility_pkg_body varchar2(32737); l_test_package_spec varchar2(32737); l_test_package_body varchar2(32737); - l_test_results ut3.ut_varchar2_list; + l_test_results ut3_develop.ut_varchar2_list; begin l_dummy_utility_pkg_spec := q'[ @@ -200,7 +200,7 @@ create or replace package body test_before_after_annotations is execute immediate l_test_package_body; --Execute the tests and collect the results - select * bulk collect into l_test_results from table(ut3.ut.run(('ut3_tester.dummy_before_after_test'))); + select * bulk collect into l_test_results from table(ut3_develop.ut.run(('ut3_tester.dummy_before_after_test'))); execute immediate 'drop package dummy_before_after_test'; execute immediate 'drop package shared_test_package'; diff --git a/test/ut3_tester/core/expectations/test_expectation_processor.pkb b/test/ut3_tester/core/expectations/test_expectation_processor.pkb index ab413616e..e93d93141 100644 --- a/test/ut3_tester/core/expectations/test_expectation_processor.pkb +++ b/test/ut3_tester/core/expectations/test_expectation_processor.pkb @@ -1,6 +1,8 @@ create or replace package body test_expectation_processor is gc_user constant varchar2(128) := sys_context('userenv','current_schema'); + gc_long_line_package constant varchar2(128) := 'TEST_EXPECTATION_LONG_LINE'; + gc_long_line constant varchar2(4000) := 'ut.expect(1).to_equal(2); /*'||rpad('*', 3900, '*')||'*/'; procedure who_called_expectation is l_stack_trace varchar2(4000); @@ -11,9 +13,9 @@ create or replace package body test_expectation_processor is handle number name 34f88e4420 124 package body SCH_TEST.UT_EXPECTATION_PROCESSOR 353dfeb2f8 26 SCH_TEST.UT_EXPECTATION_RESULT -cba249ce0 112 SCH_TEST.UT_EXPECTATION +cba2493ce0 112 SCH_TEST.UT_EXPECTATION 3539881cf0 21 SCH_TEST.UT_EXPECTATION_NUMBER -351a608008 7 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR +351a608008 9 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR 351a608018 12 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR 351a608018 24 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR 351a6862b8 6 anonymous block @@ -24,7 +26,7 @@ cba249ce0 112 SCH_TEST.UT_EXPECTATION 34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM 34f8ab9b10 74 SCH_TEST.UT_SUITE 34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM -cba24bfd0 75 SCH_TEST.UT_LOGICAL_SUITE +cba24bfad0 75 SCH_TEST.UT_LOGICAL_SUITE 353dfecf30 59 SCH_TEST.UT_RUN 34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM 357f5421e8 77 package body SCH_TEST.UT_RUNNER @@ -33,8 +35,8 @@ cba24bfd0 75 SCH_TEST.UT_LOGICAL_SUITE 20be951ab0 320 package body SCH_TEST.UT ]'; ut.expect( - ut3.ut_expectation_processor.who_called_expectation(l_stack_trace) - ).to_equal('at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 7 l_source_line varchar2(4000); + ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace) + ).to_equal('at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 9 l_source_line varchar2(4000); at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 12 at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 24'); end; @@ -47,24 +49,124 @@ at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 24'); l_stack_trace := q'[----- PL/SQL Call Stack ----- object line object handle number name -0x80e701d8 26 UT3.UT_EXPECTATION_RESULT -0x85e10150 112 UT3.UT_EXPECTATION -0x8b54bad8 21 UT3.UT_EXPECTATION_NUMBER -0x85cfd238 20 package body UT3.UT_EXAMPLETEST +0x80e701d8 26 UT3_DEVELOP.UT_EXPECTATION_RESULT +0x85e10150 112 UT3_DEVELOP.UT_EXPECTATION +0x8b54bad8 21 UT3_DEVELOP.UT_EXPECTATION_NUMBER +0x85cfd238 20 package body UT3_DEVELOP.UT_EXAMPLETEST 0x85def380 6 anonymous block 0x85e93750 1825 package body SYS.DBMS_SQL -0x80f4f608 129 UT3.UT_EXECUTABLE -0x80f4f608 65 UT3.UT_EXECUTABLE -0x8a116010 76 UT3.UT_TEST -0x8a3348a0 48 UT3.UT_SUITE_ITEM -0x887e9948 67 UT3.UT_LOGICAL_SUITE -0x8a26de20 59 UT3.UT_RUN -0x8a3348a0 48 UT3.UT_SUITE_ITEM +0x80f4f608 129 UT3_DEVELOP.UT_EXECUTABLE +0x80f4f608 65 UT3_DEVELOP.UT_EXECUTABLE +0x8a116010 76 UT3_DEVELOP.UT_TEST +0x8a3348a0 48 UT3_DEVELOP.UT_SUITE_ITEM +0x887e9948 67 UT3_DEVELOP.UT_LOGICAL_SUITE +0x8a26de20 59 UT3_DEVELOP.UT_RUN +0x8a3348a0 48 UT3_DEVELOP.UT_SUITE_ITEM 0x838d17c0 28 anonymous block ]'; ut.expect( - ut3.ut_expectation_processor.who_called_expectation(l_stack_trace) - ).to_be_like('at "UT3.UT_EXAMPLETEST", line 20 %'); + ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace) + ).to_be_like('at "UT3_DEVELOP.UT_EXAMPLETEST", line 20 %'); + end; + + procedure who_call_expectation_win_stack is + l_stack_trace varchar2(4000); + l_source_line varchar2(4000); + begin + l_stack_trace := q'[----- PL/SQL Call Stack ----- +object line object +handle number name +00007FF8547B7D30 124 package body SCH_TEST.UT_EXPECTATION_PROCESSOR +00007FF8547B7D30 26 SCH_TEST.UT_EXPECTATION_RESULT +00007FF8547B7D30 112 SCH_TEST.UT_EXPECTATION +00007FF8547B7D30 21 SCH_TEST.UT_EXPECTATION_NUMBER +00007FF8547B7D30 7 package body SCOTT.TEST_BETWNSTR.BASIC_USAGE +00007FF81FF207B0 345 type body SCOTT.TEST_BETWNSTR.BASIC_USAGE_TYP +00007FF8544B21B8 6 anonymous block +00007FF8267FBFC8 1721 package body SYS.DBMS_SQL.EXECUTE +00007FF852BCFC68 142 type body UT3_DEVELOP.UT_EXECUTABLE.DO_EXECUTE +00007FF852BCFC68 44 type body UT3_DEVELOP.UT_EXECUTABLE.DO_EXECUTE +00007FF8512F9A90 74 type body UT3_DEVELOP.UT_EXECUTABLE_TEST.DO_EXECUTE +00007FF8512F9A90 38 type body UT3_DEVELOP.UT_EXECUTABLE_TEST.DO_EXECUTE +00007FF8231A2088 79 type body UT3_DEVELOP.UT_TEST.DO_EXECUTE +00007FF81FF207B0 49 type body UT3_DEVELOP.UT_SUITE_ITEM.DO_EXECUTE +00007FF852C83270 66 type body UT3_DEVELOP.UT_SUITE.DO_EXECUTE +00007FF82165F3B0 67 type body UT3_DEVELOP.UT_RUN.DO_EXECUTE +00007FF81FF207B0 49 type body UT3_DEVELOP.UT_SUITE_ITEM.DO_EXECUTE +00007FF8266285C0 172 package body UT3_DEVELOP.UT_RUNNER.RUN +00007FF854710538 134 package body UT3_DEVELOP.UT.RUN_AUTONOMOUS +00007FF854710538 488 package body UT3_DEVELOP.UT.RUN +00007FF854710538 623 package body UT3_DEVELOP.UT.RUN +00007FF81CFFA388 1 anonymous block]'; + ut.expect( + ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace) + ).to_be_like('at "SCOTT.TEST_BETWNSTR.BASIC_USAGE", line 7 %'); + end; + + procedure create_long_line_package is + pragma autonomous_transaction; + begin + execute immediate 'create or replace package '||gc_long_line_package||' is + procedure long_line; +end;'; + execute immediate 'create or replace package body '||gc_long_line_package||' is + procedure long_line is + begin + '||gc_long_line||' + end; +end;'; + end; + + procedure drop_long_line_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package '||gc_long_line_package; + end; + + procedure who_called_exp_long_line is + l_stack_trace varchar2(4000); + l_result varchar2(32767); + begin + l_stack_trace := q'[----- PL/SQL Call Stack ----- + object line object + handle number name +0x80e701d8 26 UT3_DEVELOP.UT_EXPECTATION_RESULT +0x85e10150 112 UT3_DEVELOP.UT_EXPECTATION +0x8b54bad8 21 UT3_DEVELOP.UT_EXPECTATION_NUMBER +0x85cfd238 4 package body ]'||gc_user||'.'||gc_long_line_package||q'[ +0x85def380 6 anonymous block +]'; + l_result := ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace); + + ut.expect( l_result ).to_equal( + 'at "'||gc_user||'.'||gc_long_line_package||'", line 4 ' + || substr( gc_long_line, 1, 500 - length('[...]') ) || '[...]' + || chr(10) || 'at "anonymous block", line 6' + ); + end; + + procedure who_called_exp_long_stack is + l_stack_trace varchar2(32767); + l_result varchar2(32767); + begin + l_stack_trace := q'[----- PL/SQL Call Stack ----- + object line object + handle number name +0x80e701d8 26 UT3_DEVELOP.UT_EXPECTATION_RESULT +0x85e10150 112 UT3_DEVELOP.UT_EXPECTATION +0x8b54bad8 21 UT3_DEVELOP.UT_EXPECTATION_NUMBER +0x85cfd238 4 package body ]'||gc_user||'.'||gc_long_line_package||chr(10); + -- distinct callers, so the stack after the first frame is long + for i in 1 .. 100 loop + l_stack_trace := l_stack_trace + || '0x85cfd238 '||to_char(1000 + i)||' package body '||gc_user||'.'||gc_long_line_package||chr(10); + end loop; + + l_result := ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace); + + ut.expect( lengthb( l_result ) ).to_be_less_or_equal( 4000 ); + ut.expect( l_result ).to_be_like( 'at "'||gc_user||'.'||gc_long_line_package||'", line 4 ut.expect(1).to_equal(2); /*%' ); + ut.expect( l_result ).to_be_like( '%[...]' ); end; end; diff --git a/test/ut3_tester/core/expectations/test_expectation_processor.pks b/test/ut3_tester/core/expectations/test_expectation_processor.pks index 73cf60d11..4797dd613 100644 --- a/test/ut3_tester/core/expectations/test_expectation_processor.pks +++ b/test/ut3_tester/core/expectations/test_expectation_processor.pks @@ -14,6 +14,25 @@ create or replace package test_expectation_processor is --%test(parses stack trace and returns objects and line that called expectation) procedure who_called_expectation; + --%test(parses stack trace for Windows DB os - regression for #1000) + procedure who_call_expectation_win_stack; + + --%endcontext + + --%context(who_called_expectation_long_lines) + + --%beforeall + procedure create_long_line_package; + + --%afterall + procedure drop_long_line_package; + + --%test(truncates a long source line of the calling code - regression for #1397) + procedure who_called_exp_long_line; + + --%test(limits caller info to 4000 bytes when the call stack is long - regression for #1397) + procedure who_called_exp_long_stack; + --%endcontext end; diff --git a/test/ut3_tester/core/test_coverage_report_html_helper.pkb b/test/ut3_tester/core/test_coverage_report_html_helper.pkb new file mode 100644 index 000000000..a4cd36ed1 --- /dev/null +++ b/test/ut3_tester/core/test_coverage_report_html_helper.pkb @@ -0,0 +1,29 @@ +create or replace package body test_coverage_report_html_helper is + + gc_support_link constant varchar2(4000) := + '' || ut3_develop.ut_utils.gc_support_text || ''; + + function get_index(a_support_info boolean) return clob is + l_coverage_data ut3_develop.ut_coverage.t_coverage; + begin + return ut3_develop.ut_utils.table_to_clob( + ut3_develop.ut_coverage_report_html_helper.get_index( + a_coverage_data => l_coverage_data, + a_assets_path => null, + a_support_info => a_support_info + ) + ); + end; + + procedure index_includes_support_link is + begin + ut.expect( get_index(a_support_info => true) ).to_be_like( '%%' ); + end; + + procedure index_omits_support_link is + begin + ut.expect( get_index(a_support_info => false) ).not_to_be_like( '%' || ut3_develop.ut_utils.gc_support_url || '%' ); + end; + +end; +/ diff --git a/test/ut3_tester/core/test_coverage_report_html_helper.pks b/test/ut3_tester/core/test_coverage_report_html_helper.pks new file mode 100644 index 000000000..bad1192b8 --- /dev/null +++ b/test/ut3_tester/core/test_coverage_report_html_helper.pks @@ -0,0 +1,13 @@ +create or replace package test_coverage_report_html_helper is + + --%suite(coverage_report_html_helper) + --%suitepath(utplsql.ut3_tester.core) + + --%test(Index page footer includes support link by default) + procedure index_includes_support_link; + + --%test(Index page footer omits support link when switched off) + procedure index_omits_support_link; + +end; +/ diff --git a/test/ut3_tester/core/test_file_mapper.pkb b/test/ut3_tester/core/test_file_mapper.pkb index 3813c9450..fccc487bd 100644 --- a/test/ut3_tester/core/test_file_mapper.pkb +++ b/test/ut3_tester/core/test_file_mapper.pkb @@ -1,17 +1,17 @@ create or replace package body test_file_mapper is procedure default_mappings is - l_actual ut3.ut_file_mappings; - l_expected ut3.ut_file_mappings; + l_actual ut3_develop.ut_file_mappings; + l_expected ut3_develop.ut_file_mappings; begin --Arrange - l_expected := ut3.ut_file_mappings( - ut3.ut_file_mapping('C:\tests\helpers\core.pkb',sys_context('USERENV', 'CURRENT_USER'),'CORE','PACKAGE BODY'), - ut3.ut_file_mapping('tests/helpers/test_file_mapper.pkb',sys_context('USERENV', 'CURRENT_USER'),'TEST_FILE_MAPPER','PACKAGE BODY') + l_expected := ut3_develop.ut_file_mappings( + ut3_develop.ut_file_mapping('C:\tests\helpers\core.pkb',sys_context('USERENV', 'CURRENT_USER'),'CORE','PACKAGE BODY'), + ut3_develop.ut_file_mapping('tests/helpers/test_file_mapper.pkb',sys_context('USERENV', 'CURRENT_USER'),'TEST_FILE_MAPPER','PACKAGE BODY') ); --Act - l_actual := ut3.ut_file_mapper.build_file_mappings( - ut3.ut_varchar2_list( + l_actual := ut3_develop.ut_file_mapper.build_file_mappings( + ut3_develop.ut_varchar2_list( 'C:\tests\helpers\core.pkb', 'tests/helpers/test_file_mapper.pkb' ) @@ -21,18 +21,18 @@ create or replace package body test_file_mapper is end; procedure specific_owner is - l_actual ut3.ut_file_mappings; - l_expected ut3.ut_file_mappings; + l_actual ut3_develop.ut_file_mappings; + l_expected ut3_develop.ut_file_mappings; begin --Arrange - l_expected := ut3.ut_file_mappings( - ut3.ut_file_mapping('C:\source\core\types\ut_file_mapping.tpb','UT3','UT_FILE_MAPPING','TYPE BODY'), - ut3.ut_file_mapping('source/core/ut_file_mapper.pkb','UT3','UT_FILE_MAPPER','PACKAGE BODY') + l_expected := ut3_develop.ut_file_mappings( + ut3_develop.ut_file_mapping('C:\source\core\types\ut_file_mapping.tpb','UT3_DEVELOP','UT_FILE_MAPPING','TYPE BODY'), + ut3_develop.ut_file_mapping('source/core/ut_file_mapper.pkb','UT3_DEVELOP','UT_FILE_MAPPER','PACKAGE BODY') ); --Act - l_actual := ut3.ut_file_mapper.build_file_mappings( - 'UT3', - ut3.ut_varchar2_list( + l_actual := ut3_develop.ut_file_mapper.build_file_mappings( + 'UT3_DEVELOP', + ut3_develop.ut_varchar2_list( 'C:\source\core\types\ut_file_mapping.tpb', 'source/core/ut_file_mapper.pkb' ) diff --git a/test/ut3_tester/core/test_output_buffer.pkb b/test/ut3_tester/core/test_output_buffer.pkb index 7aab6f389..de53b957a 100644 --- a/test/ut3_tester/core/test_output_buffer.pkb +++ b/test/ut3_tester/core/test_output_buffer.pkb @@ -1,27 +1,95 @@ create or replace package body test_output_buffer is + -- Writer action that waits (up to 30 seconds) until the reader removes the buffer info. + -- It keeps the writer only as long as the test needs it, so it does not delay jobs of the following tests. + gc_wait_for_reader_to_finish constant varchar2(4000) := q'[ + for i in 1 .. 300 loop + select count(1) into l_info_count from ut3_develop.ut_output_buffer_info_tmp b where b.output_id = l_buffer.output_id; + exit when l_info_count = 0; + dbms_session.sleep(0.1); + end loop;]'; + + function long_text return varchar2 is + l_txt varchar2(32767); + begin + for i in 1 .. 100 loop + l_txt := l_txt||lpad('a text', 310, ',a text'); + end loop; + return l_txt; + end; + + -- Runs a_writer_actions in a separate session (scheduler job) on a buffer sharing output_id with a_reader. + -- The writer buffer is available to the actions as l_buffer. + procedure start_writer(a_reader ut3_develop.ut_output_buffer_base, a_writer_actions varchar2) is + begin + ut3_tester_helper.run_helper.run_as_job( + 'declare + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.'||a_reader.self_type||'(a_output_id => '''||a_reader.output_id||'''); + l_info_count integer; + begin + '||a_writer_actions||' + end;' + ); + end; + + procedure wait_for_writer_lock(a_reader ut3_develop.ut_output_buffer_base) is + c_max_wait_sec constant number := 30; + l_waited_sec number := 0; + begin + while a_reader.get_lock_status() = 0 and l_waited_sec < c_max_wait_sec loop + dbms_session.sleep(0.1); + l_waited_sec := l_waited_sec + 0.1; + end loop; + ut.expect(a_reader.get_lock_status(), 'Writer session holds the buffer lock').not_to_equal(0); + end; + + procedure reads_lines_from_writer(a_reader ut3_develop.ut_output_buffer_base) is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange - writer stays silent for 1 second longer than reader's initial timeout + start_writer( + a_reader, + q'[l_buffer.lock_buffer(); + dbms_session.sleep(1.2); + l_buffer.send_line('line 1'); + l_buffer.send_line('line 2'); + l_buffer.close();]' + ); + wait_for_writer_lock(a_reader); + --Act + open l_actual for + select to_char(text) as text from table(a_reader.get_lines(a_initial_timeout => 0.2, a_timeout_sec => 30)); + --Assert + open l_expected for + select 'line 1' as text from dual union all + select 'line 2' as text from dual; + ut.expect(l_actual).to_equal(l_expected); + end; + procedure test_receive is l_actual_text clob; l_actual_item_type varchar2(1000); l_remaining integer; l_expected_text clob; l_expected_item_type varchar2(1000); - l_buffer ut3.ut_output_buffer_base; + l_buffer ut3_develop.ut_output_buffer_base; begin --Arrange - l_buffer := ut3.ut_output_clob_table_buffer(); - l_expected_text := to_clob(lpad('a text', 31000, ',a text')) - || chr(10) || to_clob(lpad('a text', 31000, ',a text')) - || chr(13) || to_clob(lpad('a text', 31000, ',a text')) - || chr(13) || chr(10) || to_clob(lpad('a text', 31000, ',a text')) || to_clob(lpad('a text', 31000, ',a text')); + l_buffer := ut3_develop.ut_output_clob_table_buffer(); + l_expected_text := to_clob('a text') ||long_text() + || chr(10) || long_text() + || chr(13) || long_text() + || chr(13) || chr(10) || long_text() || long_text(); l_expected_item_type := lpad('some item type',1000,'-'); --Act + l_buffer.lock_buffer(); l_buffer.send_clob(l_expected_text, l_expected_item_type); l_buffer.close(); select text, item_type into l_actual_text, l_actual_item_type - from table(l_buffer.get_lines(0,0)); + from table(l_buffer.get_lines(0.1,0.1)); --Assert ut.expect(l_actual_text).to_equal(l_expected_text); @@ -32,11 +100,18 @@ create or replace package body test_output_buffer is ut.expect(l_remaining).to_equal(0); end; - + + procedure test_wait_for_producer is + l_buffer ut3_develop.ut_output_buffer_base; + begin + l_buffer := ut3_develop.ut_output_clob_table_buffer(); + ut.expect( l_buffer.get_lines_cursor(0.1) ).to_be_empty(); + end; + procedure test_doesnt_send_on_null_text is l_cur sys_refcursor; l_result integer; - l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer(); + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); begin ut3_tester_helper.run_helper.delete_buffer(); --Act @@ -48,26 +123,29 @@ create or replace package body test_output_buffer is procedure test_doesnt_send_on_null_elem is - l_cur sys_refcursor; - l_result integer; - l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer(); + l_actual sys_refcursor; + l_expected sys_refcursor; + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); l_message_id varchar2(255); l_text varchar2(4000); begin ut3_tester_helper.run_helper.delete_buffer(); --Act - l_buffer.send_lines(ut3.ut_varchar2_rows(null)); - l_buffer.send_lines(ut3.ut_varchar2_rows('test')); + l_buffer.send_lines(ut3_develop.ut_varchar2_rows(null)); + l_buffer.send_lines(ut3_develop.ut_varchar2_rows('test')); + + open l_actual for + select text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); + open l_expected for + select 'test' as text from dual; - select message_id, text into l_message_id, l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); - ut.expect(l_message_id).to_equal('1'); - ut.expect(l_text).to_equal('test'); + ut.expect(l_actual).to_equal(l_expected); end; procedure test_send_line is l_result varchar2(4000); c_expected constant varchar2(4000) := lpad('a text',4000,',a text'); - l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer(); + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); begin l_buffer.send_line(c_expected); @@ -80,17 +158,18 @@ create or replace package body test_output_buffer is l_result clob; l_remaining integer; l_expected clob; - l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer(); + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); l_start timestamp; l_duration interval day to second; begin --Arrange l_expected := 'a text'; + l_buffer.lock_buffer(); l_buffer.send_line(l_expected); l_start := localtimestamp; --Act begin - select text into l_result from table(l_buffer.get_lines(1,1)); + select text into l_result from table(l_buffer.get_lines(0,0.3)); ut.fail('Expected a timeout exception but nothing was raised'); exception when others then @@ -99,9 +178,9 @@ create or replace package body test_output_buffer is --Fetches data from output ut.expect(l_result).to_equal(l_expected); --Throws a timeout exception - ut.expect(dbms_utility.format_error_stack()).to_match('ORA'||ut3.ut_utils.gc_out_buffer_timeout); + ut.expect(dbms_utility.format_error_stack()).to_match('ORA'||ut3_develop.ut_utils.gc_out_buffer_timeout); --Waited for one second - ut.expect(l_duration).to_be_greater_than(interval '0.99' second); + ut.expect(l_duration).to_be_greater_or_equal(interval '0.3' second); end; select count(1) into l_remaining from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp) where output_id = l_buffer.output_id; @@ -110,40 +189,181 @@ create or replace package body test_output_buffer is end; - procedure test_purge(a_buffer ut3.ut_output_buffer_base ) is - l_stale_buffer ut3.ut_output_buffer_base := a_buffer; - l_fresh_buffer ut3.ut_output_buffer_base; - l_buffer ut3.ut_output_buffer_base; + procedure test_purge(a_buffer ut3_develop.ut_output_buffer_base ) is + l_stale_buffer ut3_develop.ut_output_buffer_base := a_buffer; + l_fresh_buffer ut3_develop.ut_output_buffer_base; + l_buffer ut3_develop.ut_output_buffer_base; begin --Arrange - l_stale_buffer.start_date := sysdate - 2; + l_stale_buffer.start_date := sysdate - 10; --initialize with new start date l_stale_buffer.init(); + l_stale_buffer.lock_buffer(); l_stale_buffer.send_line('some text'); l_stale_buffer.close(); - l_fresh_buffer := ut3.ut_output_table_buffer(); + l_fresh_buffer := ut3_develop.ut_output_table_buffer(); + l_fresh_buffer.lock_buffer(); l_fresh_buffer.send_line('some text'); l_fresh_buffer.close(); --Act - purge is performed on new buffer create - l_buffer := ut3.ut_output_table_buffer(); + l_buffer := ut3_develop.ut_output_table_buffer(); --Assert -- Data in "fresh" buffer remains - ut.expect( l_fresh_buffer.get_lines_cursor(0,0), l_buffer.self_type ).to_have_count(1); - -- Data in "slate" buffer is purged and so the call to get_lines_cursor throws ORA-20218 - ut.expect( l_stale_buffer.get_lines_cursor(0,0), l_buffer.self_type ).to_be_empty(); + ut.expect( l_fresh_buffer.get_lines_cursor(0,0), l_fresh_buffer.self_type ).to_have_count(1); + -- Data in "stale" buffer is purged and so the call to get_lines_cursor throws ORA-20218 + ut.expect( l_stale_buffer.get_lines_cursor(0,0), l_stale_buffer.self_type ).to_be_empty(); end; procedure test_purge_text_buffer is begin - test_purge(ut3.ut_output_table_buffer()); + test_purge(ut3_develop.ut_output_table_buffer()); end; procedure test_purge_clob_buffer is begin - test_purge(ut3.ut_output_clob_table_buffer()); + test_purge(ut3_develop.ut_output_clob_table_buffer()); + end; + + procedure text_buffer_send_multibyte is + l_input varchar2(32767); + l_max_len integer := ut3_develop.ut_utils.gc_max_storage_varchar2_len; + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + l_text varchar2(4000); + begin + --Arrange + ut3_tester_helper.run_helper.delete_buffer(); + l_input := rpad( '❤', l_max_len, 'a' ); + ut.expect( lengthb( l_input ) ).to_be_greater_than(l_max_len); + + --Act + l_buffer.send_line(l_input); + --Assert + select text into l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); + ut.expect(lengthb(l_text)).to_be_less_or_equal(l_max_len); + end; + + procedure text_buffer_send_clob_multib is + l_input clob; + l_max_len integer := ut3_develop.ut_utils.gc_max_storage_varchar2_len; + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + l_text varchar2(4000); + begin + --Arrange + ut3_tester_helper.run_helper.delete_buffer(); + l_input := rpad( '❤', l_max_len, 'a' ); + ut.expect( ut3_develop.ut_utils.lengthb_clob( l_input ) ).to_be_greater_than(l_max_len); + + --Act + l_buffer.send_clob(l_input); + --Assert + select text into l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); + ut.expect(lengthb(l_text)).to_be_less_or_equal(l_max_len); + end; + + procedure concurrent_calls_do_not_cause_exception is + l_consumer_buffer_instance ut3_develop.ut_output_buffer_base; + l_shared_output_id raw(32) := sys_guid(); + begin + ut3_tester_helper.run_helper.run_as_job('declare x ut3_develop.ut_output_buffer_base; begin x := ut3_develop.ut_output_table_buffer(a_output_id => '''||l_shared_output_id||'''); end;'); + dbms_session.sleep(0.5); + l_consumer_buffer_instance := ut3_develop.ut_output_table_buffer(a_output_id => l_shared_output_id); + end; + + procedure table_buffer_reads_from_writer is + begin + reads_lines_from_writer(ut3_develop.ut_output_table_buffer()); + end; + + procedure clob_buffer_reads_from_writer is + begin + reads_lines_from_writer(ut3_develop.ut_output_clob_table_buffer()); + end; + + procedure bulk_buffer_reads_from_writer is + begin + reads_lines_from_writer(ut3_develop.ut_output_bulk_buffer()); + end; + + procedure reader_stops_when_writer_ends is + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + l_lines ut3_develop.ut_varchar2_rows; + l_start timestamp; + l_duration interval day to second; + begin + --Arrange - writer keeps the lock for a while after sending and its session ends without calling close() + start_writer( + l_buffer, + q'[l_buffer.lock_buffer(); + l_buffer.send_line('line 1'); + dbms_session.sleep(0.5);]' + ); + wait_for_writer_lock(l_buffer); + l_start := localtimestamp; + --Act + begin + select to_char(text) bulk collect into l_lines + from table(l_buffer.get_lines(a_initial_timeout => 1, a_timeout_sec => 2)); + exception + when others then + ut.fail('Reader did not stop after writer session ended: '||sqlerrm); + end; + l_duration := localtimestamp - l_start; + --Assert + ut.expect(anydata.convertCollection(l_lines)).to_equal(anydata.convertCollection(ut3_develop.ut_varchar2_rows('line 1'))); + ut.expect(l_buffer.get_lock_status(), 'Writer lock released by session end').to_equal(0); + ut.expect(l_duration, 'Reader waited for writer session to end').to_be_greater_or_equal(interval '0.3' second); + end; + + procedure reader_times_out_on_idle_writer is + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + l_count integer; + begin + --Arrange - writer holds the lock without sending data until the reader gives up + start_writer( + l_buffer, + q'[l_buffer.lock_buffer(); + l_buffer.send_line('line 1');]' + ||gc_wait_for_reader_to_finish||q'[ + l_buffer.close();]' + ); + wait_for_writer_lock(l_buffer); + --Act + begin + select count(1) into l_count from table(l_buffer.get_lines(a_initial_timeout => 1, a_timeout_sec => 1)); + ut.fail('Expected a timeout exception but nothing was raised'); + exception + when others then + --Assert + ut.expect(dbms_utility.format_error_stack()).to_match('ORA'||ut3_develop.ut_utils.gc_out_buffer_timeout); + end; + end; + + procedure second_writer_cannot_lock is + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + begin + --Arrange - writer holds the lock until the test is done + start_writer( + l_buffer, + q'[l_buffer.lock_buffer();]' + ||gc_wait_for_reader_to_finish||q'[ + l_buffer.close();]' + ); + wait_for_writer_lock(l_buffer); + --Act + begin + l_buffer.lock_buffer(); + l_buffer.close(); + ut.fail('Expected lock_buffer to fail but it succeeded'); + exception + when others then + --Assert + ut.expect(sqlerrm).to_be_like('%Cannot allocate lock for output buffer of reporter%'); + end; + --Cleanup - let the writer finish + l_buffer.remove_buffer_info(); end; end test_output_buffer; diff --git a/test/ut3_tester/core/test_output_buffer.pks b/test/ut3_tester/core/test_output_buffer.pks index 24c2c01eb..1b5a04762 100644 --- a/test/ut3_tester/core/test_output_buffer.pks +++ b/test/ut3_tester/core/test_output_buffer.pks @@ -2,29 +2,70 @@ create or replace package test_output_buffer is --%suite(output_buffer) --%suitepath(utplsql.ut3_tester.core) - - --%test(Receives a line from buffer table and deletes) - procedure test_receive; - - --%test(Does not send line if null text given) - procedure test_doesnt_send_on_null_text; - - --%test(Does not send line if null text given for multiline case) - procedure test_doesnt_send_on_null_elem; - - --%test(Sends a line into buffer table) - procedure test_send_line; - - --%test(Waits For The Data To Appear For Specified Time) - procedure test_waiting_for_data; - - --%test(Purges text buffer data older than one day and leaves the rest) - --%throws(-20218) - procedure test_purge_text_buffer; - - --%test(Purges clob buffer data older than one day and leaves the rest) - --%throws(-20218) - procedure test_purge_clob_buffer; + + + --%context(Buffer is read in a different session than buffer write) + + --%test(Text buffer reader waits beyond initial timeout for writer holding the lock and reads all lines) + procedure table_buffer_reads_from_writer; + + --%test(Clob buffer reader waits beyond initial timeout for writer holding the lock and reads all lines) + procedure clob_buffer_reads_from_writer; + + --%test(Bulk buffer reader waits beyond initial timeout for writer holding the lock and reads all lines) + procedure bulk_buffer_reads_from_writer; + + --%test(Reader stops when writer session ends without closing the buffer) + procedure reader_stops_when_writer_ends; + + --%test(Reader times out when writer holds the lock and sends no data) + procedure reader_times_out_on_idle_writer; + + --%test(Writer cannot lock buffer that is locked by another session) + procedure second_writer_cannot_lock; + + --%endcontext + + --%context(Read and write within the same session) + + + --%test(Receives a line from buffer table and deletes) + procedure test_receive; + + --%test(Waits specified time for producer to lock the buffer ) + --%throws(-20218) + procedure test_wait_for_producer; + + --%test(Does not send line if null text given) + procedure test_doesnt_send_on_null_text; + + --%test(Does not send line if null text given for multiline case) + procedure test_doesnt_send_on_null_elem; + + --%test(Sends a line into buffer table) + procedure test_send_line; + + --%test(Waits For The Data To Appear For Specified Time) + procedure test_waiting_for_data; + + --%test(Purges text buffer data older than one day and leaves the rest) + procedure test_purge_text_buffer; + + --%test(Purges clob buffer data older than one day and leaves the rest) + procedure test_purge_clob_buffer; + + --%test(Successfully sends multibyte long line into text buffer) + procedure text_buffer_send_multibyte; + + --%test(Successfully sends multibyte long clob line into text buffer) + procedure text_buffer_send_clob_multib; + + --%beforetest(ut3_tester_helper.run_helper.slow_down_insert_into_table_buffer) + --%aftertest(ut3_tester_helper.run_helper.cleanup_slow_down_insert_into_table_buffer) + --%test(concurrent calls to init() procedure do not cause errors - Issue #985) + procedure concurrent_calls_do_not_cause_exception; + + --%endcontext end test_output_buffer; / diff --git a/test/ut3_tester/core/test_suite_builder.pkb b/test/ut3_tester/core/test_suite_builder.pkb index b49ecb2da..15aac2d01 100644 --- a/test/ut3_tester/core/test_suite_builder.pkb +++ b/test/ut3_tester/core/test_suite_builder.pkb @@ -1,29 +1,28 @@ create or replace package body test_suite_builder is function invoke_builder_for_annotations( - a_annotations ut3.ut_annotations, + a_annotations ut3_develop.ut_annotations, a_package_name varchar2 := 'TEST_SUITE_BUILDER_PACKAGE' ) return clob is - l_suites ut3.ut_suite_items; - l_suite ut3.ut_logical_suite; + l_suites ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_logical_suite; l_cursor sys_refcursor; l_type_cursor sys_refcursor; l_ctx dbms_xmlgen.ctxhandle; l_xml xmltype; begin open l_cursor for select value(x) from table( - ut3.ut_annotated_objects( - ut3.ut_annotated_object('UT3_TESTER', a_package_name, 'PACKAGE', systimestamp, a_annotations) + ut3_develop.ut_annotated_objects( + ut3_develop.ut_annotated_object('UT3_TESTER', a_package_name, 'PACKAGE', systimestamp, a_annotations) ) ) x; - l_suites := ut3.ut_suite_manager.build_suites_from_annotations( + l_suites := ut3_develop.ut_suite_manager.build_suites_from_annotations( a_owner_name => 'UT3_TESTER', a_annotated_objects => l_cursor, a_path => null, - a_object_name => a_package_name, - a_skip_all_objects => true + a_object_name => a_package_name ); - l_suite := treat( l_suites(l_suites.first) as ut3.ut_logical_suite); + l_suite := treat( l_suites(l_suites.first) as ut3_develop.ut_logical_suite); open l_type_cursor for select l_suite as "UT_LOGICAL_SUITE" from dual; l_ctx := dbms_xmlgen.newcontext(l_type_cursor); @@ -43,11 +42,11 @@ create or replace package body test_suite_builder is procedure no_suite_description is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -59,12 +58,12 @@ create or replace package body test_suite_builder is procedure suite_description_from_suite is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Some description', null), - ut3.ut_annotation(2, 'suite','Another description', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Some description', null), + ut3_develop.ut_annotation(2, 'suite','Another description', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -76,13 +75,13 @@ create or replace package body test_suite_builder is procedure suitepath_from_non_empty_path is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite',null, null), - ut3.ut_annotation(2, 'suitepath','org.utplsql.some', null), - ut3.ut_annotation(3, 'suitepath','dummy.utplsql.some', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite',null, null), + ut3_develop.ut_annotation(2, 'suitepath','org.utplsql.some', null), + ut3_develop.ut_annotation(3, 'suitepath','dummy.utplsql.some', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -94,14 +93,14 @@ create or replace package body test_suite_builder is procedure suite_descr_from_displayname is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Some description', null), - ut3.ut_annotation(2, 'suite','Another description', null), - ut3.ut_annotation(3, 'displayname','New description', null), - ut3.ut_annotation(4, 'displayname','Newest description', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Some description', null), + ut3_develop.ut_annotation(2, 'suite','Another description', null), + ut3_develop.ut_annotation(3, 'displayname','New description', null), + ut3_develop.ut_annotation(4, 'displayname','Newest description', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -113,31 +112,31 @@ create or replace package body test_suite_builder is procedure rollback_type_valid is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite',null, null), - ut3.ut_annotation(2, 'rollback','manual', null), - ut3.ut_annotation(3, 'rollback','bad', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite',null, null), + ut3_develop.ut_annotation(2, 'rollback','manual', null), + ut3_develop.ut_annotation(3, 'rollback','bad', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( - '%'||ut3.ut_utils.gc_rollback_manual||'%' + '%'||ut3_develop.ut_utils.gc_rollback_manual||'%' ); end; procedure rollback_type_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite',null, null), - ut3.ut_annotation(2, 'rollback','manual', null), - ut3.ut_annotation(3, 'rollback','bad', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite',null, null), + ut3_develop.ut_annotation(2, 'rollback','manual', null), + ut3_develop.ut_annotation(3, 'rollback','bad', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -149,12 +148,12 @@ create or replace package body test_suite_builder is procedure suite_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(8, 'suite','bad', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(8, 'suite','bad', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -166,12 +165,12 @@ create or replace package body test_suite_builder is procedure test_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -185,13 +184,13 @@ create or replace package body test_suite_builder is procedure test_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'test','Dup', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'test','Dup', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -203,13 +202,13 @@ create or replace package body test_suite_builder is procedure beforeall_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(8, 'beforeall', null, 'test_procedure'), - ut3.ut_annotation(9, 'beforeall', null, 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(8, 'beforeall', null, 'test_procedure'), + ut3_develop.ut_annotation(9, 'beforeall', null, 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -221,13 +220,13 @@ create or replace package body test_suite_builder is procedure beforeeach_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(8, 'beforeeach', null, 'test_procedure'), - ut3.ut_annotation(9, 'beforeeach', null, 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(8, 'beforeeach', null, 'test_procedure'), + ut3_develop.ut_annotation(9, 'beforeeach', null, 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -239,13 +238,13 @@ create or replace package body test_suite_builder is procedure afterall_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(8, 'afterall', null, 'test_procedure'), - ut3.ut_annotation(9, 'afterall', null, 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(8, 'afterall', null, 'test_procedure'), + ut3_develop.ut_annotation(9, 'afterall', null, 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -257,13 +256,13 @@ create or replace package body test_suite_builder is procedure aftereach_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(8, 'aftereach', null, 'test_procedure'), - ut3.ut_annotation(9, 'aftereach', null, 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(8, 'aftereach', null, 'test_procedure'), + ut3_develop.ut_annotation(9, 'aftereach', null, 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -275,13 +274,13 @@ create or replace package body test_suite_builder is procedure suitepath_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(3, 'suitepath','dummy.utplsql.some', null), - ut3.ut_annotation(4, 'suitepath','org.utplsql.some', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(3, 'suitepath','dummy.utplsql.some', null), + ut3_develop.ut_annotation(4, 'suitepath','org.utplsql.some', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -293,13 +292,13 @@ create or replace package body test_suite_builder is procedure displayname_annot_duplicated is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','Cool', null), - ut3.ut_annotation(4, 'displayname','New description', null), - ut3.ut_annotation(5, 'displayname','Newest description', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','Cool', null), + ut3_develop.ut_annotation(4, 'displayname','New description', null), + ut3_develop.ut_annotation(5, 'displayname','Newest description', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -311,12 +310,12 @@ create or replace package body test_suite_builder is procedure suitepath_annot_empty is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(3, 'suitepath',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(3, 'suitepath',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -328,12 +327,12 @@ create or replace package body test_suite_builder is procedure suitepath_annot_invalid_path is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'suitepath','path with spaces', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'suitepath','path with spaces', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -345,12 +344,12 @@ create or replace package body test_suite_builder is procedure displayname_annot_empty is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(3, 'displayname',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(3, 'displayname',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -362,12 +361,12 @@ create or replace package body test_suite_builder is procedure rollback_type_empty is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(3, 'rollback',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(3, 'rollback',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -379,12 +378,12 @@ create or replace package body test_suite_builder is procedure rollback_type_invalid is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'rollback','bad', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'rollback','bad', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -396,24 +395,24 @@ create or replace package body test_suite_builder is procedure multiple_before_after is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'first_before_all'), - ut3.ut_annotation(3, 'beforeall',null, 'another_before_all'), - ut3.ut_annotation(4, 'beforeeach',null, 'first_before_each'), - ut3.ut_annotation(5, 'beforeeach',null, 'another_before_each'), - ut3.ut_annotation(6, 'aftereach',null, 'first_after_each'), - ut3.ut_annotation(7, 'aftereach',null, 'another_after_each'), - ut3.ut_annotation(8, 'afterall',null, 'first_after_all'), - ut3.ut_annotation(9, 'afterall',null, 'another_after_all'), - ut3.ut_annotation(14, 'test','A test', 'some_test'), - ut3.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'first_before_all'), + ut3_develop.ut_annotation(3, 'beforeall',null, 'another_before_all'), + ut3_develop.ut_annotation(4, 'beforeeach',null, 'first_before_each'), + ut3_develop.ut_annotation(5, 'beforeeach',null, 'another_before_each'), + ut3_develop.ut_annotation(6, 'aftereach',null, 'first_after_each'), + ut3_develop.ut_annotation(7, 'aftereach',null, 'another_after_each'), + ut3_develop.ut_annotation(8, 'afterall',null, 'first_after_all'), + ut3_develop.ut_annotation(9, 'afterall',null, 'another_after_all'), + ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), + ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), + ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), + ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), + ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -450,24 +449,24 @@ create or replace package body test_suite_builder is procedure multiple_standalone_bef_aft is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall', 'some_package.first_before_all',null), - ut3.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), - ut3.ut_annotation(4, 'beforeeach', 'first_before_each',null), - ut3.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), - ut3.ut_annotation(6, 'aftereach', 'first_after_each',null), - ut3.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), - ut3.ut_annotation(8, 'afterall', 'first_after_all',null), - ut3.ut_annotation(9, 'afterall', 'another_after_all',null), - ut3.ut_annotation(14, 'test','A test', 'some_test'), - ut3.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall', 'some_package.first_before_all',null), + ut3_develop.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), + ut3_develop.ut_annotation(4, 'beforeeach', 'first_before_each',null), + ut3_develop.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), + ut3_develop.ut_annotation(6, 'aftereach', 'first_after_each',null), + ut3_develop.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), + ut3_develop.ut_annotation(8, 'afterall', 'first_after_all',null), + ut3_develop.ut_annotation(9, 'afterall', 'another_after_all',null), + ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), + ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), + ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), + ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), + ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -505,16 +504,16 @@ create or replace package body test_suite_builder is procedure before_after_on_single_proc is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'do_stuff'), - ut3.ut_annotation(3, 'beforeeach',null, 'do_stuff'), - ut3.ut_annotation(4, 'aftereach',null, 'do_stuff'), - ut3.ut_annotation(5, 'afterall',null, 'do_stuff'), - ut3.ut_annotation(6, 'test','A test', 'some_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'do_stuff'), + ut3_develop.ut_annotation(3, 'beforeeach',null, 'do_stuff'), + ut3_develop.ut_annotation(4, 'aftereach',null, 'do_stuff'), + ut3_develop.ut_annotation(5, 'afterall',null, 'do_stuff'), + ut3_develop.ut_annotation(6, 'test','A test', 'some_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -539,27 +538,27 @@ create or replace package body test_suite_builder is procedure multiple_mixed_bef_aft is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall', null,'first_before_all'), - ut3.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), - ut3.ut_annotation(4, 'beforeeach', 'first_before_each',null), - ut3.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), - ut3.ut_annotation(6, 'aftereach', null, 'first_after_each'), - ut3.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), - ut3.ut_annotation(8, 'afterall', 'first_after_all',null), - ut3.ut_annotation(9, 'afterall', 'another_after_all',null), - ut3.ut_annotation(14, 'test','A test', 'some_test'), - ut3.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test'), - ut3.ut_annotation(21, 'beforeall', null,'last_before_all'), - ut3.ut_annotation(22, 'aftereach', null, 'last_after_each'), - ut3.ut_annotation(23, 'afterall', null, 'last_after_all') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall', null,'first_before_all'), + ut3_develop.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), + ut3_develop.ut_annotation(4, 'beforeeach', 'first_before_each',null), + ut3_develop.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), + ut3_develop.ut_annotation(6, 'aftereach', null, 'first_after_each'), + ut3_develop.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), + ut3_develop.ut_annotation(8, 'afterall', 'first_after_all',null), + ut3_develop.ut_annotation(9, 'afterall', 'another_after_all',null), + ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), + ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), + ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), + ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), + ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test'), + ut3_develop.ut_annotation(21, 'beforeall', null,'last_before_all'), + ut3_develop.ut_annotation(22, 'aftereach', null, 'last_after_each'), + ut3_develop.ut_annotation(23, 'afterall', null, 'last_after_all') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -601,16 +600,16 @@ create or replace package body test_suite_builder is procedure before_after_mixed_with_test is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'do_stuff'), - ut3.ut_annotation(3, 'beforeeach',null, 'do_stuff'), - ut3.ut_annotation(4, 'aftereach',null, 'do_stuff'), - ut3.ut_annotation(5, 'afterall',null, 'do_stuff'), - ut3.ut_annotation(6, 'test','A test', 'do_stuff') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'do_stuff'), + ut3_develop.ut_annotation(3, 'beforeeach',null, 'do_stuff'), + ut3_develop.ut_annotation(4, 'aftereach',null, 'do_stuff'), + ut3_develop.ut_annotation(5, 'afterall',null, 'do_stuff'), + ut3_develop.ut_annotation(6, 'test','A test', 'do_stuff') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -628,18 +627,18 @@ create or replace package body test_suite_builder is procedure suite_from_context is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(4, 'context','a_context', null), - ut3.ut_annotation(5, 'displayname','A context', null), - ut3.ut_annotation(6, 'beforeall',null, 'context_setup'), - ut3.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3.ut_annotation(8, 'endcontext',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(5, 'name','a_context', null), + ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -649,6 +648,9 @@ create or replace package body test_suite_builder is '' || '%' || '%' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || '' || '%a_contextA contextsome_package.a_context' || '%' || @@ -661,9 +663,6 @@ create or replace package body test_suite_builder is '%' || '' || '' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || '' || '' || '%some_packagesuite_level_beforeall' || @@ -674,21 +673,183 @@ create or replace package body test_suite_builder is ); end; + procedure nested_contexts is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 1, 'suite','Cool', null), + ut3_develop.ut_annotation( 2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation( 3, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation( 4, 'context','A context', null), + ut3_develop.ut_annotation( 5, 'name','a_context', null), + ut3_develop.ut_annotation( 6, 'beforeall',null, 'context_setup'), + ut3_develop.ut_annotation( 7, 'test', 'First test in context', 'first_test_in_a_context'), + ut3_develop.ut_annotation( 8, 'context','A nested context', null), + ut3_develop.ut_annotation( 9, 'name','a_nested_context', null), + ut3_develop.ut_annotation(10, 'beforeall',null, 'nested_context_setup'), + ut3_develop.ut_annotation(11, 'test', 'Test in nested context', 'test_in_nested_context'), + ut3_develop.ut_annotation(12, 'endcontext',null, null), + ut3_develop.ut_annotation(13, 'context',null, null), + ut3_develop.ut_annotation(14, 'name','nested_context_2', null), + ut3_develop.ut_annotation(15, 'test', 'Test in nested context', 'test_in_nested_context_2'), + ut3_develop.ut_annotation(16, 'context','a_nested_context_3', null), + ut3_develop.ut_annotation(17, 'test', 'Test in nested context', 'test_in_nested_context_3'), + ut3_develop.ut_annotation(18, 'endcontext',null, null), + ut3_develop.ut_annotation(19, 'endcontext',null, null), + ut3_develop.ut_annotation(20, 'test', 'Second test in context', 'second_test_in_a_context'), + ut3_develop.ut_annotation(21, 'endcontext',null, null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '%' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '' || + '%a_contextA contextsome_package.a_context' || + '%' || + '' || + '%first_test_in_a_contextFirst test in contextsome_package.a_context.first_test_in_a_context' || + '%' || + '' || + '%a_nested_contextA nested contextsome_package.a_context.a_nested_context' || + '%' || + '' || + '%test_in_nested_contextTest in nested contextsome_package.a_context.a_nested_context.test_in_nested_context' || + '%' || + '' || + '' || + '%some_packagenested_context_setup' || + '%' || + '%' || + '' || + '%nested_context_2nested_context_2some_package.a_context.nested_context_2' || + '%' || + '' || + '%test_in_nested_context_2Test in nested contextsome_package.a_context.nested_context_2.test_in_nested_context_2' || + '%' || + '' || + '%nested_context_#1a_nested_context_3some_package.a_context.nested_context_2.nested_context_#1' || + '%' || + '' || + '%test_in_nested_context_3Test in nested contextsome_package.a_context.nested_context_2.nested_context_#1.test_in_nested_context_3' || + '%' || + '' || + '' || + '%' || + '' || + '' || + '%' || + '' || + '%second_test_in_a_contextSecond test in contextsome_package.a_context.second_test_in_a_context' || + '%' || + '' || + '' || + '%some_packagecontext_setup' || + '%' || + '' || + '' || + '' || + '' || + '%some_packagesuite_level_beforeall' || + '%' || + '' || + ''|| + '' + ); + end; + + procedure nested_contexts_2 is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation( 1, 'suite','Cool', null), + ut3_develop.ut_annotation( 2, 'suitepath','path', null), + ut3_develop.ut_annotation( 3, 'context','Level 1', null), + ut3_develop.ut_annotation( 4, 'name','context_1', null), + ut3_develop.ut_annotation( 5, 'context','Level 1.1', null), + ut3_develop.ut_annotation( 6, 'name','context_1_1', null), + ut3_develop.ut_annotation( 7, 'test', 'Test 1.1.1', 'test_1_1_1'), + ut3_develop.ut_annotation( 8, 'test', 'Test 1.1.2', 'test_1_1_2'), + ut3_develop.ut_annotation( 9, 'endcontext', null, null), + ut3_develop.ut_annotation(10, 'endcontext', null, null), + ut3_develop.ut_annotation(11, 'context','Level 2', null), + ut3_develop.ut_annotation(12, 'name','context_2', null), + ut3_develop.ut_annotation(13, 'test', 'Test 2.1', 'test_2_1'), + ut3_develop.ut_annotation(14, 'endcontext',null, null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%%' || + '' || + '%context_1Level 1path.some_package.context_1' || + '%' || + '' || + '%context_1_1Level 1.1path.some_package.context_1.context_1_1' || + '%' || + '' || + '%test_1_1_1Test 1.1.1path.some_package.context_1.context_1_1.test_1_1_1' || + '%' || + '' || + '%test_1_1_2Test 1.1.2path.some_package.context_1.context_1_1.test_1_1_2' || + '%' || + '' || + '%' || + '%' || + '' || + '%' || + '%' || + '%'|| + '' + ); + -- Test both contexts separately due to ordering + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%%' || + '' || + '%context_2Level 2path.some_package.context_2' || + '%' || + '' || + '%test_2_1Test 2.1path.some_package.context_2.test_2_1' || + '%' || + '%' || + '%' || + '%' || + '%'|| + '' + ); + end; + + procedure before_after_in_context is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite', 'Cool', null), - ut3.ut_annotation(2, 'test', 'In suite', 'suite_level_test'), - ut3.ut_annotation(3, 'context', 'a_context', null), - ut3.ut_annotation(4, 'beforeall', 'context_beforeall', null), - ut3.ut_annotation(5, 'beforeeach', null, 'context_beforeeach'), - ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), - ut3.ut_annotation(7, 'aftereach', 'context_aftereach' ,null), - ut3.ut_annotation(8, 'afterall', null, 'context_afterall'), - ut3.ut_annotation(9, 'endcontext', null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite', 'Cool', null), + ut3_develop.ut_annotation(2, 'test', 'In suite', 'suite_level_test'), + ut3_develop.ut_annotation(3, 'context', 'A context', null), + ut3_develop.ut_annotation(4, 'beforeall', 'context_beforeall', null), + ut3_develop.ut_annotation(5, 'beforeeach', null, 'context_beforeeach'), + ut3_develop.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(7, 'aftereach', 'context_aftereach' ,null), + ut3_develop.ut_annotation(8, 'afterall', null, 'context_afterall'), + ut3_develop.ut_annotation(9, 'endcontext', null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -698,7 +859,11 @@ create or replace package body test_suite_builder is '' || '%' || '%' || - '%a_context' || + '%suite_level_test' || + '%%suite_level_test%' || + '%' || + '%' || + '%nested_context_#1A contextsome_package.nested_context_#1' || '%' || '%' || '%test_in_a_context' || @@ -710,10 +875,6 @@ create or replace package body test_suite_builder is '%%context_beforeall%' || '%%context_afterall%' || '%' || - '%' || - '%suite_level_test' || - '%%suite_level_test%' || - '%' || '%' || '%'|| '' @@ -726,19 +887,19 @@ create or replace package body test_suite_builder is procedure before_after_out_of_context is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3.ut_annotation(3, 'beforeeach',null, 'suite_level_beforeeach'), - ut3.ut_annotation(4, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(5, 'context','a_context', null), - ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), - ut3.ut_annotation(7, 'endcontext',null, null), - ut3.ut_annotation(8, 'aftereach',null, 'suite_level_aftereach'), - ut3.ut_annotation(9, 'afterall',null, 'suite_level_afterall') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation(3, 'beforeeach',null, 'suite_level_beforeeach'), + ut3_develop.ut_annotation(4, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation(5, 'context',null, null), + ut3_develop.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(7, 'endcontext',null, null), + ut3_develop.ut_annotation(8, 'aftereach',null, 'suite_level_aftereach'), + ut3_develop.ut_annotation(9, 'afterall',null, 'suite_level_afterall') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -748,7 +909,13 @@ create or replace package body test_suite_builder is '' || '%' || '%' || - '%a_context' || + '%suite_level_test' || + '%%suite_level_beforeeach%' || + '%%suite_level_test%' || + '%%suite_level_aftereach%' || + '%' || + '%' || + '%nested_context_#1nested_context_#1some_package.nested_context_#1' || '%' || '%' || '%test_in_a_context' || @@ -758,12 +925,6 @@ create or replace package body test_suite_builder is '%' || '%' || '%' || - '%' || - '%suite_level_test' || - '%%suite_level_beforeeach%' || - '%%suite_level_test%' || - '%%suite_level_aftereach%' || - '%' || '%' || '%%suite_level_beforeall%' || '%%suite_level_afterall%' || @@ -776,40 +937,48 @@ create or replace package body test_suite_builder is procedure context_without_endcontext is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(4, 'context','A context', null), - ut3.ut_annotation(5, 'beforeall',null, 'context_setup'), - ut3.ut_annotation(7, 'test', 'In context', 'test_in_a_context') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation(4, 'context','Some context', null), + ut3_develop.ut_annotation(5, 'name','a_context', null), + ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( - '%Invalid annotation "--\%context". Cannot find following "--\%endcontext". Annotation ignored.%at package "UT3_TESTER.SOME_PACKAGE", line 4%' + '%Missing "--\%endcontext" annotation for a "--\%context" annotation. The end of package is considered end of context.%at package "UT3_TESTER.SOME_PACKAGE", line 4%' ,'\' ); ut.expect(l_actual).to_be_like( ''|| '' || - '%' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.test_in_a_context' || - '%' || - '' || - '' || - '%some_packagesuite_level_beforeall' || - '%some_packagecontext_setup' || - '%' || - '' || + '%' || + '%' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '%' || + '%a_contextSome contextsome_package.a_context' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || + '%' || + '' || + '' || + '%some_packagecontext_setup' || + '%' || + '%' || + '' || + '' || + '%some_packagesuite_level_beforeall' || + '%' || + '' || ''|| '' ); @@ -817,31 +986,34 @@ create or replace package body test_suite_builder is procedure endcontext_without_context is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(4, 'context','a_context', null), - ut3.ut_annotation(5, 'displayname','A context', null), - ut3.ut_annotation(6, 'beforeall',null, 'context_setup'), - ut3.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3.ut_annotation(8, 'endcontext',null, null), - ut3.ut_annotation(9, 'endcontext',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(5, 'name','a_context', null), + ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null), + ut3_develop.ut_annotation(9, 'endcontext',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( - '%Invalid annotation "--\%endcontext". Cannot find preceding "--\%context". Annotation ignored.%at package "UT3_TESTER.SOME_PACKAGE", line 9%' + '%Extra "--\%endcontext" annotation found. Cannot find corresponding "--\%context". Annotation ignored.%at package "UT3_TESTER.SOME_PACKAGE", line 9%' ,'\' ); ut.expect(l_actual).to_be_like( ''|| '' || '%' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || '' || '%a_contextA contextsome_package.a_context' || '%' || @@ -850,16 +1022,13 @@ create or replace package body test_suite_builder is '%' || '' || '' || - '%some_packagecontext_setup' || + '%some_packagecontext_setup' || '%' || '' || '' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || '' || '' || - '%some_packagesuite_level_beforeall' || + '%some_packagesuite_level_beforeall' || '%' || '' || ''|| @@ -867,56 +1036,67 @@ create or replace package body test_suite_builder is ); end; - --%test(Gives warning when two contexts have the same name) procedure duplicate_context_name is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(4, 'context','a_context', null), - ut3.ut_annotation(5, 'displayname','A context', null), - ut3.ut_annotation(6, 'beforeall',null, 'context_setup'), - ut3.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3.ut_annotation(8, 'endcontext',null, null), - ut3.ut_annotation(9, 'context','a_context', null), - ut3.ut_annotation(10, 'displayname','A context', null), - ut3.ut_annotation(11, 'beforeall',null, 'setup_in_duplicated_context'), - ut3.ut_annotation(12, 'test', 'In duplicated context', 'test_in_duplicated_context'), - ut3.ut_annotation(13, 'endcontext',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(5, 'name','a_context', null), + ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null), + ut3_develop.ut_annotation(9, 'context','A context', null), + ut3_develop.ut_annotation(10, 'name','a_context', null), + ut3_develop.ut_annotation(11, 'beforeall',null, 'setup_in_duplicated_context'), + ut3_develop.ut_annotation(12, 'test', 'In duplicated context', 'test_in_duplicated_context'), + ut3_develop.ut_annotation(13, 'endcontext',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( - '%Context name must be unique in a suite. Context and all of it's content ignored.%at package "UT3_TESTER.SOME_PACKAGE", line 9%' + '%Context name "a_context" already used in this scope. Name must be unique. Using fallback name nested_context_#2.%%' ,'\' ); ut.expect(l_actual).to_be_like( ''|| '' || '%' || - '' || - '%a_contextA contextsome_package.a_context' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || - '%' || - '' || - '' || - '%some_packagecontext_setup' || - '%' || - '' || - '' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '' || + '%a_contextA contextsome_package.a_context' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || + '%' || + '' || + '' || + '%some_packagecontext_setup' || + '%' || + '' || + '' || + '' || + '%nested_context_#2A contextsome_package.nested_context_#2' || + '%' || + '' || + '%test_in_duplicated_contextIn duplicated contextsome_package.nested_context_#2.test_in_duplicated_context' || + '%' || + '' || + '' || + '%some_packagesetup_in_duplicated_context' || + '%' || + '' || + '' || '' || '' || - '%some_packagesuite_level_beforeall' || + '%some_packagesuite_level_beforeall' || '%' || '' || ''|| @@ -924,55 +1104,350 @@ create or replace package body test_suite_builder is ); end; - procedure throws_value_empty is + procedure hard_stop_in_ctx_name is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; + l_bad_name varchar2(100); begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(3, 'test','A test with empty throws annotation', 'A_TEST_PROCEDURE'), - ut3.ut_annotation(3, 'throws',null, 'A_TEST_PROCEDURE') + l_bad_name := 'ctx_with_dot.in_it'; + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(4, 'context',null, null), + ut3_develop.ut_annotation(5, 'name',l_bad_name, null), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(13, 'endcontext',null, null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%Invalid value "'||l_bad_name||'" for context name. Context name ignored and fallback to auto-name "nested_context_#1"%' ); + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '' || + '%nested_context_#1nested_context_#1some_package.nested_context_#1' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || + '%' || + '%' || + '%' || + '%' || + ''|| + '' + ); + end; + + procedure name_with_spaces_invalid is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + l_bad_name varchar2(100); + begin + --Arrange + l_bad_name := 'context name with spaces'; + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(4, 'context',null, null), + ut3_develop.ut_annotation(5, 'name',l_bad_name, null), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(13, 'endcontext',null, null) + ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( - '%%"--%throws" annotation requires a parameter. Annotation ignored.%%' + '%Invalid value "'||l_bad_name||'" for context name. Context name ignored and fallback to auto-name "nested_context_#1"%' + ); + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '' || + '%nested_context_#1nested_context_#1some_package.nested_context_#1' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || + '%' || + '%' || + '%' || + '%' || + ''|| + '' + ); + end; + + procedure duplicate_name_annotation is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(5, 'name','a_context_name', null), + ut3_develop.ut_annotation(6, 'name','a_newer_context_name', null), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null), + ut3_develop.ut_annotation(12, 'test', 'In suite', 'suite_level_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%Duplicate annotation "--%name". Annotation ignored.%%' + ,'\' + ); + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '' || + '%a_context_nameA contextsome_package.a_context_name' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.a_context_name.test_in_a_context' || + '%' || + '' || + '' || + '' || + '' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '' || + '' || + '' || + ''|| + '' + ); + end; + + procedure name_outside_of_context is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(3, 'name','a_context_name', null), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null), + ut3_develop.ut_annotation(12, 'test', 'In suite', 'suite_level_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%' + ,'\' + ); + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '' || + '%nested_context_#1A contextsome_package.nested_context_#1' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || + '%' || + '' || + '' || + '' || + '' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '' || + '' || + '' || + ''|| + '' + ); + end; + + procedure name_empty_value is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(5, 'name',null, null), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null), + ut3_develop.ut_annotation(12, 'test', 'In suite', 'suite_level_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%' + ,'\' + ); + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '' || + '%nested_context_#1A contextsome_package.nested_context_#1' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || + '%' || + '' || + '' || + '' || + '' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '' || + '' || + '' || + ''|| + '' + ); + end; + + procedure multiple_contexts is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(6, 'test', 'In context1', 'test_in_a_context1'), + ut3_develop.ut_annotation(7, 'endcontext',null, null), + ut3_develop.ut_annotation(8, 'context','A context', null), + ut3_develop.ut_annotation(10, 'test', 'In context2', 'test_in_a_context2'), + ut3_develop.ut_annotation(11, 'endcontext',null, null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%' + ,'\' + ); + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '' || + '%nested_context_#1A contextsome_package.nested_context_#1' || + '%' || + '' || + '%test_in_a_context1In context1some_package.nested_context_#1.test_in_a_context1' || + '%' || + '' || + '' || + '' || + '' || + '' || + '%nested_context_#2A contextsome_package.nested_context_#2' || + '%' || + '' || + '%test_in_a_context2In context2some_package.nested_context_#2.test_in_a_context2' || + '%' || + '' || + '' || + '' || + '' || + '' || + '' || + '' || + ''|| + '' + ); + end; + + procedure context_name_case_insensitive is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(5, 'name','a_Context', null), + ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '%' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '' || + '%a_contextA contextsome_package.a_context' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || + '%' || + '' || + '' || + '%some_packagecontext_setup' || + '%' || + '' || + '' || + '' || + '' || + '%some_packagesuite_level_beforeall' || + '%' || + '' || + ''|| + '' ); end; - procedure throws_value_invalid is + procedure throws_value_empty is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(3, 'test','A test with invalid throws annotation', 'A_TEST_PROCEDURE'), - ut3.ut_annotation(3, 'throws',' -20145 , bad_variable_name ', 'A_TEST_PROCEDURE') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(3, 'test','A test with empty throws annotation', 'A_TEST_PROCEDURE'), + ut3_develop.ut_annotation(3, 'throws',null, 'A_TEST_PROCEDURE') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( - '%%Invalid parameter value "bad_variable_name" for "--%throws" annotation. Parameter ignored.%%' + '%%"--%throws" annotation requires a parameter. Annotation ignored.%%' ); end; procedure before_aftertest_multi is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(14, 'test','A test', 'some_test'), - ut3.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), + ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), + ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), + ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), + ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -993,16 +1468,16 @@ create or replace package body test_suite_builder is procedure before_aftertest_twice is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(14, 'test','A test', 'some_test'), - ut3.ut_annotation(15, 'beforetest','before_test_proc, before_test_proc2', 'some_test'), - ut3.ut_annotation(16, 'beforetest','before_test_proc3', 'some_test'), - ut3.ut_annotation(18, 'aftertest','after_test_proc,after_test_proc2', 'some_test'), - ut3.ut_annotation(20, 'aftertest','after_test_proc3', 'some_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), + ut3_develop.ut_annotation(15, 'beforetest','before_test_proc, before_test_proc2', 'some_test'), + ut3_develop.ut_annotation(16, 'beforetest','before_test_proc3', 'some_test'), + ut3_develop.ut_annotation(18, 'aftertest','after_test_proc,after_test_proc2', 'some_test'), + ut3_develop.ut_annotation(20, 'aftertest','after_test_proc3', 'some_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1025,14 +1500,14 @@ create or replace package body test_suite_builder is procedure before_aftertest_pkg_proc is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(14, 'test','A test', 'some_test'), - ut3.ut_annotation(15, 'beforetest','external_package.before_test_proc', 'some_test'), - ut3.ut_annotation(18, 'aftertest','external_package.after_test_proc', 'some_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), + ut3_develop.ut_annotation(15, 'beforetest','external_package.before_test_proc', 'some_test'), + ut3_develop.ut_annotation(18, 'aftertest','external_package.after_test_proc', 'some_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1051,14 +1526,14 @@ create or replace package body test_suite_builder is procedure before_aftertest_mixed_syntax is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(14, 'test','A test', 'some_test'), - ut3.ut_annotation(15, 'beforetest','external_package.before_test_proc, before_test_proc2', 'some_test'), - ut3.ut_annotation(18, 'aftertest','external_package.after_test_proc, after_test_proc2', 'some_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), + ut3_develop.ut_annotation(15, 'beforetest','external_package.before_test_proc, before_test_proc2', 'some_test'), + ut3_develop.ut_annotation(18, 'aftertest','external_package.after_test_proc, after_test_proc2', 'some_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1079,14 +1554,14 @@ create or replace package body test_suite_builder is procedure test_annotation_ordering is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(4, 'test','B test', 'b_test'), - ut3.ut_annotation(10, 'test','Z test', 'z_test'), - ut3.ut_annotation(14, 'test','A test', 'a_test') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(4, 'test','B test', 'b_test'), + ut3_develop.ut_annotation(10, 'test','Z test', 'z_test'), + ut3_develop.ut_annotation(14, 'test','A test', 'a_test') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1103,13 +1578,13 @@ create or replace package body test_suite_builder is procedure test_bad_procedure_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'bad_procedure_annotation',null, 'some_procedure'), - ut3.ut_annotation(6, 'test','A test', 'do_stuff') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'bad_procedure_annotation',null, 'some_procedure'), + ut3_develop.ut_annotation(6, 'test','A test', 'do_stuff') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1119,13 +1594,13 @@ create or replace package body test_suite_builder is procedure test_bad_package_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(17, 'bad_package_annotation',null, null), - ut3.ut_annotation(24, 'test','A test', 'do_stuff') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(17, 'bad_package_annotation',null, null), + ut3_develop.ut_annotation(24, 'test','A test', 'do_stuff') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1135,13 +1610,13 @@ create or replace package body test_suite_builder is procedure test_tag_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'tags','testtag', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags','testtag', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1152,17 +1627,17 @@ create or replace package body test_suite_builder is '%testtag%'|| '%%' ); - + end; procedure suite_tag_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(3, 'tags','suitetag', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags','suitetag', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1173,18 +1648,18 @@ create or replace package body test_suite_builder is '%suitetag%'|| '%%' ); - + end; - + procedure test_tags_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'tags','testtag,testtag2,testtag3', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags','testtag,testtag2,testtag3', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1195,17 +1670,17 @@ create or replace package body test_suite_builder is '%testtagtesttag2testtag3%'|| '%%' ); - + end; procedure suite_tags_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(3, 'tags','suitetag,suitetag1,suitetag2', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags','suitetag,suitetag1,suitetag2', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1216,19 +1691,19 @@ create or replace package body test_suite_builder is '%suitetagsuitetag1suitetag2%'|| '%%' ); - + end; procedure test_2line_tags_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'tags','testtag', 'test_procedure'), - ut3.ut_annotation(10, 'tags','testtag2', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags','testtag', 'test_procedure'), + ut3_develop.ut_annotation(10, 'tags','testtag2', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1239,18 +1714,18 @@ create or replace package body test_suite_builder is '%testtagtesttag2%'|| '%%' ); - + end; procedure suite_2line_tags_annotation is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(3, 'tags','suitetag', null), - ut3.ut_annotation(4, 'tags','suitetag1', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags','suitetag', null), + ut3_develop.ut_annotation(4, 'tags','suitetag1', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1261,17 +1736,17 @@ create or replace package body test_suite_builder is '%suitetagsuitetag1%'|| '%%' ); - + end; procedure test_empty_tag is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'tags',null, 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags',null, 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1280,17 +1755,17 @@ create or replace package body test_suite_builder is '%%"--%tags" annotation requires a tag value populated. Annotation ignored.%%'|| '%%' ); - + end; - + procedure suite_empty_tag is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(3, 'tags',null, null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags',null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1299,19 +1774,19 @@ create or replace package body test_suite_builder is '%"--%tags" annotation requires a tag value populated. Annotation ignored.%%'|| '%%' ); - + end; procedure test_duplicate_tag is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'tags','testtag,testtag1,testtag', 'test_procedure'), - ut3.ut_annotation(10, 'tags',' testtag,testtag1,testtag2', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags','testtag,testtag1,testtag', 'test_procedure'), + ut3_develop.ut_annotation(10, 'tags',' testtag,testtag1,testtag2', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1322,18 +1797,18 @@ create or replace package body test_suite_builder is '%testtagtesttag1testtag2%'|| '%%' ); - + end; - + procedure suite_duplicate_tag is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(3, 'tags','suitetag,suitetag1,suitetag', null), - ut3.ut_annotation(4, 'tags',' suitetag1,suitetag2', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags','suitetag,suitetag1,suitetag', null), + ut3_develop.ut_annotation(4, 'tags',' suitetag1,suitetag2', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1344,18 +1819,18 @@ create or replace package body test_suite_builder is '%suitetagsuitetag1suitetag2%'|| '%%' ); - + end; procedure test_empty_tag_between is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'tags','testtag,, ,testtag1', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags','testtag,, ,testtag1', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1366,17 +1841,17 @@ create or replace package body test_suite_builder is '%testtagtesttag1%'|| '%%' ); - + end; - + procedure suite_empty_tag_between is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(3, 'tags','suitetag,, ,suitetag1', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags','suitetag,, ,suitetag1', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1387,18 +1862,18 @@ create or replace package body test_suite_builder is '%suitetagsuitetag1%'|| '%%' ); - - end; + + end; procedure test_special_char_tag is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3.ut_annotation(9, 'tags','#?$%^&*!|\/@][', 'test_procedure') + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags','#?$%^&*!|\/@][', 'test_procedure') ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1409,17 +1884,17 @@ create or replace package body test_suite_builder is '%#?$%^&*!|\/@][%'|| '%%' ); - + end; - + procedure suite_special_char_tag is l_actual clob; - l_annotations ut3.ut_annotations; + l_annotations ut3_develop.ut_annotations; begin --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(2, 'suite','testsuite', null), - ut3.ut_annotation(3, 'tags','#?$%^&*!|\/@][', null) + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags','#?$%^&*!|\/@][', null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); @@ -1431,7 +1906,67 @@ create or replace package body test_suite_builder is '%%' ); - end; + end; + + procedure test_spaces_in_tag is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags',' good_tag , bad tag , good-tag ', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags',' good_tag , bad tag , good-tag ', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%good_taggood-tag%'|| + 'good_taggood-tag%' + ); + ut.expect(l_actual).to_be_like( + '%Invalid value "bad tag" for "--%tags" annotation.'|| + ' See documentation for details on valid tag values. Annotation value ignored.' || + '%at package "UT3_TESTER.SOME_PACKAGE", line 3%' + ); + ut.expect(l_actual).to_be_like( + '%Invalid value "bad tag" for "--%tags" annotation.'|| + ' See documentation for details on valid tag values. Annotation value ignored.' || + '%at package "UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE", line 9%' + ); + end; + + procedure test_minus_in_tag is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(2, 'suite','testsuite', null), + ut3_develop.ut_annotation(3, 'tags',' good_tag , -invalid_tag , good-tag ', null), + ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3_develop.ut_annotation(9, 'tags',' good_tag , -invalid_tag , good-tag ', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%good_taggood-tag%'|| + 'good_taggood-tag%' + ); + ut.expect(l_actual).to_be_like( + '%Invalid value "-invalid_tag" for "--%tags" annotation.'|| + ' See documentation for details on valid tag values. Annotation value ignored.' || + '%at package "UT3_TESTER.SOME_PACKAGE", line 3%' + ); + ut.expect(l_actual).to_be_like( + '%Invalid value "-invalid_tag" for "--%tags" annotation.'|| + ' See documentation for details on valid tag values. Annotation value ignored.' || + '%at package "UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE", line 9%' + ); + end; end test_suite_builder; / diff --git a/test/ut3_tester/core/test_suite_builder.pks b/test/ut3_tester/core/test_suite_builder.pks index 721db153f..09ff3c0b3 100644 --- a/test/ut3_tester/core/test_suite_builder.pks +++ b/test/ut3_tester/core/test_suite_builder.pks @@ -2,221 +2,246 @@ create or replace package test_suite_builder is --%suite(suite_builder) --%suitepath(utplsql.ut3_tester.core) - --%context(suite) - --%displayname(--%suite annotation) + --%context(--%suite annotation) + --%name(suite) - --%test(Sets suite name from package name and leaves description empty) - procedure no_suite_description; + --%test(Sets suite name from package name and leaves description empty) + procedure no_suite_description; - --%test(Sets suite description using first --%suite annotation) - procedure suite_description_from_suite; + --%test(Sets suite description using first --%suite annotation) + procedure suite_description_from_suite; - --%test(Gives warning if more than one --%suite annotation used) - procedure suite_annot_duplicated; + --%test(Gives warning if more than one --%suite annotation used) + procedure suite_annot_duplicated; --%endcontext - --%context(displayname) - --%displayname(--%displayname annotation) + --%context(--%displayname annotation) - --%test(Overrides suite description using first --%displayname annotation) - procedure suite_descr_from_displayname; + --%test(Overrides suite description using first --%displayname annotation) + procedure suite_descr_from_displayname; - --%test(Gives warning if more than one --%displayname annotation used) - procedure displayname_annot_duplicated; + --%test(Gives warning if more than one --%displayname annotation used) + procedure displayname_annot_duplicated; - --%test(Gives warning if --%displayname annotation has no value) - procedure displayname_annot_empty; + --%test(Gives warning if --%displayname annotation has no value) + procedure displayname_annot_empty; --%endcontext - --%context(test) - --%displayname(--%test annotation) + --%context(--%test annotation) - --%test(Creates a test item for procedure annotated with --%test annotation) - procedure test_annotation; + --%test(Creates a test item for procedure annotated with --%test annotation) + procedure test_annotation; - --%test(Gives warning if more than one --%test annotation used) - procedure test_annot_duplicated; + --%test(Gives warning if more than one --%test annotation used) + procedure test_annot_duplicated; - --%test(Is added to suite according to annotation order in package spec) - procedure test_annotation_ordering; + --%test(Is added to suite according to annotation order in package spec) + procedure test_annotation_ordering; --%endcontext - --%context(suitepath) - --%displayname(--%suitepath annotation) + --%context(--%suitepath annotation) - --%test(Sets suite path using first --%suitepath annotation) - procedure suitepath_from_non_empty_path; + --%test(Sets suite path using first --%suitepath annotation) + procedure suitepath_from_non_empty_path; - --%test(Gives warning if more than one --%suitepath annotation used) - procedure suitepath_annot_duplicated; + --%test(Gives warning if more than one --%suitepath annotation used) + procedure suitepath_annot_duplicated; - --%test(Gives warning if --%suitepath annotation has no value) - procedure suitepath_annot_empty; + --%test(Gives warning if --%suitepath annotation has no value) + procedure suitepath_annot_empty; - --%test(Gives warning if --%suitepath annotation has invalid value) - procedure suitepath_annot_invalid_path; + --%test(Gives warning if --%suitepath annotation has invalid value) + procedure suitepath_annot_invalid_path; --%endcontext - --%context(rollback) - --%displayname(--%rollback annotation) + --%context--%rollback annotation) - --%test(Sets rollback type using first --%rollback annotation) - procedure rollback_type_valid; + --%test(Sets rollback type using first --%rollback annotation) + procedure rollback_type_valid; - --%test(Gives warning if more than one --%rollback annotation used) - procedure rollback_type_duplicated; + --%test(Gives warning if more than one --%rollback annotation used) + procedure rollback_type_duplicated; - --%test(Gives warning if --%rollback annotation has no value) - procedure rollback_type_empty; + --%test(Gives warning if --%rollback annotation has no value) + procedure rollback_type_empty; - --%test(Gives warning if --%rollback annotation has invalid value) - procedure rollback_type_invalid; + --%test(Gives warning if --%rollback annotation has invalid value) + procedure rollback_type_invalid; --%endcontext - --%context(before_after_all_each) - --%displayname(--%before/after all/each annotations) + --%context(--%before/after all/each annotations) - --%test(Supports multiple before/after all/each procedure level definitions) - procedure multiple_before_after; + --%test(Supports multiple before/after all/each procedure level definitions) + procedure multiple_before_after; - --%test(Supports multiple before/after all/each standalone level definitions) - procedure multiple_standalone_bef_aft; + --%test(Supports multiple before/after all/each standalone level definitions) + procedure multiple_standalone_bef_aft; - --%test(Supports mixing before/after all/each annotations on single procedure) - procedure before_after_on_single_proc; + --%test(Supports mixing before/after all/each annotations on single procedure) + procedure before_after_on_single_proc; - --%test(Supports mixed before/after all/each as standalone and procedure level definitions) - procedure multiple_mixed_bef_aft; + --%test(Supports mixed before/after all/each as standalone and procedure level definitions) + procedure multiple_mixed_bef_aft; - --%test(Gives warning if more than one --%beforeall annotation used on procedure) - procedure beforeall_annot_duplicated; + --%test(Gives warning if more than one --%beforeall annotation used on procedure) + procedure beforeall_annot_duplicated; - --%test(Gives warning if more than one --%beforeeach annotation used on procedure) - procedure beforeeach_annot_duplicated; + --%test(Gives warning if more than one --%beforeeach annotation used on procedure) + procedure beforeeach_annot_duplicated; - --%test(Gives warning if more than one --%afterall annotation used on procedure) - procedure afterall_annot_duplicated; + --%test(Gives warning if more than one --%afterall annotation used on procedure) + procedure afterall_annot_duplicated; - --%test(Gives warning if more than one --%aftereach annotation used on procedure) - procedure aftereach_annot_duplicated; + --%test(Gives warning if more than one --%aftereach annotation used on procedure) + procedure aftereach_annot_duplicated; - --%test(Gives warning on before/after all/each annotations mixed with test) - procedure before_after_mixed_with_test; + --%test(Gives warning on before/after all/each annotations mixed with test) + procedure before_after_mixed_with_test; --%endcontext - --%context(context) - --%displayname(--%context annotation) + --%context(--%context annotation) + --%name(context) - --%test(Creates nested suite for content between context/endcontext annotations) - procedure suite_from_context; + --%test(Creates nested suite for content between context/endcontext annotations) + procedure suite_from_context; - --%test(Associates before/after all/each to tests in context only) - procedure before_after_in_context; + --%test(Creates nested contexts inside a context) + procedure nested_contexts; - --%test(Propagates beforeeach/aftereach to context) - procedure before_after_out_of_context; + --%test(Creates multiple nested contexts inside a context) + procedure nested_contexts_2; - --%test(Does not create context and gives warning when endcontext is missing) - procedure context_without_endcontext; + --%test(Associates before/after all/each to tests in context only) + procedure before_after_in_context; - --%test(Gives warning if --%endcontext is missing a preceding --%context) - procedure endcontext_without_context; + --%test(Propagates beforeeach/aftereach to context) + procedure before_after_out_of_context; - --%test(Gives warning when two contexts have the same name and ignores duplicated context) - procedure duplicate_context_name; + --%test(Gives warning when endcontext is missing) + procedure context_without_endcontext; + + --%test(Gives warning if --%endcontext is missing a preceding --%context) + procedure endcontext_without_context; + + --%test(Gives warning when two contexts have the same name and falls back to default context name) + procedure duplicate_context_name; --%endcontext - --%context(throws) - --%displayname(--%throws annotation) + --%context(--%name annotation) + + --%test(Falls back to default context name and gives warning when context name contains "." character) + procedure hard_stop_in_ctx_name; + + --%test(Falls back to default context name and gives warning when name contains spaces) + procedure name_with_spaces_invalid; - --%test(Gives warning if --%throws annotation has no value) - procedure throws_value_empty; + --%test(Raises warning when more than one name annotation used) + procedure duplicate_name_annotation; - --%test(Gives warning if --%throws annotation has invalid value) - procedure throws_value_invalid; + --%test(Is ignored when used outside of context - no warning given) + procedure name_outside_of_context; + + --%test(Is ignored when name value is empty) + procedure name_empty_value; + + --%test(Is applied to corresponding context when multiple contexts used) + procedure multiple_contexts; + + --%test(Context name is case insensitive) + procedure context_name_case_insensitive; --%endcontext - --%context(beforetest_aftertest) - --%displayname(--%beforetest/aftertest annotation) + --%context(--%throws annotation) - --%test(Supports multiple occurrences of beforetest/aftertest for a test) - procedure before_aftertest_multi; + --%test(Gives warning if --%throws annotation has no value) + procedure throws_value_empty; - --%test(Supports same procedure defined twice) - procedure before_aftertest_twice; + --%endcontext - --%test(Supports beforetest from external package) - procedure before_aftertest_pkg_proc; + --%context(--%beforetest/aftertest annotation) - --%test(Supports mix of procedure and package.procedure) - procedure before_aftertest_mixed_syntax; + --%test(Supports multiple occurrences of beforetest/aftertest for a test) + procedure before_aftertest_multi; + + --%test(Supports same procedure defined twice) + procedure before_aftertest_twice; + + --%test(Supports beforetest from external package) + procedure before_aftertest_pkg_proc; + + --%test(Supports mix of procedure and package.procedure) + procedure before_aftertest_mixed_syntax; --%endcontext - --%context(unknown_annotation) - --%displayname(--%bad_annotation) + --%context(--%bad_annotation) - --%test(Gives warning when unknown procedure level annotation passed) - procedure test_bad_procedure_annotation; + --%test(Gives warning when unknown procedure level annotation passed) + procedure test_bad_procedure_annotation; - --%test(Gives warning when unknown package level annotation passed) - procedure test_bad_package_annotation; + --%test(Gives warning when unknown package level annotation passed) + procedure test_bad_package_annotation; --%endcontext - --%context(tags_annotation) - --%displayname(--%tag_annotation) + --%context(--%tag_annotation) - --%test(Build suite test with tag) - procedure test_tag_annotation; + --%test(Build suite test with tag) + procedure test_tag_annotation; - --%test(Build suite with tag) - procedure suite_tag_annotation; + --%test(Build suite with tag) + procedure suite_tag_annotation; - --%test(Build suite test with three tags) - procedure test_tags_annotation; - - --%test(Build suite with three tags) - procedure suite_tags_annotation; + --%test(Build suite test with three tags) + procedure test_tags_annotation; - --%test(Build suite test with two line tag annotation) - procedure test_2line_tags_annotation; - - --%test(Build suite with two line tag annotation) - procedure suite_2line_tags_annotation; + --%test(Build suite with three tags) + procedure suite_tags_annotation; - --%test(Build suite test with empty line tag annotation) - procedure test_empty_tag; - - --%test(Build suite with empty line tag annotation) - procedure suite_empty_tag; - - --%test(Build suite test with duplicate tag annotation) - procedure test_duplicate_tag; - - --%test(Build suite with duplicate tag annotation) - procedure suite_duplicate_tag; + --%test(Build suite test with two line tag annotation) + procedure test_2line_tags_annotation; - --%test(Build suite test with empty between tag annotation) - procedure test_empty_tag_between; - - --%test(Build suite with empty between tag annotation) - procedure suite_empty_tag_between; + --%test(Build suite with two line tag annotation) + procedure suite_2line_tags_annotation; + + --%test(Build suite test with empty line tag annotation) + procedure test_empty_tag; + + --%test(Build suite with empty line tag annotation) + procedure suite_empty_tag; + + --%test(Build suite test with duplicate tag annotation) + procedure test_duplicate_tag; + + --%test(Build suite with duplicate tag annotation) + procedure suite_duplicate_tag; + + --%test(Build suite test with empty between tag annotation) + procedure test_empty_tag_between; + + --%test(Build suite with empty between tag annotation) + procedure suite_empty_tag_between; + + --%test(Build suite test with special char tag annotation) + procedure test_special_char_tag; + + --%test(Build suite with special char tag annotation) + procedure suite_special_char_tag; + + --%test(Raise warning and ignore tag with spaces in tag name) + procedure test_spaces_in_tag; + + --%test(Raise warning and ignore tag starting ith '-') + procedure test_minus_in_tag; - --%test(Build suite test with special char tag annotation) - procedure test_special_char_tag; - - --%test(Build suite with special char tag annotation) - procedure suite_special_char_tag; - --%endcontext end test_suite_builder; diff --git a/test/ut3_tester/core/test_suite_manager.pkb b/test/ut3_tester/core/test_suite_manager.pkb index 6f4237f9c..8ab9b96d9 100644 --- a/test/ut3_tester/core/test_suite_manager.pkb +++ b/test/ut3_tester/core/test_suite_manager.pkb @@ -259,8 +259,8 @@ end test_package_3;]'; gv_glob_val number; - --%context(some_context) - --%displayname(Some context description) + --%context(Some context description) + --%name(some_context) --%test --%displayname(Test1 from test package 1) @@ -278,8 +278,167 @@ end test_package_with_ctx;]'; end; end test_package_with_ctx;]'; + + execute immediate q'[create or replace package test1_frontwildcard is + + --%suite + --%displayname(test1_frontwildcard) + --%suitepath(front_wildcard) + --%rollback(manual) + + --%test + --%displayname(Test1 from test test1_frontwildcard) + procedure first_test; + + --%test + --%displayname(Test2 from test test1_frontwildcard) + procedure second_test; + +end test1_frontwildcard;]'; + + execute immediate q'[create or replace package body test1_frontwildcard is + + procedure first_test is + begin + ut.expect(1).to_equal(1); + end; + + procedure second_test is + begin + ut.expect(1).to_equal(2); + end; + +end test1_frontwildcard;]'; + + execute immediate q'[create or replace package test2_frontwildcard is + + --%suite + --%displayname(test2_frontwildcard) + --%suitepath(front_wildcard) + --%rollback(manual) + + --%test + --%displayname(Test1 from test package test2_frontwildcard) + procedure first_test; + +end test2_frontwildcard;]'; + + execute immediate q'[create or replace package body test2_frontwildcard is + + procedure first_test is + begin + ut.expect(1).to_equal(1); + end; + +end test2_frontwildcard;]'; + + execute immediate q'[create or replace package middle_test1_wildcard is + + --%suite + --%displayname(middle_test1_wildcard) + --%suitepath(wild_middle_card) + --%rollback(manual) + + --%test + --%displayname(Test1 from test middle_test1_wildcard) + procedure middle_first_test; + + --%test + --%displayname(Test2 from test middle_test1_wildcard) + procedure middle_second_test; + +end middle_test1_wildcard;]'; + + execute immediate q'[create or replace package body middle_test1_wildcard is + + procedure middle_first_test is + begin + ut.expect(1).to_equal(1); + end; + + procedure middle_second_test is + begin + ut.expect(1).to_equal(2); end; +end middle_test1_wildcard;]'; + + execute immediate q'[create or replace package middle_test2_wildcard is + + --%suite + --%displayname(middle_test2_wildcard) + --%suitepath(wild_middle_card) + --%rollback(manual) + + --%test + --%displayname(Test1 from test package middle_test2_wildcard) + procedure middle_first_test; + +end middle_test2_wildcard;]'; + + execute immediate q'[create or replace package body middle_test2_wildcard is + + procedure middle_first_test is + begin + ut.expect(1).to_equal(1); + end; + +end middle_test2_wildcard;]'; + + execute immediate q'[create or replace package test1_multi_wildcard is + + --%suite + --%displayname(test1_multi_wildcard) + --%suitepath(wildcard_multi_asterisks) + --%rollback(manual) + + --%test + --%displayname(Test1 from test test1_multi_wildcard) + procedure first_multi_test1; + + --%test + --%displayname(Test2 from test test1_multi_wildcard) + procedure second_multi_test2; + +end test1_multi_wildcard;]'; + + execute immediate q'[create or replace package body test1_multi_wildcard is + + procedure first_multi_test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure second_multi_test2 is + begin + ut.expect(1).to_equal(2); + end; + +end test1_multi_wildcard;]'; + + execute immediate q'[create or replace package test2_multi_wildcard is + + --%suite + --%displayname(test2_multi_wildcard) + --%suitepath(wildcard_multi_asterisks) + --%rollback(manual) + + --%test + --%displayname(Test1 from test package test2_multi_wildcard) + procedure first_multi_test1; + +end test2_multi_wildcard;]'; + + execute immediate q'[create or replace package body test2_multi_wildcard is + + procedure first_multi_test1 is + begin + ut.expect(1).to_equal(1); + end; + +end test2_multi_wildcard;]'; + + end; procedure drop_dummy_packages is pragma autonomous_transaction; @@ -288,19 +447,25 @@ end test_package_with_ctx;]'; execute immediate 'drop package test_package_2'; execute immediate 'drop package test_package_3'; execute immediate 'drop package test_package_with_ctx'; + execute immediate 'drop package test1_frontwildcard'; + execute immediate 'drop package test2_frontwildcard'; + execute immediate 'drop package middle_test1_wildcard'; + execute immediate 'drop package middle_test2_wildcard'; + execute immediate 'drop package test1_multi_wildcard'; + execute immediate 'drop package test2_multi_wildcard'; end; procedure test_schema_run is c_path constant varchar2(100) := sys_context('USERENV', 'CURRENT_USER'); - l_objects_to_run ut3.ut_suite_items := ut3.ut_suite_items(); - l_all_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items := ut3_develop.ut_suite_items(); + l_all_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; begin --Act - l_all_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_all_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); for i in 1..l_all_objects_to_run.count loop if l_all_objects_to_run(i).name in ('tests', 'tests2') then @@ -313,21 +478,21 @@ end test_package_with_ctx;]'; ut.expect(l_objects_to_run.count).to_equal(2); for i in 1 .. 2 loop - l_test0_suite := treat(l_objects_to_run(i) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name in ('tests', 'tests2')).to_be_true; - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); case l_test0_suite.name when 'tests' then ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(3); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); ut.expect(l_test2_suite.items.count).to_equal(3); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); + ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); when 'tests2' then ut.expect(l_test1_suite.name).to_equal('test_package_3'); ut.expect(l_test1_suite.items.count).to_equal(3); @@ -337,86 +502,116 @@ end test_package_with_ctx;]'; end; + function count_tests(a_items ut3_develop.ut_suite_items) return integer is + l_count integer := 0; + begin + for i in 1 .. a_items.count loop + if a_items(i) is of (ut3_develop.ut_test) then + l_count := l_count + 1; + else + l_count := l_count + count_tests(treat(a_items(i) as ut3_develop.ut_logical_suite).items); + end if; + end loop; + return l_count; + end; + + procedure test_overlapping_paths is + c_owner varchar2(128) := sys_context('USERENV', 'CURRENT_USER'); + l_expected_items ut3_develop.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Arrange + l_expected_items := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_owner||':tests')); + --Act - the packages are part of the suitepath + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(c_owner||':tests', c_owner||'.test_package_1', c_owner||'.test_package_2') + ); + --Assert + ut.expect(count_tests(l_expected_items)).to_be_greater_than(0); + ut.expect(l_objects_to_run.count).to_equal(1); + ut.expect(count_tests(l_objects_to_run)).to_equal(count_tests(l_expected_items)); + end; + procedure test_top2_by_name is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); + ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); ut.expect(l_test2_suite.items.count).to_equal(3); end; procedure test_top2_bt_name_cur_user is c_path varchar2(100) := 'test_package_2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); + ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); ut.expect(l_test2_suite.items.count).to_equal(3); end; procedure test_by_path_to_subsuite is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test_package_2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); ut.expect(l_test2_suite.items.count).to_equal(3); @@ -424,26 +619,26 @@ end test_package_with_ctx;]'; procedure test_by_path_to_subsuite_cu is c_path varchar2(100) := ':tests.test_package_1.test_package_2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); ut.expect(l_test2_suite.items.count).to_equal(3); @@ -451,36 +646,36 @@ end test_package_with_ctx;]'; procedure test_subsute_proc_by_path is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test_package_2.test2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); + ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); + ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); ut.expect(l_test2_suite.items.count).to_equal(1); - l_test_proc := treat(l_test2_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_test2_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual); + ut.expect(l_test_proc.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); @@ -488,32 +683,32 @@ end test_package_with_ctx;]'; procedure test_subsute_proc_by_path_cu is c_path varchar2(100) := ':tests.test_package_1.test_package_2.test2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); ut.expect(l_test2_suite.items.count).to_equal(1); - l_test_proc := treat(l_test2_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_test2_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test2'); ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); @@ -521,101 +716,101 @@ end test_package_with_ctx;]'; procedure test_top_pack_by_name is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(2); ut.expect(l_test1_suite.items(1).name).to_equal('test1'); ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1'); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).before_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).after_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_test_list.count).to_equal(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).after_test_list.count).to_equal(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(0); ut.expect(l_test1_suite.items(2).name).to_equal('test2'); ut.expect(l_test1_suite.items(2).description).to_equal('Test2 from test package 1'); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).before_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).after_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_test_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).after_test_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(0); end; procedure test_top_pack_by_name_cu is c_path varchar2(100) := 'test_package_1'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_suite; - l_test2_suite ut3.ut_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; + l_test2_suite ut3_develop.ut_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(2); ut.expect(l_test1_suite.items(1).name).to_equal('test1'); ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1'); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).before_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).after_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(1) as ut3.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_test_list.count).to_equal(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).after_test_list.count).to_equal(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(0); ut.expect(l_test1_suite.items(2).name).to_equal('test2'); ut.expect(l_test1_suite.items(2).description).to_equal('Test2 from test package 1'); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).before_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).after_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_test_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).after_test_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(0); end; procedure test_top_pack_by_path is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(3); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); ut.expect(l_test2_suite.items.count).to_equal(3); @@ -623,26 +818,26 @@ end test_package_with_ctx;]'; procedure test_top_pack_by_path_cu is c_path varchar2(100) := ':tests'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(3); - l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test2_suite.name).to_equal('test_package_2'); ut.expect(l_test2_suite.items.count).to_equal(3); @@ -650,27 +845,27 @@ end test_package_with_ctx;]'; procedure test_top_pck_proc_by_path is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test2'); ut.expect(l_test_proc.description).to_equal('Test2 from test package 1'); @@ -680,27 +875,27 @@ end test_package_with_ctx;]'; procedure test_top_pck_proc_by_path_cu is c_path varchar2(100) := ':tests.test_package_1.test2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test2_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test2'); ut.expect(l_test_proc.description).to_equal('Test2 from test package 1'); @@ -710,27 +905,27 @@ end test_package_with_ctx;]'; procedure test_top_pkc_proc_by_name is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1.test2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test2'); ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); @@ -738,27 +933,27 @@ end test_package_with_ctx;]'; procedure test_top_pkc_proc_by_name_cu is c_path varchar2(100) := 'test_package_1.test2'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_1'); ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test2'); ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); @@ -766,139 +961,139 @@ end test_package_with_ctx;]'; procedure test_top_pkc_nosub_by_name is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_3'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test1 ut3.ut_test; - l_test3 ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1 ut3_develop.ut_test; + l_test3 ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests2'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_3'); ut.expect(l_test1_suite.items.count).to_equal(3); - l_test1 := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test1.name).to_equal('test1'); ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - l_test3 := treat(l_test1_suite.items(3) as ut3.ut_test); + l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); ut.expect(l_test3.name).to_equal('disabled_test'); ut.expect(l_test3.DISABLED_FLAG).to_equal(1); end; procedure test_top_pkc_nosub_by_name_cu is c_path varchar2(100) := 'test_package_3'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test1 ut3.ut_test; - l_test3 ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1 ut3_develop.ut_test; + l_test3 ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests2'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_3'); ut.expect(l_test1_suite.items.count).to_equal(3); - l_test1 := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test1.name).to_equal('test1'); ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - l_test3 := treat(l_test1_suite.items(3) as ut3.ut_test); + l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); ut.expect(l_test3.name).to_equal('disabled_test'); ut.expect(l_test3.DISABLED_FLAG).to_equal(1); end; procedure test_top_subpck_by_path is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests2.test_package_3'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test1 ut3.ut_test; - l_test3 ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1 ut3_develop.ut_test; + l_test3 ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests2'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_3'); ut.expect(l_test1_suite.items.count).to_equal(3); - l_test1 := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test1.name).to_equal('test1'); ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - l_test3 := treat(l_test1_suite.items(3) as ut3.ut_test); + l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); ut.expect(l_test3.name).to_equal('disabled_test'); ut.expect(l_test3.DISABLED_FLAG).to_equal(1); end; procedure test_top_subpck_by_path_cu is c_path varchar2(100) := ':tests2.test_package_3'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test0_suite ut3.ut_logical_suite; - l_test1_suite ut3.ut_logical_suite; - l_test1 ut3.ut_test; - l_test3 ut3.ut_test; + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1 ut3_develop.ut_test; + l_test3 ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test0_suite.name).to_equal('tests2'); ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_test1_suite.name).to_equal('test_package_3'); ut.expect(l_test1_suite.items.count).to_equal(3); - l_test1 := treat(l_test1_suite.items(1) as ut3.ut_test); + l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test1.name).to_equal('test1'); ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - l_test3 := treat(l_test1_suite.items(3) as ut3.ut_test); + l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); ut.expect(l_test3.name).to_equal('disabled_test'); ut.expect(l_test3.DISABLED_FLAG).to_equal(1); end; procedure test_search_invalid_pck is - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; begin - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('failing_invalid_spec')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('failing_invalid_spec')); - ut3.ut.expect(l_objects_to_run.count).to_be_greater_than(0); - ut3.ut.expect(l_objects_to_run(l_objects_to_run.first).object_name).to_equal('failing_invalid_spec'); + ut3_develop.ut.expect(l_objects_to_run.count).to_be_greater_than(0); + ut3_develop.ut.expect(l_objects_to_run(l_objects_to_run.first).object_name).to_equal('failing_invalid_spec'); end; procedure compile_invalid_package is @@ -936,19 +1131,49 @@ end;]'; end; procedure test_search_nonexisting_pck is - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; begin - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('ut3.failing_non_existing')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop.failing_non_existing')); ut.fail('Non existing package did not raise exception'); exception when others then ut.expect(sqlerrm).to_be_like('%failing_non_existing%'); end; + procedure test_search_nonex_pck_wild is + l_objects_to_run ut3_develop.ut_suite_items; + begin + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop.failing_non_*')); + ut.fail('Non existing package did not raise exception'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%failing_non_*%'); + end; + + procedure test_search_nonex_prc_wild is + l_objects_to_run ut3_develop.ut_suite_items; + begin + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_tester.test_package_1.nonexist*')); + ut.fail('Non existing package did not raise exception'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%nonexist*%'); + end; + + procedure test_search_nonex_path_wild is + l_objects_to_run ut3_develop.ut_suite_items; + begin + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop:failing_non_*')); + ut.fail('Non existing path did not raise exception'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%:failing_non_*%'); + end; + procedure test_search_nonexist_sch_pck is - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; begin - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('failing_non_existing')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('failing_non_existing')); ut.fail('Non existing package without schema did not raise exception'); exception when others then @@ -956,27 +1181,27 @@ end;]'; end; procedure test_desc_with_comma is - l_objects_to_run ut3.ut_suite_items; - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('tst_package_to_be_dropped')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_to_be_dropped')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3.ut_suite); + l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); ut.expect(l_suite.name).to_equal('tst_package_to_be_dropped'); ut.expect(l_suite.description).to_equal('A suite description, though with comma, is assigned by suite_manager'); ut.expect(l_suite.items.count).to_equal(2); - l_test := treat(l_suite.items(1) as ut3.ut_test); + l_test := treat(l_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test.name).to_equal('test1'); ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager'); --- l_test := treat(l_suite.items(2) as ut3.ut_test); +-- l_test := treat(l_suite.items(2) as ut3_develop.ut_test); -- -- ut.expect(l_test.name).to_equal('test2'); -- ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager'); @@ -1013,16 +1238,16 @@ end;'; end; procedure test_inv_cache_on_drop is - l_test_report ut3.ut_varchar2_list; + l_test_report ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_test_report from table(ut3.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.tst_package_to_be_dropped')); + select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.tst_package_to_be_dropped')); -- drop package clean_inv_cache_on_drop; begin - select * bulk collect into l_test_report from table(ut3.ut.run(sys_context('USERENV', 'CURRENT_USER') || '.tst_package_to_be_dropped')); + select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER') || '.tst_package_to_be_dropped')); ut.fail('Cache not invalidated on package drop'); exception when others then @@ -1056,15 +1281,15 @@ end;'; end; procedure test_inv_pck_bodies is - l_test_report ut3.ut_varchar2_list; + l_test_report ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_test_report from table(ut3.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_dependencies')); + select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_dependencies', a_support_info => 0)); ut.expect(l_test_report(l_test_report.count-1)).to_be_like('1 test_, 0 failed, 0 errored, 0 disabled, 0 warning(s)'); - --execute immediate 'select * from table(ut3.ut.run(''UT3.test_dependencies'', ut3.utplsql_test_reporter()))' into l_result; + --execute immediate 'select * from table(ut3_develop.ut.run(''UT3_DEVELOP.test_dependencies'', ut3_develop.utplsql_test_reporter()))' into l_result; --- ut.expect(l_result).to_equal(ut3.ut_utils.gc_success); +-- ut.expect(l_result).to_equal(ut3_develop.ut_utils.gc_success); end; procedure setup_inv_pck_bodies is pragma autonomous_transaction; @@ -1092,16 +1317,16 @@ end;'; end; procedure test_pck_with_dollar is - l_objects_to_run ut3.ut_suite_items; - l_suite ut3.ut_suite; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_suite; begin --act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('tst_package_with$dollar')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with$dollar')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3.ut_suite); + l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); ut.expect(l_suite.name).to_equal('tst_package_with$dollar'); end; procedure setup_pck_with_dollar is @@ -1127,16 +1352,16 @@ end;'; procedure test_pck_with_hash is - l_objects_to_run ut3.ut_suite_items; - l_suite ut3.ut_suite; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_suite; begin --act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('tst_package_with#hash')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with#hash')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3.ut_suite); + l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); ut.expect(l_suite.name).to_equal('tst_package_with#hash'); end; procedure setup_pck_with_hash is @@ -1162,22 +1387,22 @@ end;'; procedure test_test_with_dollar is - l_objects_to_run ut3.ut_suite_items; - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin --act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('tst_package_with_dollar_test.test$1')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with_dollar_test.test$1')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3.ut_suite); + l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); ut.expect(l_suite.name).to_equal('tst_package_with_dollar_test'); ut.expect(l_suite.items.count).to_equal(1); - l_test := treat(l_suite.items(1) as ut3.ut_test); + l_test := treat(l_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test.name).to_equal('test$1'); @@ -1203,22 +1428,22 @@ end;'; end; procedure test_test_with_hash is - l_objects_to_run ut3.ut_suite_items; - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin --act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('tst_package_with_hash_test.test#1')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with_hash_test.test#1')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3.ut_suite); + l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); ut.expect(l_suite.name).to_equal('tst_package_with_hash_test'); ut.expect(l_suite.items.count).to_equal(1); - l_test := treat(l_suite.items(1) as ut3.ut_test); + l_test := treat(l_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test.name).to_equal('test#1'); @@ -1244,17 +1469,17 @@ end;'; end; procedure test_empty_suite_path is - l_objects_to_run ut3.ut_suite_items; - l_suite ut3.ut_suite; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_suite; begin --act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('tst_empty_suite_path')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_empty_suite_path')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3.ut_suite); + l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); ut.expect(l_suite.name).to_equal('tst_empty_suite_path'); end; @@ -1281,25 +1506,25 @@ end;'; end; procedure test_pck_with_same_path is - l_objects_to_run ut3.ut_suite_items; - l_suite1 ut3.ut_logical_suite; - l_suite2 ut3.ut_logical_suite; - l_suite3 ut3.ut_suite; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite1 ut3_develop.ut_logical_suite; + l_suite2 ut3_develop.ut_logical_suite; + l_suite3 ut3_develop.ut_suite; begin - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(':test1.test2$.test_package_same_1')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(':test1.test2$.test_package_same_1')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite1 := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_suite1 := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_suite1.name).to_equal('test1'); ut.expect(l_suite1.items.count).to_equal(1); - l_suite2 := treat(l_suite1.items(1) as ut3.ut_logical_suite); + l_suite2 := treat(l_suite1.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_suite2.name).to_equal('test2$'); ut.expect(l_suite2.items.count).to_equal(1); - l_suite3 := treat(l_suite2.items(1) as ut3.ut_suite); + l_suite3 := treat(l_suite2.items(1) as ut3_develop.ut_suite); ut.expect(l_suite3.name).to_equal('test_package_same_1'); end; @@ -1359,17 +1584,17 @@ end;]'; end; procedure disable_suite_floating_annot is - l_objects_to_run ut3.ut_suite_items; - l_suite ut3.ut_suite; + l_objects_to_run ut3_develop.ut_suite_items; + l_suite ut3_develop.ut_suite; begin --Arrange setup_disabled_pck; --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('test_disabled_floating')); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('test_disabled_floating')); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3.ut_suite); + l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); ut.expect(l_suite.name).to_equal('test_disabled_floating'); ut.expect(l_suite.get_disabled_flag()).to_be_true(); @@ -1378,66 +1603,66 @@ end;]'; procedure pck_proc_in_ctx_by_name is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_with_ctx.test1'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3.ut_logical_suite; - l_ctx_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test_suite ut3_develop.ut_logical_suite; + l_ctx_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test_suite.name).to_equal('test_package_with_ctx'); ut.expect(l_test_suite.items.count).to_equal(1); - l_ctx_suite := treat(l_test_suite.items(1) as ut3.ut_logical_suite); + l_ctx_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_ctx_suite.name).to_equal('some_context'); ut.expect(l_ctx_suite.description).to_equal('Some context description'); ut.expect(l_ctx_suite.items.count).to_equal(1); - l_test_proc := treat(l_ctx_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_ctx_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test1'); end; procedure pck_proc_in_ctx_by_path is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':test_package_with_ctx.some_context.test1'; - l_objects_to_run ut3.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3.ut_logical_suite; - l_ctx_suite ut3.ut_logical_suite; - l_test_proc ut3.ut_test; + l_test_suite ut3_develop.ut_logical_suite; + l_ctx_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; begin --Act - l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); --Assert ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); ut.expect(l_test_suite.name).to_equal('test_package_with_ctx'); ut.expect(l_test_suite.items.count).to_equal(1); - l_ctx_suite := treat(l_test_suite.items(1) as ut3.ut_logical_suite); + l_ctx_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); ut.expect(l_ctx_suite.name).to_equal('some_context'); ut.expect(l_ctx_suite.description).to_equal('Some context description'); ut.expect(l_ctx_suite.items.count).to_equal(1); - l_test_proc := treat(l_ctx_suite.items(1) as ut3.ut_test); + l_test_proc := treat(l_ctx_suite.items(1) as ut3_develop.ut_test); ut.expect(l_test_proc.name).to_equal('test1'); end; procedure test_get_schema_ut_packages is - l_expected ut3.ut_object_names; - l_actual ut3.ut_object_names; + l_expected ut3_develop.ut_object_names; + l_actual ut3_develop.ut_object_names; begin - l_expected := ut3.ut_object_names( - ut3.ut_object_name('UT3','SOME_TEST_PACKAGE') + l_expected := ut3_develop.ut_object_names( + ut3_develop.ut_object_name('UT3_DEVELOP','SOME_TEST_PACKAGE') ); - l_actual := ut3_tester_helper.run_helper.get_object_name('UT3'); + l_actual := ut3_tester_helper.run_helper.get_schema_ut_packages('UT3_DEVELOP'); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; @@ -1454,17 +1679,700 @@ end;]'; end; procedure add_new_long_test_package is - l_actual ut3.ut_object_names; + l_actual ut3_develop.ut_object_names; l_expected_message varchar2(500); begin - l_expected_message := q'[ORA-20217: 'Suitepath exceeds 1000 CHAR on: UT3.DUMMY_LONG_TEST_PACKAGE,UT3.DUMMY_LONG_TEST_PACKAGE1'%]'; - l_actual := ut3_tester_helper.run_helper.get_object_name('UT3'); + l_expected_message := q'[ORA-20217: 'Suitepath exceeds 1000 CHAR on: UT3_DEVELOP.DUMMY_LONG_TEST_PACKAGE,UT3_DEVELOP.DUMMY_LONG_TEST_PACKAGE1'%]'; + l_actual := ut3_tester_helper.run_helper.get_schema_ut_packages('UT3_DEVELOP'); ut.fail('Expected exception for suitpaths over 1k for two packages'); exception when others then ut.expect(dbms_utility.format_error_stack()).to_be_like(l_expected_message); - ut.expect(SQLCODE).to_equal(ut3.ut_utils.gc_value_too_large); + ut.expect(SQLCODE).to_equal(ut3_develop.ut_utils.gc_value_too_large); + end; + + procedure setup_remove_annot_test is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_removing_annotation as + --%suite + + --%test + procedure test1; + + --%test + procedure test2; + +end;]'; + end; + + procedure remove_annot_from_test is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_removing_annotation as + + procedure test1; + + procedure test2; + +end;]'; end; + procedure rem_one_annot_test is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_removing_annotation as + --%suite + + procedure test1; + + --%test + procedure test2; + +end;]'; + execute immediate q'[create or replace package body test_removing_annotation as + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(1).to_equal(1); + end; + +end;]'; + end; + + procedure clean_remove_annot_test is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_removing_annotation'; + end; + + procedure test_rem_cache_on_create is + l_test_report ut3_develop.ut_varchar2_list; + begin + + select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_removing_annotation')); + + -- drop all tests + remove_annot_from_test; + + begin + select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER') || '.test_removing_annotation')); + ut.fail('Expected exception ORA-20204 was not raised'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%ORA-20204: Suite package ut3_tester.test_removing_annotation does not exist%'); + end; + + end; + + procedure test_rem_cache_on_crt_anno is + l_test_report ut3_develop.ut_varchar2_list; + l_results clob; + begin + + select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_removing_annotation')); + + -- drop single test + rem_one_annot_test; + ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')|| '.test_removing_annotation',a_reporter => ut3_develop.ut_documentation_reporter() ); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); + + end; + + procedure test_wild_card_obj_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_*'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; + l_ctx_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(3); + + + for i in 1 .. 3 loop + l_test_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name in ('test_package_with_ctx','tests', 'tests2')).to_be_true; + + case l_test_suite.name + when 'test_package_with_ctx' then + ut.expect(l_test_suite.items.count).to_equal(1); + l_ctx_suite:= treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_ctx_suite.name).to_equal('some_context'); + ut.expect(l_ctx_suite.description).to_equal('Some context description'); + ut.expect(l_ctx_suite.items.count).to_equal(1); + l_test_proc := treat(l_ctx_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test_proc.name).to_equal('test1'); + when 'tests' then + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(3); + ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); + l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); + + ut.expect(l_test2_suite.name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(3); + ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); + when 'tests2' then + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('test_package_3'); + ut.expect(l_test1_suite.items.count).to_equal(3); + end case; + + end loop; + + end; + + procedure test_wild_card_prc_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1.test*'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('tests'); + + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(2); + + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('test1'); + + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('test2'); + end; + + procedure test_wild_card_path_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests*'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test2_suite ut3_develop.ut_logical_suite; + l_ctx_suite ut3_develop.ut_logical_suite; + l_test_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(2); + + + for i in 1 .. 2 loop + l_test_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name in ('tests', 'tests2')).to_be_true; + + case l_test_suite.name + when 'tests' then + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(3); + + for i in 1 ..3 loop + case l_test1_suite.items(i).self_type + when 'UT_SUITE' then + l_test2_suite := treat(l_test1_suite.items(i) as ut3_develop.ut_logical_suite); + ut.expect(l_test2_suite.name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(3); + + l_test_proc := treat(l_test2_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true; + + l_test_proc := treat(l_test2_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true; + + l_test_proc := treat(l_test2_suite.items(3) as ut3_develop.ut_test); + ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true; + + when 'UT_TEST' then + l_test_proc := treat(l_test1_suite.items(i) as ut3_develop.ut_test); + ut.expect(l_test_proc.name in ('test1', 'test2')).to_be_true; + end case; + end loop; + when 'tests2' then + ut.expect(l_test_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('test_package_3'); + ut.expect(l_test1_suite.items.count).to_equal(3); + for i in 1 .. 3 loop + l_test_proc := treat(l_test1_suite.items(i) as ut3_develop.ut_test); + ut.expect(l_test_proc.name in ('test1', 'test2','disabled_test')).to_be_true; + end loop; + end case; + + end loop; + + end; + + procedure test_wild_card_front_obj_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.*_frontwildcard'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('front_wildcard'); + ut.expect(l_test_suite.items.count).to_equal(2); + + for i in 1 .. 2 loop + l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); + case l_test1_suite.name + when 'test1_frontwildcard' then + ut.expect(l_test1_suite.items.count).to_equal(2); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_test'); + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('second_test'); + when 'test2_frontwildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_test'); + end case; + + end loop; + end; + + procedure test_wild_card_front_prc_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test1_frontwildcard.*_test'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('front_wildcard'); + + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('test1_frontwildcard'); + ut.expect(l_test1_suite.items.count).to_equal(2); + + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_test'); + + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('second_test'); + end; + + procedure test_wild_card_front_path_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':*_wildcard'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('front_wildcard'); + ut.expect(l_test_suite.items.count).to_equal(2); + + for i in 1 .. 2 loop + l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); + case l_test1_suite.name + when 'test1_frontwildcard' then + ut.expect(l_test1_suite.items.count).to_equal(2); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_test'); + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('second_test'); + when 'test2_frontwildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_test'); + end case; + + end loop; + end; + + procedure test_wild_card_mid_obj_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.middle_*_wildcard'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('wild_middle_card'); + ut.expect(l_test_suite.items.count).to_equal(2); + + for i in 1 .. 2 loop + l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); + case l_test1_suite.name + when 'middle_test1_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(2); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('middle_first_test'); + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('middle_second_test'); + when 'middle_test2_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('middle_first_test'); + end case; + + end loop; + end; + + procedure test_wild_card_mid_prc_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.middle_test1_wildcard.middle_*_test'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('wild_middle_card'); + + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('middle_test1_wildcard'); + ut.expect(l_test1_suite.items.count).to_equal(2); + + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('middle_first_test'); + + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('middle_second_test'); + end; + + procedure test_wild_card_mid_path_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':wild_*card'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('wild_middle_card'); + ut.expect(l_test_suite.items.count).to_equal(2); + + for i in 1 .. 2 loop + l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); + case l_test1_suite.name + when 'middle_test1_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(2); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('middle_first_test'); + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('middle_second_test'); + when 'middle_test2_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('middle_first_test'); + end case; + + end loop; + end; + + procedure test_wild_card_mul_obj_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.*_multi_*card'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); + ut.expect(l_test_suite.items.count).to_equal(2); + + for i in 1 .. 2 loop + l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); + case l_test1_suite.name + when 'test1_multi_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(2); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('second_multi_test2'); + when 'test2_multi_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); + end case; + + end loop; + end; + + procedure test_wild_card_mul_prc_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test1_multi_wildcard.*_multi_*'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); + + l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test1_suite.name).to_equal('test1_multi_wildcard'); + ut.expect(l_test1_suite.items.count).to_equal(2); + + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); + + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('second_multi_test2'); + end; + + procedure test_wild_card_mul_path_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':wild*_multi_*risks'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); + ut.expect(l_test_suite.items.count).to_equal(2); + + for i in 1 .. 2 loop + l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); + case l_test1_suite.name + when 'test1_multi_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(2); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); + l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); + ut.expect(l_test2_proc.name).to_equal('second_multi_test2'); + when 'test2_multi_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); + end case; + + end loop; + end; + + procedure tst_wild_card_mul_lv_path_name is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':wild*_multi_*risks.*_multi_wildcard.*_multi_test1'; + l_objects_to_run ut3_develop.ut_suite_items; + l_test_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_logical_suite; + l_test1_proc ut3_develop.ut_test; + l_test2_proc ut3_develop.ut_test; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); + ut.expect(l_test_suite.items.count).to_equal(2); + + for i in 1 .. 2 loop + l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); + case l_test1_suite.name + when 'test1_multi_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); + when 'test2_multi_wildcard' then + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); + ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); + end case; + + end loop; + end; + + --%test(Path validation does not fail on Estonian NLS_SORT - fix #1252) + /* + Names that differ only where a "_" or "." is: + tst_char_a / tstxchar_a, test_a / testxa, chars.sub_a / chars.subxa, chars.sub / chars_sub + */ + procedure create_char_test_packages is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package tst_char_a is + --%suite + --%suitepath(chars.sub_a) + + --%test + procedure test_a; + + --%test + procedure testxa; + end;]'; + execute immediate q'[create or replace package tstxchar_a is + --%suite + --%suitepath(chars.subxa) + + --%test + procedure test_a; + end;]'; + execute immediate q'[create or replace package tst_char_b is + --%suite + --%suitepath(chars_sub) + + --%test + procedure test_b; + end;]'; + end; + + procedure drop_char_test_packages is + pragma autonomous_transaction; + begin + execute immediate 'drop package tst_char_a'; + execute immediate 'drop package tstxchar_a'; + execute immediate 'drop package tst_char_b'; + end; + + --returns the paths of all tests, sorted and separated by commas + function get_test_paths(a_items ut3_develop.ut_suite_items) return varchar2 is + l_paths ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); + l_result varchar2(32767); + + procedure add_test_paths(a_suite_items ut3_develop.ut_suite_items) is + begin + for i in 1 .. a_suite_items.count loop + if a_suite_items(i) is of (ut3_develop.ut_test) then + l_paths.extend; + l_paths(l_paths.last) := a_suite_items(i).path; + else + add_test_paths(treat(a_suite_items(i) as ut3_develop.ut_logical_suite).items); + end if; + end loop; + end; + begin + add_test_paths(a_items); + select listagg(column_value, ',') within group (order by column_value) into l_result from table(l_paths); + return l_result; + end; + + procedure underscore_in_package_name is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||'.tst_char_a') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal('chars.sub_a.tst_char_a.test_a,chars.sub_a.tst_char_a.testxa'); + end; + + procedure underscore_in_procedure_name is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||'.tst_char_a.test_a') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal('chars.sub_a.tst_char_a.test_a'); + end; + + procedure underscore_in_suitepath is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||':chars.sub_a') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal('chars.sub_a.tst_char_a.test_a,chars.sub_a.tst_char_a.testxa'); + end; + + procedure dot_in_suitepath_wildcard is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||':chars.sub*') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal( + 'chars.sub_a.tst_char_a.test_a,chars.sub_a.tst_char_a.testxa,chars.subxa.tstxchar_a.test_a' + ); + end; + + procedure path_validate_nls_sort is + l_schema_names ut3_develop.ut_varchar2_rows; + begin + --Arrange + execute immediate q'[alter session set nls_sort='estonian']'; + --Act + l_schema_names := ut3_develop.ut_suite_manager.get_schema_names(ut3_develop.ut_varchar2_list('ut3')); + --Asseert + ut.expect(sqlcode).to_equal(0); + end; + + + procedure reset_nls_sort is + begin + execute immediate q'[alter session set nls_sort='binary']'; + end; end test_suite_manager; / diff --git a/test/ut3_tester/core/test_suite_manager.pks b/test/ut3_tester/core/test_suite_manager.pks index ed318b890..a7d3bcc20 100644 --- a/test/ut3_tester/core/test_suite_manager.pks +++ b/test/ut3_tester/core/test_suite_manager.pks @@ -3,9 +3,6 @@ create or replace package test_suite_manager is --%suite(suite_manager) --%suitepath(utplsql.ut3_tester.core) - procedure create_dummy_long_test_package; - - procedure drop_dummy_long_test_package; --%beforeall procedure compile_dummy_packages; @@ -18,6 +15,9 @@ create or replace package test_suite_manager is --%test(Prepare runner for the top 2 package by package user.package_name) procedure test_top2_by_name; + --%test(Prepare runner includes each suite item once when given paths overlap) + procedure test_overlapping_paths; + --%test(Prepare runner for the top2 package by name cur user) procedure test_top2_bt_name_cur_user; @@ -78,8 +78,17 @@ create or replace package test_suite_manager is --%test(Prepare runner for nonexisting package with schema) procedure test_search_nonexisting_pck; - - --%test(Prepare runner for nonexisting package without schema) + + --%test(Prepare runner for nonexisting package using wildcard filter) + procedure test_search_nonex_pck_wild; + + --%test(Prepare runner for nonexisting procedure using wildcard filter) + procedure test_search_nonex_prc_wild; + + --%test(Prepare runner for nonexisting path using wildcard filter) + procedure test_search_nonex_path_wild; + + --%test(Prepare runner for nonexisting package without schema) procedure test_search_nonexist_sch_pck; --%test(Test description with comma) @@ -157,7 +166,7 @@ create or replace package test_suite_manager is --%context(get_schema_ut_packages) - --%test(returns list of all unit test packages in given schema) + --%test(returns list of all unit test packages in given schema excluding packages that are not suites) --%beforetest(create_ut3_suite) --%aftertest(drop_ut3_suite) procedure test_get_schema_ut_packages; @@ -170,6 +179,98 @@ create or replace package test_suite_manager is --%beforetest(create_dummy_long_test_package) --%aftertest(drop_dummy_long_test_package) procedure add_new_long_test_package; + procedure create_dummy_long_test_package; + procedure drop_dummy_long_test_package; + + + procedure setup_remove_annot_test; + procedure clean_remove_annot_test; + + --%test(Remove cache on package create or replace when all annotations removed) + --%beforetest(setup_remove_annot_test) + --%aftertest(clean_remove_annot_test) + procedure test_rem_cache_on_create; + + + --%test(Remove cache on package create or replace when single annotation removed) + --%beforetest(setup_remove_annot_test) + --%aftertest(clean_remove_annot_test) + procedure test_rem_cache_on_crt_anno; + + --%context(wildcard_filters) + + --%test(Execute test_packages using a object_name with wildcard at the end ) + procedure test_wild_card_obj_name; + + --%test(Execute test_packages using a procedure name with wildcard at the end) + procedure test_wild_card_prc_name; + + --%test(Execute test_packages using a path name with wildcard at the end) + procedure test_wild_card_path_name; + + --%test(Execute test_packages using a object_name with wildcard in the front) + procedure test_wild_card_front_obj_name; + + --%test(Execute test_packages using a procedure name with wildcard in the front) + procedure test_wild_card_front_prc_name; + + --%test(Execute test_packages using a path name with wildcard in the front) + procedure test_wild_card_front_path_name; + + --%test(Execute test_packages using a object_name with wildcard in the middle) + procedure test_wild_card_mid_obj_name; + + --%test(Execute test_packages using a procedure name with wildcard in the middle) + procedure test_wild_card_mid_prc_name; + + --%test(Execute test_packages using a path name with wildcard in the middle) + procedure test_wild_card_mid_path_name; + + --%test(Execute test_packages using a object_name with multiple wildcards) + procedure test_wild_card_mul_obj_name; + + --%test(Execute test_packages using a procedure name with multiple wildcards) + procedure test_wild_card_mul_prc_name; + + --%test(Execute test_packages using a path name with multiple wildcards) + procedure test_wild_card_mul_path_name; + + --%test(Execute test_packages using a path name with multiple wildcards on different level) + procedure tst_wild_card_mul_lv_path_name; + + --%endcontext + + --%context(literal_characters) + --%displayname(Characters other than * in a path match only themselves) + + --%beforeall + procedure create_char_test_packages; + --%afterall + procedure drop_char_test_packages; + + --%test(Underscore in a package name is not a wildcard) + procedure underscore_in_package_name; + + --%test(Underscore in a procedure name is not a wildcard) + procedure underscore_in_procedure_name; + + --%test(Underscore in a suitepath is not a wildcard) + procedure underscore_in_suitepath; + + --%test(Dot in a suitepath with a wildcard is not a wildcard) + procedure dot_in_suitepath_wildcard; + + --%endcontext + + --%context(paths validation) + + --%test(Path validation does not fail on Estonian NLS_SORT - fix #1252) + --%aftertest(reset_nls_sort) + procedure path_validate_nls_sort; + + procedure reset_nls_sort; + + --%endcontext end test_suite_manager; / diff --git a/test/ut3_tester/core/test_ut_executable.pkb b/test/ut3_tester/core/test_ut_executable.pkb index 92420de47..e27a2e432 100644 --- a/test/ut3_tester/core/test_ut_executable.pkb +++ b/test/ut3_tester/core/test_ut_executable.pkb @@ -3,13 +3,13 @@ create or replace package body test_ut_executable is g_dbms_output_text varchar2(30) := 'Some output from procedure'; procedure exec_schema_package_proc is - l_executable ut3.ut_executable; - l_test ut3.ut_test; + l_executable ut3_develop.ut_executable; + l_test ut3_develop.ut_test; l_result boolean; begin --Arrange - l_test := ut3.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); - l_executable := ut3.ut_executable_test( null, 'test_ut_executable', 'passing_proc', ut3.ut_utils.gc_test_execute ); + l_test := ut3_develop.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); + l_executable := ut3_develop.ut_executable_test( null, 'test_ut_executable', 'passing_proc', ut3_develop.ut_utils.gc_test_execute ); --Act l_result := l_executable.do_execute(l_test); --Assert @@ -19,14 +19,14 @@ create or replace package body test_ut_executable is end; procedure exec_package_proc_output is - l_executable ut3.ut_executable; - l_test ut3.ut_test; + l_executable ut3_develop.ut_executable; + l_test ut3_develop.ut_test; l_result boolean; begin --Arrange - l_test := ut3.ut_test(a_object_owner => 'ut3_tester', a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); - l_executable := ut3.ut_executable_test( a_owner => 'ut3_tester', a_package => 'test_ut_executable', - a_procedure_name => 'output_proc', a_executable_type => ut3.ut_utils.gc_test_execute ); + l_test := ut3_develop.ut_test(a_object_owner => 'ut3_tester', a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); + l_executable := ut3_develop.ut_executable_test( a_owner => 'ut3_tester', a_package => 'test_ut_executable', + a_procedure_name => 'output_proc', a_executable_type => ut3_develop.ut_utils.gc_test_execute ); --Act l_result := l_executable.do_execute(l_test); --Assert @@ -36,13 +36,13 @@ create or replace package body test_ut_executable is end; procedure exec_failing_proc is - l_executable ut3.ut_executable; - l_test ut3.ut_test; + l_executable ut3_develop.ut_executable; + l_test ut3_develop.ut_test; l_result boolean; begin --Arrange - l_test := ut3.ut_test(a_object_owner => 'ut3_tester', a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); - l_executable := ut3.ut_executable_test( 'ut3_tester', 'test_ut_executable', 'throwing_proc', ut3.ut_utils.gc_test_execute ); + l_test := ut3_develop.ut_test(a_object_owner => 'ut3_tester', a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); + l_executable := ut3_develop.ut_executable_test( 'ut3_tester', 'test_ut_executable', 'throwing_proc', ut3_develop.ut_utils.gc_test_execute ); --Act l_result := l_executable.do_execute(l_test); --Assert @@ -51,42 +51,12 @@ create or replace package body test_ut_executable is ut.expect(l_executable.get_error_stack_trace()).to_be_like('ORA-06501: PL/SQL: program error%'); end; - procedure modify_stateful_package is - l_job_name varchar2(30) := 'recreate_stateful_package'; - l_cnt integer := 1; - pragma autonomous_transaction; - begin - dbms_scheduler.create_job( - job_name => l_job_name, - job_type => 'PLSQL_BLOCK', - job_action => q'/ - begin - execute immediate q'[ - create or replace package stateful_package as - g_state varchar2(3) := 'abc'; - end;]'; - end;/', - start_date => localtimestamp, - enabled => TRUE, - auto_drop => TRUE, - comments => 'one-time job' - ); - $if dbms_db_version.version >= 18 $then - dbms_session.sleep(0.4); - $else - dbms_lock.sleep(0.4); - $end - while l_cnt > 0 loop - l_cnt:=ut3_tester_helper.main_helper.get_job_count(l_job_name); - end loop; - end; - procedure form_name is begin - ut.expect(ut3.ut_executable_test( user, ' package ', 'proc', null ).form_name()).to_equal(user||'.package.proc'); - ut.expect(ut3.ut_executable_test( null, 'package', ' proc ', null ).form_name()).to_equal('package.proc'); - ut.expect(ut3.ut_executable_test( null, 'proc', null, null ).form_name()).to_equal('proc'); - ut.expect(ut3.ut_executable_test( ' '||user||' ', 'proc', null, null ).form_name()).to_equal(user||'.proc'); + ut.expect(ut3_develop.ut_executable_test( user, ' package ', 'proc', null ).form_name()).to_equal(user||'.package.proc'); + ut.expect(ut3_develop.ut_executable_test( null, 'package', ' proc ', null ).form_name()).to_equal('package.proc'); + ut.expect(ut3_develop.ut_executable_test( null, 'proc', null, null ).form_name()).to_equal('proc'); + ut.expect(ut3_develop.ut_executable_test( ' '||user||' ', 'proc', null, null ).form_name()).to_equal(user||'.proc'); end; procedure passing_proc is diff --git a/test/ut3_tester/core/test_ut_metadata.pkb b/test/ut3_tester/core/test_ut_metadata.pkb new file mode 100644 index 000000000..905f31081 --- /dev/null +++ b/test/ut3_tester/core/test_ut_metadata.pkb @@ -0,0 +1,109 @@ +create or replace package body test_ut_metadata is + + c_cr constant varchar2(1) := chr(13); + c_lf constant varchar2(2) := chr(10); + c_crlf constant varchar2(2) := chr(13)||chr(10); + + c_pks_lf constant varchar2(1000) := + 'create or replace package test_package1 is'||c_lf + ||' procedure test_max_length;'||c_lf + ||'end;' + ; + c_pkg_lf constant varchar2(20000) := + q'[create or replace package body test_package1 is]'||c_lf + ||q'[ procedure test_max_length is]'||c_lf + ||q'[ begin]'||c_lf + ||q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_lf + ||substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_lf + ||q'[ dbms_output.put_line('test_max_length called.');]'||c_lf + ||q'[ end;]'||c_lf + ||q'[ end;]' + ; + + procedure test_over_varchar2_limit_trim_first_4000_lf + is + l_actual varchar2(32767); + l_expect varchar2(32767); + begin + l_expect := trim(substrb(q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_lf, 1, 4000)); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 4); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := trim(substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_lf); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 5); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := 'dbms_output.put_line(''test_max_length called.'');'||c_lf; + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 6); + ut.expect(l_actual).to_equal(l_expect); + end; + + procedure test_over_varchar2_limit_trim_first_4000_crlf is + l_actual varchar2(32767); + l_expect varchar2(32767); + begin + l_expect := trim(substrb(q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_crlf, 1, 4000)); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 4); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := trim(substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_cr); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 5); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := 'dbms_output.put_line(''test_max_length called.'');'||c_crlf; + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 6); + ut.expect(l_actual).to_equal(l_expect); + end; + + procedure test_over_varchar2_limit_trim_first_4000_cr + is + l_actual varchar2(32767); + l_expect varchar2(32767); + begin + l_expect := trim(substrb(q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_cr, 1, 4000)); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 4); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := trim(substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_cr); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 5); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := 'ut.expect(l_actual).to_equal(l_expect);'||c_cr; + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 6); + ut.expect(l_actual).to_equal(l_expect); + end; + + procedure clear_cache is + begin + ut3_develop.ut_metadata.reset_source_definition_cache(); + end; + + procedure drop_test_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_package1'; + end; + + procedure create_test_package_lf is + pragma autonomous_transaction; + begin + execute immediate c_pks_lf; + execute immediate c_pkg_lf; + end; + + procedure create_test_package_crlf is + pragma autonomous_transaction; + begin + execute immediate replace(c_pks_lf, c_lf, c_crlf); + execute immediate replace(c_pkg_lf, c_lf, c_crlf); + end; + + procedure create_test_package_cr is + pragma autonomous_transaction; + begin + execute immediate replace(c_pks_lf, c_lf, c_cr); + execute immediate replace(c_pkg_lf, c_lf, c_cr); + end; + +end; +/ \ No newline at end of file diff --git a/test/ut3_tester/core/test_ut_metadata.pks b/test/ut3_tester/core/test_ut_metadata.pks new file mode 100644 index 000000000..b4a1d601c --- /dev/null +++ b/test/ut3_tester/core/test_ut_metadata.pks @@ -0,0 +1,34 @@ +create or replace package test_ut_metadata is + --%suite(ut_metadata) + --%suitepath(utplsql.ut3_tester.core) + + --%context(get_source_definition_line) + + --%test(source line over 4000 limit is trimmed to first 4000 [linebreeak lf]) + --%beforetest(create_test_package_lf) + procedure test_over_varchar2_limit_trim_first_4000_lf; + + --%test(source line over 4000 limit is trimmed to first 4000 [linebreeak:crlf]) + --%beforetest(create_test_package_crlf) + procedure test_over_varchar2_limit_trim_first_4000_crlf; + + --%disabled(PLS-00103 occurs when execute immediate CR package) + --%test(source line over 4000 limit is trimmed to first 4000 [linebreeak cr]) + --%beforetest(create_test_package_cr) + procedure test_over_varchar2_limit_trim_first_4000_cr; + + --%beforeeach + procedure clear_cache; + --%aftereach + procedure drop_test_package; + + procedure create_test_package_lf; + + procedure create_test_package_crlf; + + procedure create_test_package_cr; + + --%endcontext + +end; +/ \ No newline at end of file diff --git a/test/ut3_tester/core/test_ut_suite.pkb b/test/ut3_tester/core/test_ut_suite.pkb index 3ea323a6d..7cb9121f6 100644 --- a/test/ut3_tester/core/test_ut_suite.pkb +++ b/test/ut3_tester/core/test_ut_suite.pkb @@ -16,23 +16,23 @@ create or replace package body test_ut_suite is end; procedure disabled_suite is - l_suite ut3.ut_suite; + l_suite ut3_develop.ut_suite; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); l_suite.path := 'ut3_tester_helper.ut_example_tests'; - l_suite.disabled_flag := ut3.ut_utils.boolean_to_int(true); - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_suite.after_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3.ut_utils.gc_before_all)); + l_suite.disabled_flag := ut3_develop.ut_utils.boolean_to_int(true); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); + l_suite.after_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3_develop.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_disabled); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_disabled); ut.expect(l_suite.results_count.disabled_count).to_equal(2); ut.expect(l_suite.results_count.warnings_count).to_equal(0); ut.expect(l_suite.results_count.success_count).to_equal(0); @@ -41,19 +41,19 @@ create or replace package body test_ut_suite is end; procedure beforeall_errors is - l_suite ut3.ut_suite; + l_suite ut3_develop.ut_suite; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); l_suite.path := 'ut3_tester_helper.ut_example_tests'; - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_before_all)); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3_develop.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); ut.expect(l_suite.results_count.success_count).to_equal(0); @@ -62,22 +62,22 @@ create or replace package body test_ut_suite is end; procedure aftereall_errors is - l_suite ut3.ut_suite; + l_suite ut3_develop.ut_suite; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); l_suite.path := 'ut3_tester_helper.ut_example_tests'; - l_suite.after_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_after_all)); + l_suite.after_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3_develop.ut_utils.gc_after_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_success); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(1); ut.expect(l_suite.results_count.success_count).to_equal(2); @@ -86,42 +86,42 @@ create or replace package body test_ut_suite is end; procedure package_without_body is - l_suite ut3.ut_suite; + l_suite ut3_develop.ut_suite; begin - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_WITHOUT_BODY', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_WITHOUT_BODY', a_line_no=> 1); l_suite.path := 'UT_WITHOUT_BODY'; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'ut_without_body',a_name => 'test1', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_name => 'ut_without_body',a_name => 'test1', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure package_with_invalid_body is - l_suite ut3.ut_suite; + l_suite ut3_develop.ut_suite; begin - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_WITH_INVALID_BODY', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_WITH_INVALID_BODY', a_line_no=> 1); l_suite.path := 'UT_WITH_INVALID_BODY'; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'ut_with_invalid_body',a_name => 'test1', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_name => 'ut_with_invalid_body',a_name => 'test1', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure rollback_auto is - l_suite ut3.ut_suite; + l_suite ut3_develop.ut_suite; begin --Arrange execute immediate 'delete from ut3_tester_helper.ut$test_table'; - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); l_suite.path := 'ut3_tester_helper.ut_transaction_control'; - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_TRANSACTION_CONTROL', 'setup', ut3.ut_utils.gc_before_all)); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable(USER, 'UT_TRANSACTION_CONTROL', 'setup', ut3_develop.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => USER, a_object_name => 'ut_transaction_control',a_name => 'test', a_line_no=> 1); - l_suite.set_rollback_type(ut3.ut_utils.gc_rollback_auto); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => USER, a_object_name => 'ut_transaction_control',a_name => 'test', a_line_no=> 1); + l_suite.set_rollback_type(ut3_develop.ut_utils.gc_rollback_auto); --Act l_suite.do_execute(); @@ -133,24 +133,24 @@ create or replace package body test_ut_suite is procedure rollback_auto_on_failure is begin - ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3.ut_utils.gc_rollback_auto, equal(0) ); + ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3_develop.ut_utils.gc_rollback_auto, equal(0) ); end; procedure rollback_manual is begin - ut3_tester_helper.run_helper.test_rollback_type('test', ut3.ut_utils.gc_rollback_manual, be_greater_than(0) ); + ut3_tester_helper.run_helper.test_rollback_type('test', ut3_develop.ut_utils.gc_rollback_manual, be_greater_than(0) ); end; procedure rollback_manual_on_failure is begin - ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3.ut_utils.gc_rollback_manual, be_greater_than(0) ); + ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3_develop.ut_utils.gc_rollback_manual, be_greater_than(0) ); end; procedure trim_transaction_invalidators is - l_suite ut3.ut_suite; + l_suite ut3_develop.ut_suite; begin --arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); for i in 1 .. 100 loop l_suite.add_transaction_invalidator('schema_name.package_name.procedure_name'||i); end loop; diff --git a/test/ut3_tester/core/test_ut_suite_tag_filter.pkb b/test/ut3_tester/core/test_ut_suite_tag_filter.pkb new file mode 100644 index 000000000..34af60549 --- /dev/null +++ b/test/ut3_tester/core/test_ut_suite_tag_filter.pkb @@ -0,0 +1,356 @@ +create or replace package body test_ut_suite_tag_filter is + + procedure test_conversion_to_rpn is + l_postfix ut3_develop.ut_varchar2_list; + l_postfix_string varchar2(4000); + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('A'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); + ut.expect(l_postfix_string).to_equal('A'); + + l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('A|B'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); + ut.expect(l_postfix_string).to_equal('AB|'); + + l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('(a|b)|c&d'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); + ut.expect(l_postfix_string).to_equal('ab|cd&|'); + + l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('!a|b'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); + ut.expect(l_postfix_string).to_equal('a!b|'); + end; + + procedure test_conversion_opr_by_opr is + l_postfix ut3_develop.ut_varchar2_list; + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_varchar2_list('A','B'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure test_conversion_oprd_by_opd is + l_postfix ut3_develop.ut_varchar2_list; + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_varchar2_list('|','|'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure test_conversion_lb_by_oper is + l_postfix ut3_develop.ut_varchar2_list; + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_varchar2_list('(','A','|','B',')','('); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure test_conversion_rb_by_oprd is + l_postfix ut3_develop.ut_varchar2_list; + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_varchar2_list(')','A'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure conversion_throws_when_lb_rb is + l_postfix ut3_develop.ut_varchar2_list; + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_varchar2_list('(',')'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure conversion_throws_when_unmatched_rb is + l_postfix ut3_develop.ut_varchar2_list; + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_varchar2_list('(','a',')',')'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure conversion_throws_when_empty is + l_postfix ut3_develop.ut_varchar2_list; + begin + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(ut3_develop.ut_varchar2_list()); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure conversion_throws_when_trailing_opr is + l_postfix ut3_develop.ut_varchar2_list; + begin + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(ut3_develop.ut_varchar2_list('a','|')); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure tokenize_empty_string is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.tokenize_tags_string(null).count ).to_equal(0); + end; + + procedure is_matching_or_and_not is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1', 'test1') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test2', 'test1') ).to_equal(0); + + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test2', 'test1|test2') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test3', 'test1|test2') ).to_equal(0); + + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test3', 'test1|!test2') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test2', 'test1|!test2') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1,test2', 'test1|!test2') ).to_equal(1); + + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1', 'test1&!test2') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1,test2', 'test1&!test2') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test3', 'test1&!test2') ).to_equal(0); + end; + + procedure is_matching_evaluates_tags is + l_tags varchar2(100) := 'db,slow'; + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'slow&db') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'slow&!db') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast|db') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, '!fast') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, '(fast|slow)&!(db&fast)') ).to_equal(1); + --legacy notation: "," is or, "-" is not + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast,slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast,-slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'none') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'any') ).to_equal(1); + end; + + procedure is_matching_without_tags is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'none') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'any') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, '!slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'slow') ).to_equal(0); + end; + + procedure is_matching_operator_precedence is + begin + --"&" binds stronger than "|" + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a|b&c') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b', 'a|b&c') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b,c', 'a|b&c') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('c', 'b&c|a') ).to_equal(0); + --brackets + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', '(a|b)&c') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,c', '(a|b)&c') ).to_equal(1); + --"!" binds stronger than "&" + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b', '!a&b') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,b', '!a&b') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', '!(a&b)') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,b', '!(a&b)') ).to_equal(0); + --double negation + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', '!!a') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b', '!!a') ).to_equal(0); + end; + + procedure is_matching_none_and_any_combined is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'none|slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'none|slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db', 'none|slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', '!none') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, '!none') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, '!any') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'any&!slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db', 'any&!slow') ).to_equal(1); + end; + + procedure is_matching_is_case_sensitive is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('Slow', 'slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'SLOW') ).to_equal(0); + --upper case keywords are tags, not the none and any keywords + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'NONE') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'ANY') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('ANY', 'ANY') ).to_equal(1); + end; + + procedure is_matching_ignores_whitespace is + c_tab constant varchar2(1) := chr(9); + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', ' slow & db ') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', ' ( fast | slow ) & ! db ') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', c_tab||'slow'||c_tab||'&'||c_tab||'db'||c_tab) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', 'slow'||c_tab||'&'||c_tab||'!'||c_tab||'db') ).to_equal(0); + --legacy notation + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', 'fast, slow') ).to_equal(1); + end; + + procedure is_matching_empty_expression is + c_tab constant varchar2(1) := chr(9); + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', null) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, null) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', ' ') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, ' ') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', c_tab) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, ' '||c_tab||' ') ).to_equal(1); + end; + + procedure remove_whitespace_from_expression is + c_tab constant varchar2(1) := chr(9); + begin + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(null) ).to_be_null(); + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(' ') ).to_be_null(); + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(' '||c_tab||c_tab||' ') ).to_be_null(); + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(' slow &'||c_tab||'db ') ).to_equal('slow&db'); + end; + + procedure is_matching_tag_with_quote is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(q'[it's]', q'[it's]') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', q'[slow&!it's]') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', q'[it's]') ).to_equal(0); + end; + + procedure is_matching_many_tags is + c_tag_prefix constant varchar2(30) := 'a_long_tag_name_for_testing_'; + l_expression varchar2(32767); + begin + --80 tags of 31 characters, joined with "|": a condition with "member of" for each tag would be over 4000 characters + for i in 1 .. 80 loop + l_expression := l_expression || case when i > 1 then '|' end || c_tag_prefix || lpad(i, 3, '0'); + end loop; + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(c_tag_prefix||'080', l_expression) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow,'||c_tag_prefix||'001', l_expression) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', l_expression) ).to_equal(0); + end; + + procedure is_matching_null_tag_element is + begin + --'a,,b' has a null element, so "x member of" it is unknown (null) instead of false when x is not in the list + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'a') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'x') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', '!x') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'a|!x') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'a&!x') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', '!a&!x') ).to_equal(0); + end; + + procedure is_matching_follows_expression_change is + l_result integer; + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'b') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a') ).to_equal(1); + begin + l_result := ut3_develop.ut_suite_tag_filter.is_matching('a', 'a&'); + ut.fail('Expected exception but nothing was raised'); + exception + when others then + ut.expect( sqlcode ).to_equal( ut3_develop.ut_utils.gc_invalid_tag_expression ); + end; + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'b') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a') ).to_equal(1); + end; + + procedure is_matching_invalid_expression is + l_result integer; + begin + l_result := ut3_develop.ut_suite_tag_filter.is_matching('slow', 'slow&|db'); + end; + + procedure is_matching_incomplete_expression is + --legacy notation turns ',' into an empty expression + l_expressions ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('slow|', 'slow&!', '!', '(slow', ','); + l_result integer; + begin + for i in 1 .. l_expressions.count loop + begin + l_result := ut3_develop.ut_suite_tag_filter.is_matching('slow', l_expressions(i)); + ut.fail('Expected exception for tag expression "'||l_expressions(i)||'" but nothing was raised'); + exception + when others then + ut.expect( sqlcode, 'Tag expression "'||l_expressions(i)||'"' ).to_equal( ut3_develop.ut_utils.gc_invalid_tag_expression ); + end; + end loop; + end; + + procedure create_tags_suite is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_tags_1324 as + --%suite + --%suitepath(some.path) + --%tags(slow) + + --%context(tags_are_applied_in_contexts) + --%tags(context_tag) + + --%test + --%tags(test_tag) + procedure create_new_mapping; + + --%endcontext + end;]'; + execute immediate q'[create or replace package body test_tags_1324 as + procedure create_new_mapping is begin null; end; + end;]'; + end; + + procedure drop_tags_suite is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_tags_1324'; + end; + + procedure filtering_is_correctly_applied_to_all_items is + l_paths ut3_develop.ut_path_items; + l_suites ut3_develop.ut_suite_items; + l_items ut3_develop.ut_suite_cache_rows; + l_expected sys_refcursor; + l_actual sys_refcursor; + + --suite items selected by the tag expression, without the logical suites "some" and "some.path" + function get_items(a_tags varchar2) return ut3_develop.ut_suite_cache_rows is + l_rows ut3_develop.ut_suite_cache_rows; + l_result ut3_develop.ut_suite_cache_rows; + begin + l_rows := ut3_develop.ut_suite_cache_manager.get_suite_rows( l_paths, true, a_tags ); + select value(r) bulk collect into l_result from table(l_rows) r where r.self_type != 'UT_LOGICAL_SUITE'; + return l_result; + end; + begin + --refresh the suite cache of the schema + l_suites := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_tester.test_tags_1324')); + l_paths := ut3_develop.ut_suite_cache_manager.get_schema_paths(ut3_develop.ut_varchar2_list('ut3_tester.test_tags_1324')); + + l_items := get_items('slow'); + ut.expect( l_items.count ).to_equal(3); + + open l_expected for + select 'some.path.test_tags_1324' as path from dual union all + select 'some.path.test_tags_1324.nested_context_#1' from dual union all + select 'some.path.test_tags_1324.nested_context_#1.create_new_mapping' from dual; + open l_actual for select r.path from table( l_items ) r; + ut.expect(l_actual).to_equal(l_expected).unordered(); + + ut.expect( get_items('!slow').count ).to_equal(0); + ut.expect( get_items('bad').count ).to_equal(0); + ut.expect( get_items('!bad').count ).to_equal(3); + ut.expect( get_items('!context_tag').count ).to_equal(0); + ut.expect( get_items('context_tag').count ).to_equal(3); + ut.expect( get_items('!test_tag').count ).to_equal(0); + ut.expect( get_items('test_tag').count ).to_equal(3); + end; + +end test_ut_suite_tag_filter; +/ diff --git a/test/ut3_tester/core/test_ut_suite_tag_filter.pks b/test/ut3_tester/core/test_ut_suite_tag_filter.pks new file mode 100644 index 000000000..92c8cc744 --- /dev/null +++ b/test/ut3_tester/core/test_ut_suite_tag_filter.pks @@ -0,0 +1,103 @@ +create or replace package test_ut_suite_tag_filter is + + --%suite(ut_suite_tag_filter) + --%suitepath(utplsql.ut3_tester.core) + + --%context( Conversion to Reverse Polish Notation) + + --%test( Test conversion of expression into Reverse Polish Notation) + procedure test_conversion_to_rpn; + + --%test( Operator is followed by operator) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_opr_by_opr; + + --%test( Operand is followed by operand) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_oprd_by_opd; + + --%test( Left Bracket is followed by operator) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_lb_by_oper; + + --%test( Right Bracket is followed by operand) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_rb_by_oprd; + + --%test(Conversion raises exception when empty brackets) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_lb_rb; + + --%test(Conversion raises exception when a right bracket has no left bracket) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_unmatched_rb; + + --%test(Conversion raises exception for an empty list of tokens) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_empty; + + --%test(Conversion raises exception when the expression ends with an operator) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_trailing_opr; + + --%test(Tokenizing an empty string returns no tokens) + procedure tokenize_empty_string; + + --%endcontext + + --%test( Evaluates or, and and not in tag expressions) + procedure is_matching_or_and_not; + + --%test( Evaluates tag expressions against a list of tags) + procedure is_matching_evaluates_tags; + + --%test( Evaluates none and any for items without tags) + procedure is_matching_without_tags; + + --%test( Applies operator precedence, brackets and double negation) + procedure is_matching_operator_precedence; + + --%test( Combines none and any with other tags) + procedure is_matching_none_and_any_combined; + + --%test( Compares tags and the none and any keywords case sensitively) + procedure is_matching_is_case_sensitive; + + --%test( Ignores spaces and tabs in the tag expression) + procedure is_matching_ignores_whitespace; + + --%test( Matches any tags when the tag expression is empty or made of spaces and tabs) + procedure is_matching_empty_expression; + + --%test( Removes spaces and tabs from a tag expression, returning null for one made only of them) + procedure remove_whitespace_from_expression; + + --%test( Evaluates a tag containing a quote) + procedure is_matching_tag_with_quote; + + --%test( Evaluates an expression with many tags) + procedure is_matching_many_tags; + + --%test( Follows three-valued logic for an empty element in the list of tags) + procedure is_matching_null_tag_element; + + --%test( Evaluates the current expression after the expression changes or an invalid expression is given) + procedure is_matching_follows_expression_change; + + --%test( Raises exception for an invalid tag expression) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure is_matching_invalid_expression; + + --%test( Raises exception for an incomplete tag expression) + procedure is_matching_incomplete_expression; + + procedure create_tags_suite; + procedure drop_tags_suite; + + --%test( Regression for issue #1324 - corect filtering by tags with suitepath and contexts) + --%beforetest(create_tags_suite) + --%aftertest(drop_tags_suite) + procedure filtering_is_correctly_applied_to_all_items; + +end test_ut_suite_tag_filter; +/ diff --git a/test/ut3_tester/core/test_ut_test.pkb b/test/ut3_tester/core/test_ut_test.pkb index 2a85a323f..f6f59df08 100644 --- a/test/ut3_tester/core/test_ut_test.pkb +++ b/test/ut3_tester/core/test_ut_test.pkb @@ -6,24 +6,24 @@ create or replace package body test_ut_test is end; procedure disabled_test is - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); l_suite.path := 'ut3_tester_helper.ut_example_tests'; - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 2); - l_suite.items(l_suite.items.last).disabled_flag := ut3.ut_utils.boolean_to_int(true); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 2); + l_suite.items(l_suite.items.last).disabled_flag := ut3_develop.ut_utils.boolean_to_int(true); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_success); ut.expect(l_suite.results_count.disabled_count).to_equal(1); ut.expect(l_suite.results_count.warnings_count).to_equal(0); ut.expect(l_suite.results_count.success_count).to_equal(1); @@ -32,26 +32,26 @@ create or replace package body test_ut_test is end; procedure aftertest_errors is - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); l_suite.path := 'ut3_tester_helper.ut_example_tests'; - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_before_test)); - l_test.after_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_after_test)); + l_test := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_before_test)); + l_test.after_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.ut_utils.gc_after_test)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(3); - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); ut.expect(l_suite.results_count.success_count).to_equal(1); @@ -60,24 +60,24 @@ create or replace package body test_ut_test is end; procedure aftereach_errors is - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_before_each)); - l_test.after_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_after_each)); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); + l_test := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_before_each)); + l_test.after_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.ut_utils.gc_after_each)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(3); - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); ut.expect(l_suite.results_count.success_count).to_equal(1); @@ -86,24 +86,24 @@ create or replace package body test_ut_test is end; procedure beforetest_errors is - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'ut_example_tests', a_line_no=> 1); - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_owner =>'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_before_test)); - l_test.after_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_after_test)); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); + l_test := ut3_develop.ut_test(a_object_owner =>'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.ut_utils.gc_before_test)); + l_test.after_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_after_test)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner =>'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner =>'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(2); - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); ut.expect(l_suite.results_count.success_count).to_equal(1); @@ -112,24 +112,24 @@ create or replace package body test_ut_test is end; procedure beforeeach_errors is - l_suite ut3.ut_suite; - l_test ut3.ut_test; + l_suite ut3_develop.ut_suite; + l_test ut3_develop.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'ut_example_tests', a_line_no=> 1); - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_owner => USER,a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_before_each)); - l_test.after_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_after_each)); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); + l_test := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.ut_utils.gc_before_each)); + l_test.after_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_after_each)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => USER,a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(2); - ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); ut.expect(l_suite.results_count.success_count).to_equal(1); @@ -139,63 +139,63 @@ create or replace package body test_ut_test is procedure after_each_executed is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.after_each_list := ut3.ut_executables( - ut3.ut_executable( - user, - 'UT_EXAMPLE_TESTS', + l_test.after_each_list := ut3_develop.ut_executables( + ut3_develop.ut_executable( + 'ut3_tester_helper', + 'ut_example_tests', 'add_1_to_g_number', - ut3.ut_utils.gc_after_each + ut3_develop.ut_utils.gc_after_each ) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure after_each_proc_name_invalid is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.after_each_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', 'invalid setup name', ut3.ut_utils.gc_after_each) + l_test.after_each_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid setup name', ut3_develop.ut_utils.gc_after_each) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; procedure after_each_procedure_name_null is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.after_each_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', null, ut3.ut_utils.gc_after_each) + l_test.after_each_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_after_each) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; @@ -292,7 +292,7 @@ create or replace package body test_ut_test is end; procedure application_info_on_execution is - l_output_data ut3.ut_varchar2_list; + l_output_data ut3_develop.ut_varchar2_list; l_output clob; function get_test_value(a_variable_name varchar2) return varchar2 is l_result varchar2(4000); @@ -303,8 +303,8 @@ create or replace package body test_ut_test is begin --act select * bulk collect into l_output_data - from table(ut3.ut.run('ut_output_tests')); - l_output := ut3.ut_utils.table_to_clob(l_output_data); + from table(ut3_develop.ut.run('ut_output_tests')); + l_output := ut3_develop.ut_utils.table_to_clob(l_output_data); --assert ut.expect(get_test_value('gv_before_all_client_info')).to_equal('beforeall'); @@ -318,80 +318,80 @@ create or replace package body test_ut_test is procedure before_each_executed is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'add_1_to_g_number', a_line_no => null ); begin - l_test.before_each_list := ut3.ut_executables(ut3.ut_executable(user, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_each)); + l_test.before_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_each)); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure before_each_proc_name_invalid is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.before_each_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', 'invalid setup name', ut3.ut_utils.gc_before_each) + l_test.before_each_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid setup name', ut3_develop.ut_utils.gc_before_each) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure before_each_proc_name_null is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.before_each_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', null, ut3.ut_utils.gc_before_each) + l_test.before_each_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_before_each) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure ignore_savepoint_exception is pragma autonomous_transaction; --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'ut_commit_test', a_line_no => null ); begin - l_test.rollback_type := ut3.ut_utils.gc_rollback_auto; + l_test.rollback_type := ut3_develop.ut_utils.gc_rollback_auto; --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); end; procedure owner_name_invalid is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'invalid owner name', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', @@ -401,7 +401,7 @@ create or replace package body test_ut_test is --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure create_synonym is @@ -416,7 +416,7 @@ create or replace package body test_ut_test is procedure owner_name_null is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -425,7 +425,7 @@ create or replace package body test_ut_test is --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; @@ -450,7 +450,7 @@ create or replace package body test_ut_test is procedure package_in_invalid_state is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_name => 'invalid_package', a_name => 'ut_exampletest', a_line_no => null @@ -459,12 +459,12 @@ create or replace package body test_ut_test is --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure package_name_invalid is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_name => 'invalid package name', a_name => 'set_g_number_0', a_line_no => null @@ -473,12 +473,12 @@ create or replace package body test_ut_test is --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure package_name_null is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_name => null, a_name => 'set_g_number_0', a_line_no => null @@ -487,12 +487,12 @@ create or replace package body test_ut_test is --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure procedure_name_invalid is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'invalid procedure name', @@ -502,12 +502,12 @@ create or replace package body test_ut_test is --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure procedure_name_null is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => null, @@ -517,116 +517,116 @@ create or replace package body test_ut_test is --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); end; procedure before_test_executed is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'add_1_to_g_number', a_line_no => null ); begin - l_test.before_test_list := ut3.ut_executables(ut3.ut_executable(user, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_test)); + l_test.before_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_test)); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure before_test_proc_name_invalid is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.before_test_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', 'invalid setup name', ut3.ut_utils.gc_before_test) + l_test.before_test_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid setup name', ut3_develop.ut_utils.gc_before_test) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure before_test_proc_name_null is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.before_test_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', null, ut3.ut_utils.gc_before_test) + l_test.before_test_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_before_test) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure after_test_executed is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.after_test_list := ut3.ut_executables(ut3.ut_executable(user, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_after_test)); + l_test.after_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_after_test)); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure after_test_proce_name_invalid is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.after_test_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', 'invalid procedure name', ut3.ut_utils.gc_after_test) + l_test.after_test_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid procedure name', ut3_develop.ut_utils.gc_after_test) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; procedure after_test_proc_name_null is --Arrange - l_test ut3.ut_test := ut3.ut_test( + l_test ut3_develop.ut_test := ut3_develop.ut_test( a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.after_test_list := ut3.ut_executables( - ut3.ut_executable(user, 'ut_example_tests', null, ut3.ut_utils.gc_after_test) + l_test.after_test_list := ut3_develop.ut_executables( + ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_after_test) ); --Act l_test.do_execute(); --Assert - ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); + ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; @@ -711,12 +711,12 @@ create or replace package body test_ut_test is end; procedure test_output_gathering is - l_output_data ut3.ut_varchar2_list; + l_output_data ut3_develop.ut_varchar2_list; l_output clob; begin select * bulk collect into l_output_data - from table(ut3.ut.run('ut_output_tests')); - l_output := ut3.ut_utils.table_to_clob(l_output_data); + from table(ut3_develop.ut.run('ut_output_tests')); + l_output := ut3_develop.ut_utils.table_to_clob(l_output_data); ut.expect(l_output).to_be_like( '%%%%%%%%1 tests, 0 failed, 0 errored%' ); diff --git a/test/ut3_tester/core/test_ut_test.pks b/test/ut3_tester/core/test_ut_test.pks index 18ea6613f..caf75eb6c 100644 --- a/test/ut3_tester/core/test_ut_test.pks +++ b/test/ut3_tester/core/test_ut_test.pks @@ -29,7 +29,7 @@ create or replace package test_ut_test is --%test(Fails test when aftereach procedure name invalid) procedure after_each_proc_name_invalid; - --%test(Tails test when aftereach procedure name null) + --%test(Fails test when aftereach procedure name null) procedure after_each_procedure_name_null; procedure create_app_info_package; diff --git a/test/ut3_tester/core/test_ut_utils.pkb b/test/ut3_tester/core/test_ut_utils.pkb index 31e1520d2..d46835f66 100644 --- a/test/ut3_tester/core/test_ut_utils.pkb +++ b/test/ut3_tester/core/test_ut_utils.pkb @@ -33,17 +33,17 @@ create or replace package body test_ut_utils is end; - procedure common_clob_to_table_exec(p_clob varchar2, p_delimiter varchar2, p_expected_list ut3.ut_varchar2_list, p_limit number) is + procedure common_clob_to_table_exec(p_clob varchar2, p_delimiter varchar2, p_expected_list ut3_develop.ut_varchar2_list, p_limit number) is begin execute immediate 'declare l_clob clob := '''||p_clob||'''; l_delimiter varchar2(1) := '''||p_delimiter||'''; - l_expected ut3.ut_varchar2_list := :p_expected_list; - l_result ut3.ut_varchar2_list; + l_expected ut3_develop.ut_varchar2_list := :p_expected_list; + l_result ut3_develop.ut_varchar2_list; l_limit integer := '||p_limit||q'[; l_result_str varchar2(32767); l_errors integer := 0; - function compare_element(a_element_id integer, a_expected ut3.ut_varchar2_list, a_actual ut3.ut_varchar2_list) return integer is + function compare_element(a_element_id integer, a_expected ut3_develop.ut_varchar2_list, a_actual ut3_develop.ut_varchar2_list) return integer is begin if a_expected.exists(a_element_id) and a_actual.exists(a_element_id) then if a_expected(a_element_id) = a_actual(a_element_id) or a_expected(a_element_id) is null and a_actual(a_element_id) is null then @@ -63,7 +63,7 @@ create or replace package body test_ut_utils is end; begin --Act - select column_value bulk collect into l_result from table( ut3.ut_utils.clob_to_table(l_clob, l_limit, l_delimiter) ); + select column_value bulk collect into l_result from table( ut3_develop.ut_utils.clob_to_table(l_clob, l_limit, l_delimiter) ); for i in 1 .. l_result.count loop l_result_str := l_result_str||''''||l_result(i)||''''||l_delimiter; end loop; @@ -78,68 +78,68 @@ end;]' using p_expected_list; procedure test_clob_to_table is begin - common_clob_to_table_exec('a,b,c,d', ',', ut3.ut_varchar2_list('a','b','c','d'), 1000); - common_clob_to_table_exec( '', ',', ut3.ut_varchar2_list(), 1000); - common_clob_to_table_exec( '1,b,c,d', '', ut3.ut_varchar2_list('1,b,','c,d'), 4); - common_clob_to_table_exec( 'abcdefg,hijk,axa,a', ',', ut3.ut_varchar2_list('abc','def','g','hij','k','axa','a'), 3); - common_clob_to_table_exec( ',a,,c,d,', ',', ut3.ut_varchar2_list('','a','','c','d',''), 1000); + common_clob_to_table_exec('a,b,c,d', ',', ut3_develop.ut_varchar2_list('a','b','c','d'), 1000); + common_clob_to_table_exec( '', ',', ut3_develop.ut_varchar2_list(), 1000); + common_clob_to_table_exec( '1,b,c,d', '', ut3_develop.ut_varchar2_list('1,b,','c,d'), 4); + common_clob_to_table_exec( 'abcdefg,hijk,axa,a', ',', ut3_develop.ut_varchar2_list('abc','def','g','hij','k','axa','a'), 3); + common_clob_to_table_exec( ',a,,c,d,', ',', ut3_develop.ut_varchar2_list('','a','','c','d',''), 1000); end; procedure test_test_result_to_char is begin - ut.expect(ut3.ut_utils.test_result_to_char(-1),'test unknown').to_equal('Unknown(-1)'); - ut.expect(ut3.ut_utils.test_result_to_char(null),'test unknown').to_equal('Unknown(NULL)'); - ut.expect(ut3.ut_utils.test_result_to_char(ut3.ut_utils.gc_success),'test unknown').to_equal(ut3.ut_utils.gc_success_char); + ut.expect(ut3_develop.ut_utils.test_result_to_char(-1),'test unknown').to_equal('Unknown(-1)'); + ut.expect(ut3_develop.ut_utils.test_result_to_char(null),'test unknown').to_equal('Unknown(NULL)'); + ut.expect(ut3_develop.ut_utils.test_result_to_char(ut3_develop.ut_utils.gc_success),'test unknown').to_equal(ut3_develop.ut_utils.gc_success_char); end; procedure to_string_emptyblob is begin - ut.expect(ut3.ut_data_value_blob(empty_blob()).to_string()).to_equal('EMPTY'); + ut.expect(ut3_develop.ut_data_value_blob(empty_blob()).to_string()).to_equal('EMPTY'); end; procedure to_string_emptyclob is begin - ut.expect(ut3.ut_data_value_clob(empty_clob()).to_string()).to_equal('EMPTY'); + ut.expect(ut3_develop.ut_data_value_clob(empty_clob()).to_string()).to_equal('EMPTY'); end; procedure to_string_nullblob is begin - ut.expect(ut3.ut_data_value_blob(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_blob(null).to_string()).to_equal('NULL'); end; procedure to_string_nullclob is begin - ut.expect(ut3.ut_data_value_clob(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_clob(null).to_string()).to_equal('NULL'); end; procedure to_string_nulldate is begin - ut.expect(ut3.ut_data_value_date(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_date(null).to_string()).to_equal('NULL'); end; procedure to_string_nullnumber is begin - ut.expect(ut3.ut_data_value_number(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_number(null).to_string()).to_equal('NULL'); end; procedure to_string_nulltimestamp is begin - ut.expect(ut3.ut_data_value_timestamp(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_timestamp(null).to_string()).to_equal('NULL'); end; procedure to_string_nulltimestamp_ltz is begin - ut.expect(ut3.ut_data_value_timestamp_ltz(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_timestamp_ltz(null).to_string()).to_equal('NULL'); end; procedure to_string_nulltimestamp_tz is begin - ut.expect(ut3.ut_data_value_timestamp_tz(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_timestamp_tz(null).to_string()).to_equal('NULL'); end; procedure to_string_nullvarchar2 is begin - ut.expect(ut3.ut_data_value_varchar2(null).to_string()).to_equal('NULL'); + ut.expect(ut3_develop.ut_data_value_varchar2(null).to_string()).to_equal('NULL'); end; procedure to_string_blob is @@ -147,49 +147,49 @@ end;]' using p_expected_list; l_value blob := utl_raw.cast_to_raw(l_text); l_expected varchar2(32767) := ''''||rawtohex(l_value)||''''; begin - ut.expect(ut3.ut_data_value_blob(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_blob(l_value).to_string()).to_equal(l_expected); end; procedure to_string_clob is l_value clob := 'A test char'; l_expected varchar2(32767) := ''''||l_value||''''; begin - ut.expect(ut3.ut_data_value_clob(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_clob(l_value).to_string()).to_equal(l_expected); end; procedure to_string_date is l_value date := to_date('2016-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss'); - l_expected varchar2(100) := '2016-12-31T23:59:59'; + l_expected varchar2(100) := ' 2016-12-31T23:59:59'; begin - ut.expect(ut3.ut_data_value_date(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_date(l_value).to_string()).to_equal(l_expected); end; procedure to_string_timestamp is l_value timestamp(9) := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_expected varchar2(100) := '2016-12-31T23:59:59'||gc_delimiter||'123456789'; + l_expected varchar2(100) := ' 2016-12-31T23:59:59'||gc_delimiter||'123456789'; begin - ut.expect(ut3.ut_data_value_timestamp(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_timestamp(l_value).to_string()).to_equal(l_expected); end; procedure to_string_timestamp_ltz is l_value timestamp(9) with local time zone := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_expected varchar2(100) := '2016-12-31T23:59:59'||gc_delimiter||'123456789'; + l_expected varchar2(100) := ' 2016-12-31T23:59:59'||gc_delimiter||'123456789'; begin - ut.expect(ut3.ut_data_value_timestamp_ltz(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_timestamp_ltz(l_value).to_string()).to_equal(l_expected); end; procedure to_string_timestamp_tz is l_value timestamp(9) with time zone := to_timestamp_tz('2016-12-31 23:59:59.123456789 -8:00', 'yyyy-mm-dd hh24:mi:ss.ff tzh:tzm'); - l_expected varchar2(100) := '2016-12-31T23:59:59'||gc_delimiter||'123456789 -08:00'; + l_expected varchar2(100) := ' 2016-12-31T23:59:59'||gc_delimiter||'123456789 -08:00'; begin - ut.expect(ut3.ut_data_value_timestamp_tz(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_timestamp_tz(l_value).to_string()).to_equal(l_expected); end; procedure to_string_varchar2 is l_value varchar2(20) := 'A test char'; l_expected varchar2(100) := ''''||l_value||''''; begin - ut.expect(ut3.ut_data_value_varchar2(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_varchar2(l_value).to_string()).to_equal(l_expected); end; procedure to_string_verybigblob is @@ -197,53 +197,53 @@ end;]' using p_expected_list; l_value blob; begin l_value := clob_to_blob(l_text); - ut.expect(length(ut3.ut_data_value_blob(l_value).to_string())).to_equal(ut3.ut_utils.gc_max_output_string_length); - ut.expect(ut3.ut_data_value_blob(l_value).to_string()).to_be_like('%'||ut3.ut_utils.gc_more_data_string); + ut.expect(length(ut3_develop.ut_data_value_blob(l_value).to_string())).to_equal(ut3_develop.ut_utils.gc_max_output_string_length); + ut.expect(ut3_develop.ut_data_value_blob(l_value).to_string()).to_be_like('%'||ut3_develop.ut_utils.gc_more_data_string); end; procedure to_string_verybigclob is l_value clob := lpad('A test char',32767,'1')||lpad('1',32767,'1'); begin - ut.expect(length(ut3.ut_data_value_clob(l_value).to_string())).to_equal(ut3.ut_utils.gc_max_output_string_length); - ut.expect(ut3.ut_data_value_clob(l_value).to_string()).to_be_like('%'||ut3.ut_utils.gc_more_data_string); + ut.expect(length(ut3_develop.ut_data_value_clob(l_value).to_string())).to_equal(ut3_develop.ut_utils.gc_max_output_string_length); + ut.expect(ut3_develop.ut_data_value_clob(l_value).to_string()).to_be_like('%'||ut3_develop.ut_utils.gc_more_data_string); end; procedure to_string_verybignumber is l_value number := 1234567890123456789012345678901234567890; l_expected varchar2(100) := '1234567890123456789012345678901234567890'; begin - ut.expect(ut3.ut_data_value_number(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_number(l_value).to_string()).to_equal(l_expected); end; procedure to_string_verybigvarchar2 is l_value varchar2(32767) := lpad('A test char',32767,'1'); l_result varchar2(32767); begin - ut.expect(length(ut3.ut_data_value_varchar2(l_value).to_string())).to_equal(ut3.ut_utils.gc_max_output_string_length); - ut.expect(ut3.ut_data_value_varchar2(l_value).to_string()).to_be_like('%'||ut3.ut_utils.gc_more_data_string); + ut.expect(length(ut3_develop.ut_data_value_varchar2(l_value).to_string())).to_equal(ut3_develop.ut_utils.gc_max_output_string_length); + ut.expect(ut3_develop.ut_data_value_varchar2(l_value).to_string()).to_be_like('%'||ut3_develop.ut_utils.gc_more_data_string); end; procedure to_string_verysmallnumber is l_value number := 0.123456789012345678901234567890123456789; l_expected varchar2(100) := gc_delimiter||'123456789012345678901234567890123456789'; begin - ut.expect(ut3.ut_data_value_number(l_value).to_string()).to_equal(l_expected); + ut.expect(ut3_develop.ut_data_value_number(l_value).to_string()).to_equal(l_expected); end; procedure test_table_to_clob is - procedure exec_table_to_clob(a_list ut3.ut_varchar2_list, a_delimiter varchar2, a_expected clob) is + procedure exec_table_to_clob(a_list ut3_develop.ut_varchar2_list, a_delimiter varchar2, a_expected clob) is l_result clob; begin - l_result := ut3.ut_utils.table_to_clob(a_list, a_delimiter); + l_result := ut3_develop.ut_utils.table_to_clob(a_list, a_delimiter); ut.expect(l_result).to_equal(a_expected, a_nulls_are_equal => true); end; begin exec_table_to_clob(null, ',', ''); - exec_table_to_clob(ut3.ut_varchar2_list(), ',', ''); - exec_table_to_clob(ut3.ut_varchar2_list('a', 'b', 'c', 'd'), ',', 'a,b,c,d'); - exec_table_to_clob(ut3.ut_varchar2_list('1,b,', 'c,d'), ',', '1,b,,c,d'); - exec_table_to_clob(ut3.ut_varchar2_list('', 'a', '', 'c', 'd', ''), ',', ',a,,c,d,'); + exec_table_to_clob(ut3_develop.ut_varchar2_list(), ',', ''); + exec_table_to_clob(ut3_develop.ut_varchar2_list('a', 'b', 'c', 'd'), ',', 'a,b,c,d'); + exec_table_to_clob(ut3_develop.ut_varchar2_list('1,b,', 'c,d'), ',', '1,b,,c,d'); + exec_table_to_clob(ut3_develop.ut_varchar2_list('', 'a', '', 'c', 'd', ''), ',', ',a,,c,d,'); end; procedure test_append_with_multibyte is @@ -258,7 +258,7 @@ end;]' using p_expected_list; for i in 1..l_lines.count loop l_result := null; - ut3.ut_utils.append_to_clob(l_result, l_lines(i)); + ut3_develop.ut_utils.append_to_clob(l_result, l_lines(i)); --Assert ut.expect(dbms_lob.getlength(l_result),'Error for index '||i).to_equal(dbms_lob.getlength(l_lines(i))); @@ -287,23 +287,23 @@ end;'; l_varchar2_byte_limit integer := 32767; l_workaround_byte_limit integer := 8191; l_singlebyte_string_max_size varchar2(32767 char) := rpad('x',l_varchar2_byte_limit,'x'); - l_twobyte_character char(1 char) := '�?'; + l_twobyte_character char(1 char) := unistr('\00E4'); l_clob_multibyte clob := l_twobyte_character||l_singlebyte_string_max_size; --here we have 32769(2+32767) bytes and 32768 chars - l_expected ut3.ut_varchar2_list := ut3.ut_varchar2_list(); - l_result ut3.ut_varchar2_list; + l_expected ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); + l_result ut3_develop.ut_varchar2_list; begin l_expected.extend(1); l_expected(1) := l_twobyte_character||substr(l_singlebyte_string_max_size,1,l_workaround_byte_limit-1); --Act - l_result := ut3.ut_utils.clob_to_table(l_clob_multibyte); + l_result := ut3_develop.ut_utils.clob_to_table(l_clob_multibyte); --Assert ut.expect(l_result(1)).to_equal(l_expected(1)); end; procedure test_to_version_split is - l_version ut3.ut_utils.t_version; + l_version ut3_develop.ut_utils.t_version; begin - l_version := ut3.ut_utils.to_version('v034.0.0456.0333'); + l_version := ut3_develop.ut_utils.to_version('v034.0.0456.0333'); ut.expect(l_version.major).to_equal(34); ut.expect(l_version.minor).to_equal(0); ut.expect(l_version.bugfix).to_equal(456); @@ -312,62 +312,62 @@ end;'; procedure test_trim_list_elements is - l_list_to_be_equal ut3.ut_varchar2_list := ut3.ut_varchar2_list('hello', 'world', 'okay'); - l_list ut3.ut_varchar2_list := ut3.ut_varchar2_list(' hello ', chr(9)||'world ', 'okay'); + l_list_to_be_equal ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('hello', 'world', 'okay'); + l_list ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(' hello ', chr(9)||'world ', 'okay'); begin --Act - l_list := ut3.ut_utils.trim_list_elements(l_list); + l_list := ut3_develop.ut_utils.trim_list_elements(l_list); --Assert ut.expect(anydata.convertcollection(l_list)).to_equal(anydata.convertcollection(l_list_to_be_equal)); end; procedure trim_list_elemts_null_collect is - l_list_to_be_null ut3.ut_varchar2_list; + l_list_to_be_null ut3_develop.ut_varchar2_list; begin --Act - l_list_to_be_null := ut3.ut_utils.trim_list_elements(l_list_to_be_null); + l_list_to_be_null := ut3_develop.ut_utils.trim_list_elements(l_list_to_be_null); --Assert ut.expect(anydata.convertcollection(l_list_to_be_null)).to_be_null; end; procedure trim_list_elemts_empty_collect is - l_list_to_be_empty ut3.ut_varchar2_list := ut3.ut_varchar2_list(); + l_list_to_be_empty ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); begin --Act - l_list_to_be_empty := ut3.ut_utils.trim_list_elements(l_list_to_be_empty); + l_list_to_be_empty := ut3_develop.ut_utils.trim_list_elements(l_list_to_be_empty); --Assert ut.expect(anydata.convertcollection(l_list_to_be_empty)).to_be_empty; end; procedure test_filter_list is - l_list_to_be_equal ut3.ut_varchar2_list := ut3.ut_varchar2_list('-12458', '8956', '789'); - l_list ut3.ut_varchar2_list := ut3.ut_varchar2_list('-12458', '8956', 'okay', null,'458963', '789'); + l_list_to_be_equal ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('-12458', '8956', '789'); + l_list ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('-12458', '8956', 'okay', null,'458963', '789'); begin --Act - l_list := ut3.ut_utils.filter_list(l_list, '^-?[[:digit:]]{1,5}$'); + l_list := ut3_develop.ut_utils.filter_list(l_list, '^-?[[:digit:]]{1,5}$'); --Assert ut.expect(anydata.convertcollection(l_list)).to_equal(anydata.convertcollection(l_list_to_be_equal)); end; procedure filter_list_null_collection is - l_list_to_be_null ut3.ut_varchar2_list; + l_list_to_be_null ut3_develop.ut_varchar2_list; begin --Act - l_list_to_be_null := ut3.ut_utils.filter_list(l_list_to_be_null, '^-?[[:digit:]]{1,5}$'); + l_list_to_be_null := ut3_develop.ut_utils.filter_list(l_list_to_be_null, '^-?[[:digit:]]{1,5}$'); --Assert ut.expect(anydata.convertcollection(l_list_to_be_null)).to_be_null; end; procedure filter_list_empty_collection is - l_list_to_be_empty ut3.ut_varchar2_list := ut3.ut_varchar2_list(); + l_list_to_be_empty ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); begin --Act - l_list_to_be_empty := ut3.ut_utils.filter_list(l_list_to_be_empty, '^-?[[:digit:]]{1,5}$'); + l_list_to_be_empty := ut3_develop.ut_utils.filter_list(l_list_to_be_empty, '^-?[[:digit:]]{1,5}$'); --Assert ut.expect(anydata.convertcollection(l_list_to_be_empty)).to_be_empty; end; @@ -375,8 +375,8 @@ end;'; procedure replace_multiline_comments is l_source clob; - l_actual clob; - l_expected clob; + l_actual dbms_preprocessor.source_lines_t; + l_expected dbms_preprocessor.source_lines_t; begin --Arrange l_source := q'[ @@ -390,11 +390,11 @@ create or replace package dummy as gv_text2 varchar2(200) := '/* multi-line comment in a multi-line string*/'; - -- ignored start of multi-line comment with multi-byte text � /* - -- ignored end of multi-line comment with multi-byte text � */ + -- ignored start of multi-line comment with multi-byte text ☺ /* + -- ignored end of multi-line comment with multi-byte text ☺ */ /* multi-line comment with - multi-byte characters ��� + multi-byte characters ☺☺☺ in it */ gv_text3 varchar2(200) := 'some text'; /* multiline comment*/ --followed by single-line comment /* multi-line comment in one line*/ @@ -403,7 +403,14 @@ create or replace package dummy as string*/}'; end; ]'; - l_expected := q'[ + + --Act + l_actual := ut3_develop.ut_utils.replace_multiline_comments( + ut3_tester_helper.main_helper.make_source( ut3_develop.ut_utils.clob_to_table(l_source) ) + ); + + --Assert + l_expected := ut3_tester_helper.main_helper.make_source( ut3_develop.ut_utils.clob_to_table( q'[ create or replace package dummy as -- single line comment with disabled /* multi-line comment */ @@ -414,8 +421,8 @@ create or replace package dummy as gv_text2 varchar2(200) := '/* multi-line comment in a multi-line string*/'; - -- ignored start of multi-line comment with multi-byte text � /* - -- ignored end of multi-line comment with multi-byte text � */ + -- ignored start of multi-line comment with multi-byte text ☺ /* + -- ignored end of multi-line comment with multi-byte text ☺ */ ]'||q'[ @@ -426,11 +433,84 @@ create or replace package dummy as in escaped q'multi-line string*/}'; end; -]'; +]' ) ); --Act - l_actual := ut3.ut_utils.replace_multiline_comments(l_source); - --Assert - ut.expect(l_actual).to_equal(l_expected); + ut.expect(ut3_tester_helper.main_helper.lines_to_str(l_actual)).to_equal(ut3_tester_helper.main_helper.lines_to_str(l_expected)); + end; + + procedure int_conv_ds_sec is + l_expected varchar2(100) := '1 second'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' second); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure int_conv_ds_minute is + l_expected varchar2(100) := '1 minute'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' minute); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure int_conv_ds_hour is + l_expected varchar2(100) := '1 hour'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' hour); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure int_conv_ds_day is + l_expected varchar2(100) := '1 day'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' day); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure int_conv_ds_date is + l_expected varchar2(100) := '2 days 3 hours 4 minutes 11.333 seconds'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(INTERVAL '2 3:04:11.333' DAY TO SECOND); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure int_conv_ym_year is + l_expected varchar2(100) := '1 year'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' year); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure int_conv_ym_month is + l_expected varchar2(100) := '1 month'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' month); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure int_conv_ym_date is + l_expected varchar2(100) := '1 year 2 months'; + l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(INTERVAL '1-2' YEAR TO MONTH); + begin + ut.expect(l_expected).to_equal(l_actual); + end; + + procedure convert_collection_multibyte is + l_input ut3_develop.ut_varchar2_list; + l_max_len integer := ut3_develop.ut_utils.gc_max_storage_varchar2_len; + begin + --Arrange + l_input := ut3_develop.ut_varchar2_list( rpad( '❤', l_max_len, 'a' ) ); + ut.expect( lengthb( l_input( 1 ) ) ).to_be_greater_than(l_max_len); + + --Act + ut.expect( lengthb( ut3_develop.ut_utils.convert_collection(l_input)(1) ) ).to_be_less_or_equal(l_max_len); + end; + + procedure lengthb_gives_length_in_bytes is + l_clob clob; + begin + l_clob := '❤'; + ut.expect(ut3_develop.ut_utils.lengthb_clob(l_clob)).to_be_greater_than(1); end; end test_ut_utils; / diff --git a/test/ut3_tester/core/test_ut_utils.pks b/test/ut3_tester/core/test_ut_utils.pks index d8fca3b60..82145f908 100644 --- a/test/ut3_tester/core/test_ut_utils.pks +++ b/test/ut3_tester/core/test_ut_utils.pks @@ -93,7 +93,6 @@ create or replace package test_ut_utils is procedure clean_append_with_multibyte; --%test(clob_to_table - converts multibyte CLOB to ut_varchar2_list) - --%disabled(We cannot run this test successfully on 12.1 until we change NLSCHARACTERSET from US7ASCII to AL32UTF8) procedure test_clob_to_table_multibyte; --%test(to_version - splits version string into individual version components) @@ -128,5 +127,39 @@ create or replace package test_ut_utils is --%test(replace_multiline_comments - replaces multi-line comments with empty lines) procedure replace_multiline_comments; + --%context(interval_converter_to_strin) + + --%test(returns text representation of interval day to second for 1 second interval) + procedure int_conv_ds_sec; + + --%test(returns text representation of interval day to second for 1 minute interval) + procedure int_conv_ds_minute; + + --%test(returns text representation of interval day to second for 1 hour interval) + procedure int_conv_ds_hour; + + --%test(returns text representation of interval day to second for 1 day interval) + procedure int_conv_ds_day; + + --%test(returns text representation of interval day to second for combination interval) + procedure int_conv_ds_date; + + --%test(returns text representation of interval year to month for 1 year interval) + procedure int_conv_ym_year; + + --%test(returns text representation of interval year to month for 1 month interval) + procedure int_conv_ym_month; + + --%test(returns text representation of interval year to month for custom interval) + procedure int_conv_ym_date; + + --%endcontext + + --%test(convert_collection does not fail on multibyte strings - Issue #1245 ) + procedure convert_collection_multibyte; + + --%test(lengthb returns length of a CLOB in bytes ) + procedure lengthb_gives_length_in_bytes; + end test_ut_utils; / diff --git a/test/ut3_tester_helper/annotation_cache_helper.pkb b/test/ut3_tester_helper/annotation_cache_helper.pkb new file mode 100644 index 000000000..63e20159d --- /dev/null +++ b/test/ut3_tester_helper/annotation_cache_helper.pkb @@ -0,0 +1,250 @@ +create or replace package body annotation_cache_helper as + + procedure setup_two_suites is + pragma autonomous_transaction; + begin + execute immediate + 'create or replace package ut3_cache_test_owner.granted_test_suite authid definer is + --%suite + + --%test + procedure test1; + --%test + procedure test2; + end;'; + + execute immediate + 'create or replace package body ut3_cache_test_owner.granted_test_suite is + procedure test1 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + procedure test2 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate + 'create or replace package ut3_cache_test_owner.not_granted_test_suite authid definer is + --%suite + + --%test + procedure test1; + --%test + procedure test2; + end;'; + execute immediate + 'create or replace package body ut3_cache_test_owner.not_granted_test_suite is + procedure test1 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + procedure test2 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + + execute immediate + 'grant execute on ut3_cache_test_owner.granted_test_suite to + ut3_execute_any_proc_user, ut3_select_any_table_user, ut3_select_catalog_user, ut3_no_extra_priv_user'; + end; + + procedure revoke_granted_suite is + pragma autonomous_transaction; + begin + execute immediate + 'revoke execute on ut3_cache_test_owner.granted_test_suite from + ut3_execute_any_proc_user, ut3_select_any_table_user, ut3_select_catalog_user, ut3_no_extra_priv_user'; + exception + when others then + null; + end; + + + procedure add_new_suite is + pragma autonomous_transaction; + begin + execute immediate + 'create or replace package ut3_cache_test_owner.new_suite authid definer is + --%suite + + --%test + procedure test1; + --%test + procedure test2; + end;'; + + execute immediate + 'create or replace package body ut3_cache_test_owner.new_suite is + procedure test1 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + procedure test2 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate + 'grant execute on ut3_cache_test_owner.new_suite to + ut3_execute_any_proc_user, ut3_select_any_table_user, ut3_select_catalog_user, ut3_no_extra_priv_user'; + end; + + procedure cleanup_two_suites is + pragma autonomous_transaction; + begin + begin + execute immediate 'drop package ut3_cache_test_owner.not_granted_test_suite'; + exception + when others then + null; + end; + begin + execute immediate 'drop package ut3_cache_test_owner.granted_test_suite'; + exception + when others then + null; + end; + end; + + /* + Suites spread across packages, only child_suite is granted: + parent_suite package parent_suite, not granted, tagged parent_tag + parent_suite.child_suite package child_suite, granted + hidden_path.sub.lone_suite package lone_suite, not granted, below logical suites hidden_path and hidden_path.sub + */ + procedure setup_suite_hierarchy is + pragma autonomous_transaction; + begin + execute immediate + 'create or replace package ut3_cache_test_owner.parent_suite authid definer is + --%suite + --%tags(parent_tag) + + --%test + procedure parent_test; + end;'; + execute immediate + 'create or replace package body ut3_cache_test_owner.parent_suite is + procedure parent_test is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate + 'create or replace package ut3_cache_test_owner.child_suite authid definer is + --%suite + --%suitepath(parent_suite) + + --%test + procedure child_test; + end;'; + execute immediate + 'create or replace package body ut3_cache_test_owner.child_suite is + procedure child_test is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate + 'create or replace package ut3_cache_test_owner.lone_suite authid definer is + --%suite + --%suitepath(hidden_path.sub) + + --%test + procedure lone_test; + end;'; + execute immediate + 'create or replace package body ut3_cache_test_owner.lone_suite is + procedure lone_test is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate 'grant execute on ut3_cache_test_owner.child_suite to ut3_no_extra_priv_user'; + end; + + procedure cleanup_suite_hierarchy is + pragma autonomous_transaction; + begin + for i in ( select column_value as package_name from table(ut3_develop.ut_varchar2_list('parent_suite','child_suite','lone_suite')) ) loop + begin + execute immediate 'drop package ut3_cache_test_owner.'||i.package_name; + exception + when others then + null; + end; + end loop; + end; + + procedure cleanup_new_suite is + pragma autonomous_transaction; + begin + execute immediate 'drop package ut3_cache_test_owner.new_suite'; + exception + when others then + null; + end; + + procedure purge_annotation_cache is + begin + ut3_develop.ut_runner.purge_cache( 'UT3_CACHE_TEST_OWNER' ); + end; + + + procedure disable_ddl_trigger is + pragma autonomous_transaction; + begin + execute immediate 'alter trigger ut3_develop.ut_trigger_annotation_parsing disable'; + execute immediate 'begin ut3_develop.ut_trigger_check.is_alive( ); end;'; + end; + + procedure enable_ddl_trigger is + pragma autonomous_transaction; + begin + execute immediate 'alter trigger ut3_develop.ut_trigger_annotation_parsing enable'; + end; + + procedure create_run_function_for_user(a_user varchar2) is + pragma autonomous_transaction; + begin + execute immediate + 'create or replace function ' || a_user || '.call_ut_run(a_path varchar2 := ''ut3_cache_test_owner'', a_tags varchar2 := null) return clob is + l_data ut3_develop.ut_varchar2_list; + l_results clob; + begin + select * bulk collect into l_data from table (ut3_develop.ut.run( a_path, a_tags => a_tags )); + return ut3_tester_helper.main_helper.table_to_clob( l_data ); + end; + '; + execute immediate 'grant execute on ' || a_user || '.call_ut_run to public '; + execute immediate + 'create or replace function ' || a_user || '.call_suites_info return clob is + l_data ut3_develop.ut_varchar2_list; + begin + select i.item_type || '' '' || i.path + bulk collect into l_data + from table (ut3_develop.ut_runner.get_suites_info( ''UT3_CACHE_TEST_OWNER'' )) i + order by i.path; + return ut3_tester_helper.main_helper.table_to_clob( l_data ); + end; + '; + execute immediate 'grant execute on ' || a_user || '.call_suites_info to public '; + end; + + procedure drop_run_function_for_user(a_user varchar2) is + pragma autonomous_transaction; + begin + execute immediate 'drop function ' || a_user || '.call_ut_run'; + execute immediate 'drop function ' || a_user || '.call_suites_info'; + end; + + procedure create_run_function_for_users is + begin + create_run_function_for_user( 'ut3_no_extra_priv_user' ); + create_run_function_for_user( 'ut3_select_catalog_user' ); + create_run_function_for_user( 'ut3_select_any_table_user' ); + create_run_function_for_user( 'ut3_execute_any_proc_user' ); + create_run_function_for_user( 'ut3_cache_test_owner' ); + create_run_function_for_user( 'ut3_develop' ); + end; + + procedure drop_run_function_for_users is + begin + drop_run_function_for_user( 'ut3_no_extra_priv_user' ); + drop_run_function_for_user( 'ut3_select_catalog_user' ); + drop_run_function_for_user( 'ut3_select_any_table_user' ); + drop_run_function_for_user( 'ut3_execute_any_proc_user' ); + drop_run_function_for_user( 'ut3_cache_test_owner' ); + drop_run_function_for_user( 'ut3_develop' ); + end; + + function run_tests_as(a_user varchar2, a_path varchar2 := 'ut3_cache_test_owner', a_tags varchar2 := null) return clob is + l_results clob; + begin + execute immediate 'begin :x := '||a_user||'.call_ut_run(:a_path, :a_tags); end;' using out l_results, a_path, a_tags; + return l_results; + end; + + function get_suites_info_as(a_user varchar2) return clob is + l_results clob; + begin + execute immediate 'begin :x := '||a_user||'.call_suites_info; end;' using out l_results; + return l_results; + end; +end; +/ \ No newline at end of file diff --git a/test/ut3_tester_helper/annotation_cache_helper.pks b/test/ut3_tester_helper/annotation_cache_helper.pks new file mode 100644 index 000000000..88b82d872 --- /dev/null +++ b/test/ut3_tester_helper/annotation_cache_helper.pks @@ -0,0 +1,25 @@ +create or replace package annotation_cache_helper as + + procedure setup_two_suites; + procedure add_new_suite; + procedure revoke_granted_suite; + + procedure cleanup_two_suites; + procedure cleanup_new_suite; + + procedure purge_annotation_cache; + + procedure disable_ddl_trigger; + procedure enable_ddl_trigger; + + procedure setup_suite_hierarchy; + procedure cleanup_suite_hierarchy; + + procedure create_run_function_for_users; + procedure drop_run_function_for_users; + + function run_tests_as(a_user varchar2, a_path varchar2 := 'ut3_cache_test_owner', a_tags varchar2 := null) return clob; + function get_suites_info_as(a_user varchar2) return clob; + +end; +/ \ No newline at end of file diff --git a/test/ut3_tester_helper/coverage_helper.pkb b/test/ut3_tester_helper/coverage_helper.pkb index 74a33da54..8c978d046 100644 --- a/test/ut3_tester_helper/coverage_helper.pkb +++ b/test/ut3_tester_helper/coverage_helper.pkb @@ -1,174 +1,96 @@ create or replace package body coverage_helper is - g_run_ids ut3.ut_coverage.tt_coverage_id_arr; - g_profiler_run_id integer; - g_block_run_id integer; + g_job_no integer := 0; - function get_mock_proftab_run_id return integer is - v_result integer; + function covered_package_name return varchar2 is begin - select nvl(min(runid),0) - 1 into v_result - from ut3.plsql_profiler_runs; - return v_result; - end; - - function get_mock_block_run_id return integer is - v_result integer; - begin - select nvl(min(run_id),0) - 1 into v_result - from ut3.dbmspcc_runs; - return v_result; + return 'dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long'; end; - procedure setup_mock_coverage_id is + function substitute_covered_package( a_text varchar2, a_substitution varchar2 ) return varchar2 is begin - g_profiler_run_id := get_mock_proftab_run_id(); - ut3.ut_coverage.mock_coverage_id(g_profiler_run_id, ut3.ut_coverage.gc_proftab_coverage); + return replace( replace( a_text, a_substitution, covered_package_name() ), upper(a_substitution), upper(covered_package_name()) ); end; - procedure setup_mock_coverage_ids(a_profiler_run_id integer, a_block_run_id integer) is - l_coverage_ids ut3.ut_coverage.tt_coverage_id_arr; - begin - l_coverage_ids(ut3.ut_coverage.gc_proftab_coverage) := a_profiler_run_id; - l_coverage_ids(ut3.ut_coverage.gc_block_coverage) := a_block_run_id; - ut3.ut_coverage.mock_coverage_id(l_coverage_ids); - end; - - procedure setup_dummy_coverage is - pragma autonomous_transaction; - begin - create_dummy_12_2_cov_pck(); - create_dummy_12_2_cov_test(); - grant_exec_on_12_2_cov(); - - g_profiler_run_id := get_mock_proftab_run_id(); - g_block_run_id := get_mock_block_run_id(); - setup_mock_coverage_ids(g_profiler_run_id, g_block_run_id); - - mock_block_coverage_data(g_block_run_id, user); - mock_profiler_coverage_data(g_profiler_run_id, user); - commit; - end; - - procedure mock_coverage_data(a_user in varchar2) is - c_unit_id constant integer := 1; - begin - insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment) - values(g_profiler_run_id, a_user, sysdate, 'unit testing utPLSQL'); - - insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name) - values(g_profiler_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE'); - - insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time) - select g_profiler_run_id, c_unit_id, 4, 1, 1 from dual union all - select g_profiler_run_id, c_unit_id, 5, 0, 0 from dual union all - select g_profiler_run_id, c_unit_id, 7, 1, 1 from dual; - end; - - procedure cleanup_dummy_coverage(a_run_id in integer) is - pragma autonomous_transaction; - begin - delete from ut3.plsql_profiler_data where runid = a_run_id; - delete from ut3.plsql_profiler_units where runid = a_run_id; - delete from ut3.plsql_profiler_runs where runid = a_run_id; - commit; - end; - - procedure cleanup_dummy_coverage(a_block_id in integer, a_prof_id in integer) is - pragma autonomous_transaction; + procedure set_develop_mode is begin - begin execute immediate q'[drop package ut3.test_block_dummy_coverage]'; exception when others then null; end; - begin execute immediate q'[drop package ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long]'; exception when others then null; end; - delete from dbmspcc_blocks where run_id = a_block_id; - delete from dbmspcc_units where run_id = a_block_id; - delete from dbmspcc_runs where run_id = a_block_id; - cleanup_dummy_coverage(a_prof_id); - commit; + ut3_develop.ut_coverage.set_develop_mode(true); end; - procedure cleanup_dummy_coverage is - begin - cleanup_dummy_coverage( - g_block_run_id, - g_profiler_run_id - ); - end; - procedure create_dummy_coverage_package is + procedure create_dummy_coverage is pragma autonomous_transaction; begin - execute immediate q'[create or replace package UT3.DUMMY_COVERAGE is - procedure do_stuff; - - procedure grant_myself; + execute immediate q'[create or replace package ut3_develop.]'||covered_package_name||q'[ is + procedure do_stuff(i_input in number); end;]'; - execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE is - procedure do_stuff is + + execute immediate q'[create or replace package body ut3_develop.]'||covered_package_name||q'[ is + procedure do_stuff(i_input in number) is begin - if 1 = 2 then - dbms_output.put_line('should not get here'); + if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); else - dbms_output.put_line('should get here'); + dbms_output.put_line('should not get here'); end if; end; - - procedure grant_myself is + end;]'; + + execute immediate q'[create or replace package ut3_develop.some_other_package is + procedure do_stuff(i_input in number); + end;]'; + + execute immediate q'[create or replace package body ut3_develop.some_other_package is + procedure do_stuff(i_input in number) is begin - execute immediate 'grant debug,execute on UT3.DUMMY_COVERAGE to ut3$user#'; + if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); + else + dbms_output.put_line('should not get here'); + end if; end; end;]'; - - end; - procedure create_dummy_coverage_test is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package UT3.TEST_DUMMY_COVERAGE is + execute immediate q'[create or replace package ut3_develop.test_dummy_coverage is --%suite(dummy coverage test) --%suitepath(coverage_testing) --%test procedure test_do_stuff; - - procedure grant_myself; + + --%test + procedure zero_coverage; end;]'; - execute immediate q'[create or replace package body UT3.TEST_DUMMY_COVERAGE is + + execute immediate q'[create or replace package body ut3_develop.test_dummy_coverage is procedure test_do_stuff is begin - dummy_coverage.do_stuff; + ]'||covered_package_name||q'[.do_stuff(1); + ut.expect(1).to_equal(1); end; - - procedure grant_myself is + procedure zero_coverage is begin - execute immediate 'grant debug,execute on UT3.TEST_DUMMY_COVERAGE to ut3$user#'; + null; end; end;]'; - - end; - - procedure grant_exec_on_cov is - pragma autonomous_transaction; - begin - execute immediate 'begin UT3.DUMMY_COVERAGE.grant_myself(); end;'; - execute immediate 'begin UT3.TEST_DUMMY_COVERAGE.grant_myself(); end;'; + end; - - procedure drop_dummy_coverage_pkg is + + procedure drop_dummy_coverage is pragma autonomous_transaction; begin - begin execute immediate q'[drop package ut3.test_dummy_coverage]'; exception when others then null; end; - begin execute immediate q'[drop package ut3.dummy_coverage]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.test_dummy_coverage]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.some_other_package]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.]'||covered_package_name; exception when others then null; end; end; - procedure create_dummy_coverage_test_1 is + procedure create_dummy_coverage_1 is pragma autonomous_transaction; begin - execute immediate q'[create or replace package UT3.DUMMY_COVERAGE_1 is + execute immediate q'[create or replace package ut3_develop.dummy_coverage_1 is procedure do_stuff; - procedure grant_myself; end;]'; - execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE_1 is + + execute immediate q'[create or replace package body ut3_develop.dummy_coverage_1 is procedure do_stuff is begin if 1 = 2 then @@ -177,141 +99,465 @@ create or replace package body coverage_helper is dbms_output.put_line('should get here'); end if; end; - - procedure grant_myself is - begin - execute immediate 'grant debug,execute on UT3.DUMMY_COVERAGE_1 to ut3$user#'; - end; - end;]'; - execute immediate q'[create or replace package UT3.TEST_DUMMY_COVERAGE_1 is + + execute immediate q'[create or replace package ut3_develop.test_dummy_coverage_1 is --%suite(dummy coverage test 1) --%suitepath(coverage_testing) --%test procedure test_do_stuff; - - procedure grant_myself; end;]'; - execute immediate q'[create or replace package body UT3.TEST_DUMMY_COVERAGE_1 is + + execute immediate q'[create or replace package body ut3_develop.test_dummy_coverage_1 is procedure test_do_stuff is begin dummy_coverage_1.do_stuff; end; - procedure grant_myself is - begin - execute immediate 'grant debug,execute on UT3.TEST_DUMMY_COVERAGE_1 to ut3$user#'; - end; - end;]'; - execute immediate 'begin UT3.DUMMY_COVERAGE_1.grant_myself(); end;'; - execute immediate 'begin UT3.TEST_DUMMY_COVERAGE_1.grant_myself(); end;'; end; - procedure drop_dummy_coverage_test_1 is + procedure drop_dummy_coverage_1 is pragma autonomous_transaction; begin - execute immediate q'[drop package UT3.DUMMY_COVERAGE_1]'; - execute immediate q'[drop package UT3.TEST_DUMMY_COVERAGE_1]'; + begin execute immediate q'[drop package ut3_develop.dummy_coverage_1]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.test_dummy_coverage_1]'; exception when others then null; end; end; - --12.2 Setup - procedure create_dummy_12_2_cov_pck is + procedure create_cov_with_dbms_stats is pragma autonomous_transaction; begin - execute immediate q'[create or replace package UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG is + execute immediate q'[create table ut3_develop.table_to_test_stats as select * from user_objects]'; + + execute immediate q'[create or replace package ut3_develop.stats is + procedure gather; + end;]'; + + execute immediate q'[create or replace package body ut3_develop.stats is + procedure gather is + begin + dbms_Stats.gather_table_stats('UT3_DEVELOP','TABLE_TO_TEST_STATS'); + end; + end;]'; + + execute immediate q'[create or replace package ut3_develop.test_stats is + --%suite(stats gathering coverage test) + --%suitepath(coverage_testing) + + --%test + procedure test_stats_gather; + + end;]'; + + execute immediate q'[create or replace package body ut3_develop.test_stats is + procedure test_stats_gather is + begin + stats.gather; + ut.expect(1).to_equal(1); + end; + end;]'; + + end; + + procedure create_regex_dummy_for_schema(p_schema in varchar2) is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ]'||p_schema||q'[.regex_dummy_cov is procedure do_stuff(i_input in number); - - procedure grant_myself; end;]'; - execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG is + + execute immediate q'[create or replace package body ]'||p_schema||q'[.regex_dummy_cov is procedure do_stuff(i_input in number) is begin - if i_input = 2 then - dbms_output.put_line('should not get here'); + if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); else - dbms_output.put_line('should get here'); + dbms_output.put_line('should not get here'); end if; end; - - procedure grant_myself is + end;]'; + + execute immediate q'[create or replace package ]'||p_schema||q'[.test_regex_dummy_cov is + --%suite(dummy coverage test) + --%suitepath(coverage_testing) + + --%test + procedure test_do_stuff; + + --%test + procedure zero_coverage; + end;]'; + + execute immediate q'[create or replace package body ]'||p_schema||q'[.test_regex_dummy_cov is + procedure test_do_stuff is begin - execute immediate 'grant debug,execute on UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG to ut3$user#'; + regex_dummy_cov.do_stuff(1); + ut.expect(1).to_equal(1); + end; + procedure zero_coverage is + begin + null; end; - end;]'; end; - procedure create_dummy_12_2_cov_test is + procedure create_regex_dummy_obj is pragma autonomous_transaction; begin - execute immediate q'[create or replace package UT3.TEST_BLOCK_DUMMY_COVERAGE is + execute immediate q'[create or replace package ut3_develop.regex123_dummy_cov is + procedure do_stuff(i_input in number); + end;]'; + + execute immediate q'[create or replace package body ut3_develop.regex123_dummy_cov is + procedure do_stuff(i_input in number) is + begin + if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); + else + dbms_output.put_line('should not get here'); + end if; + end; + end;]'; + + execute immediate q'[create or replace package ut3_develop.test_regex123_dummy_cov is --%suite(dummy coverage test) --%suitepath(coverage_testing) --%test procedure test_do_stuff; - - procedure grant_myself; - + + --%test + procedure zero_coverage; end;]'; - execute immediate q'[create or replace package body UT3.TEST_BLOCK_DUMMY_COVERAGE is + + execute immediate q'[create or replace package body ut3_develop.test_regex123_dummy_cov is procedure test_do_stuff is begin - dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long.do_stuff(1); + regex123_dummy_cov.do_stuff(1); ut.expect(1).to_equal(1); end; - - procedure grant_myself is + procedure zero_coverage is begin - execute immediate 'grant debug,execute on UT3.TEST_BLOCK_DUMMY_COVERAGE to ut3$user#'; + null; end; end;]'; end; - procedure mock_block_coverage_data(a_run_id integer,a_user in varchar2) is - c_unit_id constant integer := 1; + procedure create_regex_dummy_cov is + begin + create_regex_dummy_for_schema('ut3_develop'); + create_regex_dummy_for_schema('ut3_tester_helper'); + create_regex_dummy_obj; + end; + + procedure drop_regex_dummy_cov is + pragma autonomous_transaction; begin - insert into dbmspcc_runs ( run_id, run_owner, run_timestamp, run_comment) - values(a_run_id, a_user, sysdate, 'unit testing utPLSQL'); + begin execute immediate q'[drop package ut3_develop.regex_dummy_cov]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.test_regex_dummy_cov]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_tester_helper.regex_dummy_cov]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_tester_helper.test_regex_dummy_cov]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.regex123_dummy_cov]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.test_regex123_dummy_cov]'; exception when others then null; end; + end; - insert into dbmspcc_units ( run_id, object_id, type, owner, name,last_ddl_time) - values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG',sysdate); - insert into dbmspcc_blocks ( run_id, object_id, line,block,col,covered,not_feasible) - select a_run_id, c_unit_id,4,1,1,1,0 from dual union all - select a_run_id, c_unit_id,4,2,2,0,0 from dual union all - select a_run_id, c_unit_id,5,3,0,1,0 from dual union all - select a_run_id, c_unit_id,7,4,1,1,0 from dual; + procedure drop_cov_with_dbms_stats is + pragma autonomous_transaction; + begin + begin execute immediate q'[drop package ut3_develop.test_stats]'; exception when others then null; end; + begin execute immediate q'[drop package ut3_develop.stats]'; exception when others then null; end; + begin execute immediate q'[drop table ut3_develop.table_to_test_stats]'; exception when others then null; end; end; - procedure mock_profiler_coverage_data(a_run_id integer,a_user in varchar2) is - c_unit_id constant integer := 1; + + procedure run_standalone_coverage(a_coverage_run_id raw, a_input integer) is begin - insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment) - values(a_run_id, a_user, sysdate, 'unit testing utPLSQL'); + ut3_develop.ut_runner.coverage_start(a_coverage_run_id); + execute immediate 'begin ut3_develop.'||covered_package_name||'.do_stuff(:a_input); end;' using in a_input; + ut3_develop.ut_runner.coverage_stop(); + end; - insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name) - values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG'); + function get_job_status(a_job_name varchar2, a_job_started_after timestamp with time zone) return user_scheduler_job_run_details%rowtype is + l_result user_scheduler_job_run_details%rowtype; + begin + begin + select * into l_result + from user_scheduler_job_run_details + where job_name = upper(a_job_name) + and req_start_date >= a_job_started_after; + exception + when no_data_found then + null; + end; + return l_result; + end; - insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time) - select a_run_id, c_unit_id, 4, 1, 1 from dual union all - select a_run_id, c_unit_id, 5, 0, 0 from dual union all - select a_run_id, c_unit_id, 6, 1, 0 from dual union all - select a_run_id, c_unit_id, 7, 1, 1 from dual; + procedure run_job_and_wait_for_finish(a_job_action varchar2) is + l_job_run_info user_scheduler_job_run_details%rowtype; + l_job_name varchar2(30); + l_timestamp timestamp with time zone := current_timestamp; + i integer := 0; + pragma autonomous_transaction; + begin + g_job_no := g_job_no + 1; + l_job_name := 'utPLSQL_selftest_job_'||g_job_no; + dbms_session.sleep(0.15); + dbms_scheduler.create_job( + job_name => l_job_name, + job_type => 'PLSQL_BLOCK', + job_action => a_job_action, + start_date => l_timestamp, + enabled => TRUE, + auto_drop => TRUE, + comments => 'one-time-job' + ); + while (l_job_run_info.status is null or l_job_run_info.status not in ('SUCCEEDED','FAILED')) and i < 6000 loop + l_job_run_info := get_job_status( l_job_name, l_timestamp ); + dbms_session.sleep(0.1); + i := i + 1; + end loop; + commit; + if nvl(l_job_run_info.status,'null') <> 'SUCCEEDED' then + raise_application_error(-20000, 'Scheduler job '''||l_job_name||''', status='''||l_job_run_info.status||'''. Additional info: '||l_job_run_info.additional_info); + end if; end; - procedure grant_exec_on_12_2_cov is - pragma autonomous_transaction; + procedure run_coverage_job(a_coverage_run_id raw, a_input integer) is begin - execute immediate 'begin UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG.grant_myself(); end;'; - execute immediate 'begin UT3.TEST_BLOCK_DUMMY_COVERAGE.grant_myself(); end;'; + run_job_and_wait_for_finish( + 'begin coverage_helper.run_standalone_coverage('''||a_coverage_run_id||''', '||a_input||'); end;' + ); end; - procedure set_develop_mode is + procedure create_test_results_table is + pragma autonomous_transaction; + e_exists exception; + pragma exception_init ( e_exists, -955 ); + begin + execute immediate 'create table test_results (id integer, text varchar2(4000))'; + exception + when e_exists then + null; + end; + + procedure drop_test_results_table is + pragma autonomous_transaction; + e_not_exists exception; + pragma exception_init ( e_not_exists, -942 ); + begin + execute immediate 'drop table test_results'; + exception + when e_not_exists then + null; + end; + + function run_code_as_job( a_plsql_block varchar2 ) return clob is + l_result_clob clob; + pragma autonomous_transaction; + begin + run_job_and_wait_for_finish( a_plsql_block ); + dbms_session.sleep(0.1); + execute immediate q'[ + declare + l_results ut3_develop.ut_varchar2_list; + begin + select text + bulk collect into l_results + from test_results + order by id; + delete from test_results; + commit; + :clob_results := ut3_tester_helper.main_helper.table_to_clob(l_results); + end; + ]' + using out l_result_clob; + + return l_result_clob; + end; + + procedure copy_coverage_data_to_ut3(a_coverage_run_id raw) is + pragma autonomous_transaction; + l_current_coverage_run_id raw(32) := hextoraw(sys_context('UT3_INFO','COVERAGE_RUN_ID')); + begin + insert into ut3.ut_coverage_runs(coverage_run_id, line_coverage_id, block_coverage_id) + select l_current_coverage_run_id, -line_coverage_id, -block_coverage_id + from ut3_develop.ut_coverage_runs + where coverage_run_id = a_coverage_run_id; + + insert into ut3.plsql_profiler_runs(runid, related_run, run_owner, run_date, run_comment, run_total_time, run_system_info, run_comment1, spare1) + select -runid, related_run, run_owner, run_date, run_comment, run_total_time, run_system_info, run_comment1, spare1 + from ut3_develop.plsql_profiler_runs c + join ut3_develop.ut_coverage_runs r + on r.line_coverage_id = c.runid + where r.coverage_run_id = a_coverage_run_id; + + insert into ut3.plsql_profiler_units(runid, unit_number, unit_type, unit_owner, unit_name, unit_timestamp, total_time, spare1, spare2) + select -runid, unit_number, unit_type, unit_owner, unit_name, unit_timestamp, total_time, spare1, spare2 + from ut3_develop.plsql_profiler_units c + join ut3_develop.ut_coverage_runs r + on r.line_coverage_id = c.runid + where r.coverage_run_id = a_coverage_run_id; + + insert into ut3.plsql_profiler_data(runid, unit_number, line#, total_occur, total_time, min_time, max_time, spare1, spare2, spare3, spare4) + select -runid, unit_number, line#, total_occur, total_time, min_time, max_time, spare1, spare2, spare3, spare4 + from ut3_develop.plsql_profiler_data c + join ut3_develop.ut_coverage_runs r + on r.line_coverage_id = c.runid + where r.coverage_run_id = a_coverage_run_id; + + insert into ut3.dbmspcc_runs(run_id, run_comment, run_owner, run_timestamp) + select -run_id, run_comment, run_owner, run_timestamp + from ut3_develop.dbmspcc_runs c + join ut3_develop.ut_coverage_runs r + on r.block_coverage_id = c.run_id + where r.coverage_run_id = a_coverage_run_id; + + insert into ut3.dbmspcc_units(run_id, object_id, owner, name, type, last_ddl_time) + select -run_id, object_id, owner, name, type, last_ddl_time + from ut3_develop.dbmspcc_units c + join ut3_develop.ut_coverage_runs r + on r.block_coverage_id = c.run_id + where r.coverage_run_id = a_coverage_run_id; + + insert into ut3.dbmspcc_blocks(run_id, object_id, block, line, col, covered, not_feasible) + select -run_id, object_id, block, line, col, covered, not_feasible + from ut3_develop.dbmspcc_blocks c + join ut3_develop.ut_coverage_runs r + on r.block_coverage_id = c.run_id + where r.coverage_run_id = a_coverage_run_id; + + commit; + end; + + function gather_coverage_on_coverage( a_cov_options varchar2) return clob is + pragma autonomous_transaction; + l_plsql_block varchar2(32767); + l_result_clob clob; + l_coverage_id raw(32) := sys_guid(); + begin + l_plsql_block := q'[ + declare + l_coverage_options ut3_develop.ut_coverage_options; + l_coverage_run_id raw(32) := ']'||rawtohex(l_coverage_id)||q'['; + l_result ut3_develop.ut_coverage.t_coverage; + begin + ut3_develop.ut_runner.coverage_start(l_coverage_run_id); + ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => true); + l_coverage_options := {a_cov_options}; + l_result := ut3_develop.ut_coverage.get_coverage_data(l_coverage_options); + ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => false); + ut3_develop.ut_runner.coverage_stop(); + insert into test_results select rownum, owner||'.'||name from ut3_develop.ut_coverage_sources_tmp; + commit; + end;]'; + l_plsql_block := replace(l_plsql_block,'{a_cov_options}',a_cov_options); + run_job_and_wait_for_finish( l_plsql_block ); + execute immediate q'[ + declare + l_results ut3_develop.ut_varchar2_list; + begin + select text + bulk collect into l_results + from test_results + order by id; + delete from test_results; + commit; + :clob_results := ut3_tester_helper.main_helper.table_to_clob(l_results); + end; + ]' + using out l_result_clob; + copy_coverage_data_to_ut3(l_coverage_id); + return l_result_clob; + end; + + function run_tests_as_job( a_run_command varchar2 ) return clob is + l_plsql_block varchar2(32767); + l_result_clob clob; + l_coverage_id raw(32) := sys_guid(); + begin + l_plsql_block := q'[ + declare + x dbms_output.chararr; + i integer := 100000; + begin +/* + execute immediate 'alter session set statistics_level=all'; + dbms_hprof.start_profiling( + location => 'PLSHPROF_DIR' + , filename => 'profiler_utPLSQL_run_]'||rawtohex(l_coverage_id)||q'[.txt' + ); +*/ + ut3_develop.ut_runner.coverage_start(']'||rawtohex(l_coverage_id)||q'['); + ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => true); + --gather coverage on the command executed + begin {a_run_command}; end; + dbms_output.get_lines(x,i); + ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => false); + ut3_develop.ut_runner.coverage_stop(); + --get the actual results of the command gathering the coverage + insert into test_results select rownum as id, x.* from table( {a_run_command} ) x; + commit; +/* + dbms_hprof.stop_profiling; +*/ + end;]'; + l_plsql_block := replace(l_plsql_block,'{a_run_command}',a_run_command); + l_result_clob := run_code_as_job( l_plsql_block ); + copy_coverage_data_to_ut3(l_coverage_id); + return l_result_clob; + end; + + procedure create_dup_object_name is + pragma autonomous_transaction; + begin + execute immediate 'create table ut3_develop.test_table(id integer)'; + execute immediate q'[ + create or replace trigger ut3_develop.duplicate_name + before insert on ut3_develop.test_table + begin + + dbms_output.put_line('A'); + end; + ]'; + execute immediate q'[ + create or replace package ut3_develop.duplicate_name is + procedure some_procedure; + end; + ]'; + execute immediate q'[ + create or replace package body ut3_develop.duplicate_name is + procedure some_procedure is + begin + insert into test_table(id) values(1); + end; + end; + ]'; + execute immediate q'[ + create or replace package ut3_develop.test_duplicate_name is + --%suite + + --%test + procedure run_duplicate_name; + end; + ]'; + execute immediate q'[ + create or replace package body ut3_develop.test_duplicate_name is + procedure run_duplicate_name is + l_actual sys_refcursor; + begin + ut3_develop.duplicate_name.some_procedure; + ut.expect(l_actual).to_have_count(1); + end; + end; + ]'; + end; + + procedure drop_dup_object_name is + pragma autonomous_transaction; begin - ut3.ut_coverage.set_develop_mode(true); + execute immediate 'drop table ut3_develop.test_table'; + execute immediate 'drop package ut3_develop.duplicate_name'; + execute immediate 'drop package ut3_develop.test_duplicate_name'; end; end; diff --git a/test/ut3_tester_helper/coverage_helper.pks b/test/ut3_tester_helper/coverage_helper.pks index 9e152707b..d6a57a143 100644 --- a/test/ut3_tester_helper/coverage_helper.pks +++ b/test/ut3_tester_helper/coverage_helper.pks @@ -1,34 +1,34 @@ create or replace package coverage_helper is - type prof_runs_tab is table of ut3.plsql_profiler_runs%rowtype; - - function get_mock_proftab_run_id return integer; + function covered_package_name return varchar2; - procedure setup_mock_coverage_id; + function substitute_covered_package( a_text varchar2, a_substitution varchar2 := '{p}' ) return varchar2; - procedure mock_coverage_data(a_user in varchar2); + procedure set_develop_mode; - procedure cleanup_dummy_coverage; + procedure create_dummy_coverage; + procedure drop_dummy_coverage; - procedure setup_dummy_coverage; + procedure create_dummy_coverage_1; + procedure drop_dummy_coverage_1; - --Profiler coverage - procedure create_dummy_coverage_package; - procedure create_dummy_coverage_test; - procedure grant_exec_on_cov; - procedure mock_profiler_coverage_data(a_run_id integer,a_user in varchar2); - procedure drop_dummy_coverage_pkg; + procedure create_regex_dummy_cov; + procedure drop_regex_dummy_cov; - procedure create_dummy_coverage_test_1; - procedure drop_dummy_coverage_test_1; + procedure create_cov_with_dbms_stats; + procedure drop_cov_with_dbms_stats; - --Block coverage - procedure create_dummy_12_2_cov_pck; - procedure create_dummy_12_2_cov_test; - procedure mock_block_coverage_data(a_run_id integer,a_user in varchar2); - procedure grant_exec_on_12_2_cov; + procedure run_standalone_coverage(a_coverage_run_id raw, a_input integer); + procedure run_coverage_job(a_coverage_run_id raw, a_input integer); + + function gather_coverage_on_coverage( a_cov_options varchar2) return clob; + function run_tests_as_job( a_run_command varchar2 ) return clob; + function run_code_as_job( a_plsql_block varchar2 ) return clob; + procedure create_test_results_table; + procedure drop_test_results_table; + + procedure drop_dup_object_name; + procedure create_dup_object_name; - procedure set_develop_mode; - end; / diff --git a/test/ut3_tester_helper/expectations_helper.pkb b/test/ut3_tester_helper/expectations_helper.pkb index cc86f18a6..c5c1f379f 100644 --- a/test/ut3_tester_helper/expectations_helper.pkb +++ b/test/ut3_tester_helper/expectations_helper.pkb @@ -12,7 +12,7 @@ create or replace package body expectations_helper is l_expected '||a_data_type||' := '||a_data_value||'; begin --act - execute the expectation - ut3.ut.expect(l_expected).'||a_matcher_name||'(); + ut3_develop.ut.expect(l_expected).'||a_matcher_name||'(); end;'; return l_execute; end; @@ -28,7 +28,7 @@ create or replace package body expectations_helper is declare l_object '||a_object_name||' := '||a_object_value||'; begin - ut3.ut.expect(anydata.convert'||a_object_type||'(l_object)).'||a_matcher_name||'(); + ut3_develop.ut.expect(anydata.convert'||a_object_type||'(l_object)).'||a_matcher_name||'(); end;'; end; @@ -48,7 +48,7 @@ create or replace package body expectations_helper is l_expected '||a_expected_data_type||' := '||a_expected_data||'; begin --act - execute the expectation - ut3.ut.expect( l_actual ).'||a_matcher_name||'(l_expected); + ut3_develop.ut.expect( l_actual ).'||a_matcher_name||'(l_expected); end;'; return l_execute; end; diff --git a/test/ut3_tester_helper/main_helper.pkb b/test/ut3_tester_helper/main_helper.pkb index c684054a1..f60ce796c 100644 --- a/test/ut3_tester_helper/main_helper.pkb +++ b/test/ut3_tester_helper/main_helper.pkb @@ -12,7 +12,7 @@ create or replace package body main_helper is end if; while l_status != 1 loop if l_line is not null then - ut3.ut_utils.append_to_clob(l_result, l_line||chr(10)); + ut3_develop.ut_utils.append_to_clob(l_result, l_line||chr(10)); end if; dbms_output.get_line(line => l_line, status => l_status); end loop; @@ -29,10 +29,10 @@ create or replace package body main_helper is end; function run_test(a_path varchar2) return clob is - l_lines ut3.ut_varchar2_list; + l_lines ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_lines from table(ut3.ut.run(a_path)); - return ut3.ut_utils.table_to_clob(l_lines); + select * bulk collect into l_lines from table(ut3_develop.ut.run(a_path)); + return ut3_develop.ut_utils.table_to_clob(l_lines); end; function get_value(a_variable varchar2) return integer is @@ -42,9 +42,9 @@ create or replace package body main_helper is return l_glob_val; end; - function get_failed_expectations return ut3.ut_varchar2_list is - l_expectations_result ut3.ut_expectation_results := ut3.ut_expectation_processor.get_failed_expectations(); - l_result ut3.ut_varchar2_list := ut3.ut_varchar2_list(); + function get_failed_expectations return ut3_develop.ut_varchar2_list is + l_expectations_result ut3_develop.ut_expectation_results := ut3_develop.ut_expectation_processor.get_failed_expectations(); + l_result ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); begin for i in 1..l_expectations_result.count loop l_result := l_result multiset union l_expectations_result(i).get_result_lines(); @@ -53,19 +53,19 @@ create or replace package body main_helper is end; function get_failed_expectations(a_pos in number) return varchar2 is - l_result varchar2(32767) := ut3.ut_expectation_processor.get_failed_expectations()(a_pos).message; + l_result varchar2(32767) := ut3_develop.ut_expectation_processor.get_failed_expectations()(a_pos).message; begin return l_result; end; function failed_expectations_data return anydata is begin - return anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations()); + return anydata.convertCollection(ut3_develop.ut_expectation_processor.get_failed_expectations()); end; function get_failed_expectations_num return number is l_num_failed number; - l_results ut3.ut_expectation_results := ut3.ut_expectation_processor.get_failed_expectations(); + l_results ut3_develop.ut_expectation_results := ut3_develop.ut_expectation_processor.get_failed_expectations(); begin l_num_failed := l_results.count; return l_num_failed; @@ -73,95 +73,105 @@ create or replace package body main_helper is procedure clear_expectations is begin - ut3.ut_expectation_processor.clear_expectations(); + ut3_develop.ut_expectation_processor.clear_expectations(); end; - function table_to_clob(a_results in ut3.ut_varchar2_list) return clob is + function table_to_clob(a_results in ut3_develop.ut_varchar2_list) return clob is begin - return ut3.ut_utils.table_to_clob(a_results); + return ut3_develop.ut_utils.table_to_clob(a_results); end; - function get_warnings return ut3.ut_varchar2_rows is + function get_warnings return ut3_develop.ut_varchar2_rows is begin - return ut3.ut_expectation_processor.get_warnings(); + return ut3_develop.ut_expectation_processor.get_warnings(); end; procedure reset_nulls_equal is begin - ut3.ut_expectation_processor.nulls_Are_equal(ut3.ut_expectation_processor.gc_default_nulls_are_equal); + ut3_develop.ut_expectation_processor.nulls_Are_equal(ut3_develop.ut_expectation_processor.gc_default_nulls_are_equal); end; procedure nulls_are_equal(a_nulls_equal boolean := true) is begin - ut3.ut_expectation_processor.nulls_Are_equal(a_nulls_equal); + ut3_develop.ut_expectation_processor.nulls_Are_equal(a_nulls_equal); end; procedure cleanup_annotation_cache is pragma autonomous_transaction; begin - delete from ut3.ut_annotation_cache_info + delete from ut3_develop.ut_annotation_cache_info where object_owner = 'UT3_TESTER' and object_type = 'PACKAGE' and object_name in ('DUMMY_PACKAGE','DUMMY_TEST_PACKAGE'); commit; end; - procedure create_parse_proc_as_ut3$user# is + procedure create_parse_proc_as_ut3_user is pragma autonomous_transaction; begin execute immediate q'[ - create or replace procedure ut3$user#.parse_annotations is + create or replace procedure ut3_user.parse_annotations is begin - ut3.ut_runner.rebuild_annotation_cache('UT3_TESTER','PACKAGE'); + ut3_develop.ut_runner.rebuild_annotation_cache('UT3_TESTER','PACKAGE'); end;]'; end; - procedure drop_parse_proc_as_ut3$user# is + procedure drop_parse_proc_as_ut3_user is pragma autonomous_transaction; begin - execute immediate 'drop procedure ut3$user#.parse_annotations'; + execute immediate 'drop procedure ut3_user.parse_annotations'; end; - procedure parse_dummy_test_as_ut3$user# is + procedure parse_dummy_test_as_ut3_user is pragma autonomous_transaction; begin - execute immediate 'begin ut3$user#.parse_annotations; end;'; + execute immediate 'begin ut3_user.parse_annotations; end;'; end; - function get_job_count(a_job_name varchar2) return number is - l_cnt number; + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_list, a_item varchar2) is begin - select count(1) into l_cnt - from dba_scheduler_running_jobs srj - where srj.job_name = a_job_name; - end; - - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_list, a_item varchar2) is - begin - ut3.ut_utils.append_to_list(a_list,a_item); + ut3_develop.ut_utils.append_to_list(a_list,a_item); end; - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item varchar2) is + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item varchar2) is begin - ut3.ut_utils.append_to_list(a_list,a_item); + ut3_develop.ut_utils.append_to_list(a_list,a_item); end; - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item clob) is + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item clob) is begin - ut3.ut_utils.append_to_list(a_list,a_item); + ut3_develop.ut_utils.append_to_list(a_list,a_item); end; - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_items ut3.ut_varchar2_rows) is + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_items ut3_develop.ut_varchar2_rows) is begin - ut3.ut_utils.append_to_list(a_list,a_items); + ut3_develop.ut_utils.append_to_list(a_list,a_items); end; procedure set_ut_run_context is begin - ut3.ut_session_context.set_context('RUN_PATHS',' '); + ut3_develop.ut_session_context.set_context('RUN_PATHS',' '); end; procedure clear_ut_run_context is begin - ut3.ut_session_context.clear_all_context; + ut3_develop.ut_session_context.clear_all_context; + end; + + function lines_to_str(a_lines dbms_preprocessor.source_lines_t) return varchar2 is + l_result varchar2(32767); + begin + for i in 1 .. a_lines.count loop + l_result := l_result || a_lines(i); + end loop; + return l_result; + end; + + function make_source(a_lines ut3_develop.ut_varchar2_list) return dbms_preprocessor.source_lines_t is + l_result dbms_preprocessor.source_lines_t; + begin + for i in 1 .. a_lines.count loop + l_result(i) := a_lines(i); + end loop; + return l_result; end; end; diff --git a/test/ut3_tester_helper/main_helper.pks b/test/ut3_tester_helper/main_helper.pks index 63c99936c..71575e145 100644 --- a/test/ut3_tester_helper/main_helper.pks +++ b/test/ut3_tester_helper/main_helper.pks @@ -1,7 +1,7 @@ create or replace package main_helper is - gc_success number := ut3.ut_utils.gc_success; - gc_failure number := ut3.ut_utils.gc_failure; + gc_success number := ut3_develop.ut_utils.gc_success; + gc_failure number := ut3_develop.ut_utils.gc_failure; procedure execute_autonomous(a_sql varchar2); @@ -11,7 +11,7 @@ create or replace package main_helper is function get_dbms_output_as_clob return clob; - function get_failed_expectations return ut3.ut_varchar2_list; + function get_failed_expectations return ut3_develop.ut_varchar2_list; function get_failed_expectations(a_pos in number) return varchar2; @@ -19,9 +19,9 @@ create or replace package main_helper is procedure clear_expectations; - function table_to_clob(a_results in ut3.ut_varchar2_list) return clob; + function table_to_clob(a_results in ut3_develop.ut_varchar2_list) return clob; - function get_warnings return ut3.ut_varchar2_rows; + function get_warnings return ut3_develop.ut_varchar2_rows; procedure reset_nulls_equal; @@ -29,25 +29,27 @@ create or replace package main_helper is procedure cleanup_annotation_cache; - procedure create_parse_proc_as_ut3$user#; + procedure create_parse_proc_as_ut3_user; - procedure drop_parse_proc_as_ut3$user#; + procedure drop_parse_proc_as_ut3_user; - procedure parse_dummy_test_as_ut3$user#; + procedure parse_dummy_test_as_ut3_user; - function get_job_count(a_job_name varchar2) return number; - - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_list, a_item varchar2); + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_list, a_item varchar2); - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item varchar2); + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item varchar2); - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item clob); + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item clob); - procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_items ut3.ut_varchar2_rows); + procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_items ut3_develop.ut_varchar2_rows); procedure set_ut_run_context; procedure clear_ut_run_context; + function lines_to_str(a_lines dbms_preprocessor.source_lines_t) return varchar2; + + function make_source(a_lines ut3_develop.ut_varchar2_list) return dbms_preprocessor.source_lines_t; + end; / diff --git a/test/ut3_tester_helper/run_helper.pkb b/test/ut3_tester_helper/run_helper.pkb index ef6528e04..6bd88bfa8 100644 --- a/test/ut3_tester_helper/run_helper.pkb +++ b/test/ut3_tester_helper/run_helper.pkb @@ -3,7 +3,7 @@ create or replace package body run_helper is procedure setup_cache_objects is pragma autonomous_transaction; begin - execute immediate q'[create or replace package ut3$user#.dummy_test_package as + execute immediate q'[create or replace package ut3_user.dummy_test_package as --%suite(dummy_test_suite) --%suitepath(some.path) --%rollback(manual) @@ -12,7 +12,7 @@ create or replace package body run_helper is --%beforetest(some_procedure) procedure some_dummy_test_procedure; end;]'; - execute immediate q'[create or replace procedure ut3$user#.dummy_test_procedure as + execute immediate q'[create or replace procedure ut3_user.dummy_test_procedure as --%some_annotation(some_text) --%rollback(manual) begin @@ -27,7 +27,7 @@ create or replace package body run_helper is execute immediate q'[grant execute on ut3_tester_helper.dummy_test_procedure to public]'; - execute immediate q'[create or replace package ut3$user#.bad_test_package as + execute immediate q'[create or replace package ut3_user.bad_test_package as --%rollback(manual) --%test(dummy_test) procedure some_dummy_test_procedure; @@ -37,7 +37,7 @@ create or replace package body run_helper is procedure setup_cache_objectstag is pragma autonomous_transaction; begin - execute immediate q'[create or replace package ut3$user#.dummy_test_package as + execute immediate q'[create or replace package ut3_user.dummy_test_package as --%suite(dummy_test_suite) --%suitepath(some.path) --%tags(dummy) @@ -48,7 +48,7 @@ create or replace package body run_helper is --%beforetest(some_procedure) procedure some_dummy_test_procedure; end;]'; - execute immediate q'[create or replace procedure ut3$user#.dummy_test_procedure as + execute immediate q'[create or replace procedure ut3_user.dummy_test_procedure as --%some_annotation(some_text) --%rollback(manual) begin @@ -67,7 +67,7 @@ create or replace package body run_helper is procedure setup_cache_twotags is pragma autonomous_transaction; begin - execute immediate q'[create or replace package ut3$user#.dummy_test_package as + execute immediate q'[create or replace package ut3_user.dummy_test_package as --%suite(dummy_test_suite) --%tags(suitetag1,suitetag2) --%rollback(manual) @@ -77,7 +77,7 @@ create or replace package body run_helper is --%beforetest(some_procedure) procedure some_dummy_test_procedure; end;]'; - execute immediate q'[create or replace procedure ut3$user#.dummy_test_procedure as + execute immediate q'[create or replace procedure ut3_user.dummy_test_procedure as --%some_annotation(some_text) --%rollback(manual) begin @@ -141,19 +141,41 @@ create or replace package body run_helper is pragma autonomous_transaction; begin setup_cache_objects(); - ut3.ut_annotation_manager.rebuild_annotation_cache('UT3$USER#','PACKAGE'); - ut3.ut_annotation_manager.rebuild_annotation_cache('UT3$USER#','PROCEDURE'); - ut3.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER_HELPER','PROCEDURE'); + ut3_develop.ut_annotation_manager.rebuild_annotation_cache('UT3_USER','PACKAGE'); + ut3_develop.ut_annotation_manager.rebuild_annotation_cache('UT3_USER','PROCEDURE'); + ut3_develop.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER_HELPER','PROCEDURE'); + end; + + procedure setup_cache_context_disabled is + pragma autonomous_transaction; + begin + --the procedures that cleanup_cache drops + setup_cache_objects(); + execute immediate q'[create or replace package ut3_user.dummy_test_package as + --%suite(dummy_test_suite) + --%suitepath(some.path) + + --%test(dummy_test) + procedure some_dummy_test_procedure; + + --%context(dummy_context) + + --%test(disabled_test) + --%disabled(not ready) + procedure disabled_test_procedure; + + --%endcontext + end;]'; end; procedure cleanup_cache is pragma autonomous_transaction; begin - delete from ut3.ut_annotation_cache_info - where object_type = 'PROCEDURE' and object_owner in ('UT3$USER#','UT3_TESTER_HELPER') + delete from ut3_develop.ut_annotation_cache_info + where object_type = 'PROCEDURE' and object_owner in ('UT3_USER','UT3_TESTER_HELPER') or object_type = 'PACKAGE' and object_owner = user and object_name = 'DUMMY_TEST_PACKAGE'; - execute immediate q'[drop package ut3$user#.dummy_test_package]'; - execute immediate q'[drop procedure ut3$user#.dummy_test_procedure]'; + execute immediate q'[drop package ut3_user.dummy_test_package]'; + execute immediate q'[drop procedure ut3_user.dummy_test_procedure]'; execute immediate q'[drop procedure ut3_tester_helper.dummy_test_procedure]'; end; @@ -185,7 +207,7 @@ create or replace package body run_helper is begin create_db_link; execute immediate q'[ - create or replace package ut3$user#.test_db_link is + create or replace package ut3_user.test_db_link is --%suite --%test @@ -193,13 +215,13 @@ create or replace package body run_helper is end;]'; execute immediate q'[ - create or replace package body ut3$user#.test_db_link is + create or replace package body ut3_user.test_db_link is procedure runs_with_db_link is a_value integer; begin select 1 into a_value from dual@db_loopback; - ut3.ut.expect(a_value).to_be_null(); + ut3_develop.ut.expect(a_value).to_be_null(); end; end;]'; @@ -208,10 +230,10 @@ create or replace package body run_helper is procedure db_link_cleanup is begin drop_db_link; - begin execute immediate 'drop package ut3$user#.test_db_link'; exception when others then null; end; + begin execute immediate 'drop package ut3_user.test_db_link'; exception when others then null; end; end; - procedure create_suite_with_link is + procedure create_suite_with_link is pragma autonomous_transaction; begin create_db_link; @@ -250,7 +272,7 @@ create or replace package body run_helper is execute immediate 'grant execute on test_distributed_savepoint to public'; end; - procedure drop_suite_with_link is + procedure drop_suite_with_link is pragma autonomous_transaction; begin drop_db_link; @@ -258,7 +280,7 @@ create or replace package body run_helper is execute immediate 'drop package test_distributed_savepoint'; end; - procedure create_ut3$user#_tests is + procedure create_ut3_user_tests is pragma autonomous_transaction; begin execute immediate q'[create or replace package test_package_1 is @@ -343,17 +365,267 @@ create or replace package body run_helper is end; end test_package_3; ]'; + + execute immediate q'[create or replace package test_tag_pkg_1 is + --%suite + --%tags(suite1,release_3_1_13,development,complex,end_to_end) + --%suitepath(suite1) + --%rollback(manual) + + --%test(Test1 from test_tag_pkg_1) + --%tags(test1,development,fast) + procedure test1; + + --%test(Test2 from test_tag_pkg_1) + --%tags(test2,production,slow,patch_3_1_13) + procedure test2; + + end test_tag_pkg_1; + ]'; + + execute immediate q'[create or replace package body test_tag_pkg_1 is + procedure test1 is + begin + dbms_output.put_line('test_tag_pkg_1.test1 executed'); + end; + procedure test2 is + begin + dbms_output.put_line('test_tag_pkg_1.test2 executed'); + end; + end test_tag_pkg_1; + ]'; + + execute immediate q'[create or replace package test_tag_pkg_2 is + --%suite + --%tags(suite2,release_3_1_12,development,simple) + --%suitepath(suite1.suite2) + --%rollback(manual) + + --%test(Test3 from test_tag_pkg_2) + --%tags(test3,development,fast) + procedure test3; + + --%test(Test4 from test_tag_pkg_1) + --%tags(test4,production,slow) + procedure test4; + + end test_tag_pkg_2; + ]'; + + execute immediate q'[create or replace package body test_tag_pkg_2 is + procedure test3 is + begin + dbms_output.put_line('test_tag_pkg_2.test3 executed'); + end; + procedure test4 is + begin + dbms_output.put_line('test_tag_pkg_2.test4 executed'); + end; + end test_tag_pkg_2; + ]'; + + execute immediate q'[create or replace package test_tag_pkg_3 is + --%suite + --%tags(suite3,release_3_1_13,production,simple,end_to_end) + --%suitepath(suite3) + --%rollback(manual) + + --%test(Test5 from test_tag_pkg_3) + --%tags(test5,release_3_1_13,production,patch_3_1_13) + procedure test5; + + --%test(Test6 from test_tag_pkg_3) + --%tags(test6,development,patch_3_1_14) + procedure test6; + + end test_tag_pkg_3; + ]'; + + execute immediate q'[create or replace package body test_tag_pkg_3 is + procedure test5 is + begin + dbms_output.put_line('test_tag_pkg_3.test5 executed'); + end; + procedure test6 is + begin + dbms_output.put_line('test_tag_pkg_3.test6 executed'); + end; + end test_tag_pkg_3; + ]'; + + execute immediate q'[create or replace package suite1_level1_pkg is + + --%suite(suite1_level1) + --%suitepath(any_none) + --%rollback(manual) + + --%test(Test 1 from Suite1 on level 1) + --%tags(suite1,level1,test1,test1_level1) + procedure test1_level1; + + --%test(Test 2 from Suite1 on level 1) + procedure test2_level1; + + end suite1_level1_pkg; + ]'; + + execute immediate q'[create or replace package body suite1_level1_pkg is + procedure test1_level1 is + begin + dbms_output.put_line('suite1_level1_pkg.test1_level1 executed'); + end; + procedure test2_level1 is + begin + dbms_output.put_line('suite1_level1_pkg.test2_level1 executed'); + end; + end suite1_level1_pkg; + ]'; + + execute immediate q'[create or replace package suite1_1_level2_pkg is + + --%suite(suite1_1_level2) + --%suitepath(any_none.suite1_level1) + --%rollback(manual) + + --%test(Test 1 from Suite1_2 on level 2) + --%tags(level2,test1,test1_level2) + procedure suite1_1_test1_level2; + + --%test(Test 2 from Suite1_2 on level 2) + procedure suite1_1_test2_level2; + + end suite1_1_level2_pkg; + ]'; + + execute immediate q'[create or replace package body suite1_1_level2_pkg is + procedure suite1_1_test1_level2 is + begin + dbms_output.put_line('suite1_1_level2_pkg.suite1_1_test1_level2 executed'); + end; + procedure suite1_1_test2_level2 is + begin + dbms_output.put_line('suite1_1_level2_pkg.suite1_1_test2_level2 executed'); + end; + end suite1_1_level2_pkg; + ]'; + + execute immediate q'[create or replace package suite1_2_level2_pkg is + + --%suite(suite1_2_level2) + --%tags(level2,suite1_2,suites) + --%suitepath(any_none.suite1_level1) + --%rollback(manual) + + --%test(Test 1 from Suite1_2 on level 2) + procedure suite1_2_test1_level2; + + --%test(Test 2 from Suite1_2 on level 2) + --%tags(level2,test2,test2_level2) + procedure suite1_2_test2_level1; + + end suite1_2_level2_pkg; + ]'; + + execute immediate q'[create or replace package body suite1_2_level2_pkg is + procedure suite1_2_test1_level2 is + begin + dbms_output.put_line('suite1_2_level2_pkg.suite1_2_test1_level2 executed'); + end; + procedure suite1_2_test2_level1 is + begin + dbms_output.put_line('suite1_2_level2_pkg.suite1_2_test2_level1 executed'); + end; + end suite1_2_level2_pkg; + ]'; + + execute immediate q'[create or replace package suite2_level1_pkg is + + --%suite(suite2_level1) + --%tags(level1,suite2,suites) + --%suitepath(any_none) + --%rollback(manual) + + --%test(Test 1 from Suite1 on level 1) + --%tags(suite2,level1,test1,test1_level1) + procedure test1_level1; + + --%test(Test 2 from Suite1 on level 1) + procedure test2_level1; + + end suite2_level1_pkg; + ]'; + + execute immediate q'[create or replace package body suite2_level1_pkg is + procedure test1_level1 is + begin + dbms_output.put_line('suite2_level1_pkg.test1_level1 executed'); + end; + procedure test2_level1 is + begin + dbms_output.put_line('suite2_level1_pkg.test2_level1 executed'); + end; + end suite2_level1_pkg; + ]'; + + execute immediate q'[create or replace package suite2_2_level2_pkg is + + --%suite(suite2_2_level2) + --%tags(level2,suite2_2,suites) + --%suitepath(any_none.suite2_level1) + --%rollback(manual) + + --%test(Test 1 from Suite2_2 on level 2) + procedure suite2_2_test1_level2; + + --%test(Test 2 from Suite2_2 on level 2) + --%tags(level2,test2,test2_level2) + procedure suite2_2_test2_level2; + + end suite2_2_level2_pkg; + ]'; + + execute immediate q'[create or replace package body suite2_2_level2_pkg is + procedure suite2_2_test1_level2 is + begin + dbms_output.put_line('suite2_2_level2_pkg.suite2_2_test1_level2 executed'); + end; + procedure suite2_2_test2_level2 is + begin + dbms_output.put_line('suite2_2_level2_pkg.suite2_2_test2_level2 executed'); + end; + end suite2_2_level2_pkg; + ]'; + + execute immediate q'[grant execute on test_package_1 to public]'; execute immediate q'[grant execute on test_package_2 to public]'; execute immediate q'[grant execute on test_package_3 to public]'; + execute immediate q'[grant execute on test_tag_pkg_1 to public]'; + execute immediate q'[grant execute on test_tag_pkg_2 to public]'; + execute immediate q'[grant execute on test_tag_pkg_3 to public]'; + + execute immediate q'[grant execute on suite1_level1_pkg to public]'; + execute immediate q'[grant execute on suite1_1_level2_pkg to public]'; + execute immediate q'[grant execute on suite1_2_level2_pkg to public]'; + execute immediate q'[grant execute on suite2_level1_pkg to public]'; + execute immediate q'[grant execute on suite2_2_level2_pkg to public]'; end; - procedure drop_ut3$user#_tests is + procedure drop_ut3_user_tests is pragma autonomous_transaction; begin execute immediate q'[drop package test_package_1]'; execute immediate q'[drop package test_package_2]'; execute immediate q'[drop package test_package_3]'; + execute immediate q'[drop package test_tag_pkg_1]'; + execute immediate q'[drop package test_tag_pkg_2]'; + execute immediate q'[drop package test_tag_pkg_3]'; + + execute immediate q'[drop package suite2_2_level2_pkg]'; + execute immediate q'[drop package suite2_level1_pkg]'; + execute immediate q'[drop package suite1_2_level2_pkg]'; + execute immediate q'[drop package suite1_level1_pkg]'; + execute immediate q'[drop package suite1_1_level2_pkg]'; end; procedure create_test_suite is @@ -390,7 +662,7 @@ create or replace package body run_helper is procedure failing_stateful_test is begin - ut3.ut.expect(stateful_package.get_state@db_loopback).to_equal('abc'); + ut3_develop.ut.expect(stateful_package.get_state@db_loopback).to_equal('abc'); end; procedure rebuild_stateful_package is @@ -435,126 +707,126 @@ create or replace package body run_helper is execute immediate 'drop package ut_without_body'; end; - procedure run(a_reporter ut3.ut_reporter_base := null) is + procedure run(a_reporter ut3_develop.ut_reporter_base := null) is begin - ut3.ut.run(a_reporter); + ut3_develop.ut.run(a_reporter); end; - procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) is + procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null) is begin - ut3.ut.run(a_path, a_reporter); + ut3_develop.ut.run(a_path, a_reporter); end; - procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) is + procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null) is begin - ut3.ut.run(a_paths, a_reporter); + ut3_develop.ut.run(a_paths, a_reporter); end; - procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is + procedure run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) is begin - ut3.ut.run( + ut3_develop.ut.run( a_paths, a_reporter, - a_source_files => ut3.ut_varchar2_list(), + a_source_files => ut3_develop.ut_varchar2_list(), a_test_files => a_test_files ); end; - function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_reporter ut3_develop.ut_reporter_base := null) return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run(a_reporter)); + select * bulk collect into l_results from table (ut3_develop.ut.run(a_reporter)); return l_results; end; - function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin select * bulk collect into l_results from table ( - ut3.ut.run( + ut3_develop.ut.run( a_paths, - a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_reporter, a_source_files => ut3_develop.ut_varchar2_list(), a_test_files => a_test_files )); return l_results; end; - function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) - return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null) + return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run(a_path, a_reporter)); + select * bulk collect into l_results from table (ut3_develop.ut.run(a_path, a_reporter)); return l_results; end; - function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) - return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null) + return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run(a_paths, a_reporter)); + select * bulk collect into l_results from table (ut3_develop.ut.run(a_paths, a_reporter)); return l_results; end; - function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) - return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) + return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin select * bulk collect into l_results from table ( - ut3.ut.run( - a_reporter, a_source_files => ut3.ut_varchar2_list(), + ut3_develop.ut.run( + a_reporter, a_source_files => ut3_develop.ut_varchar2_list(), a_test_files => a_test_files )); return l_results; end; - procedure run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2) is + procedure run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) is begin - ut3.ut.run(a_reporter,a_tags => a_tags); + ut3_develop.ut.run(a_reporter,a_tags => a_tags); end; - procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null,a_tags varchar2) is + procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) is begin - ut3.ut.run(a_path, a_reporter,a_tags => a_tags); + ut3_develop.ut.run(a_path, a_reporter,a_tags => a_tags); end; - procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) is + procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) is begin - ut3.ut.run(a_paths, a_reporter,a_tags => a_tags); + ut3_develop.ut.run(a_paths, a_reporter,a_tags => a_tags); end; - function run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run(a_reporter, a_tags => a_tags)); + select * bulk collect into l_results from table (ut3_develop.ut.run(a_reporter, a_tags => a_tags)); return l_results; end; - function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) - return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) + return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run(a_path, a_reporter,a_tags => a_tags)); + select * bulk collect into l_results from table (ut3_develop.ut.run(a_path, a_reporter,a_tags => a_tags)); return l_results; end; - function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) - return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; + function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) + return ut3_develop.ut_varchar2_list is + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run(a_paths, a_reporter, a_tags => a_tags)); + select * bulk collect into l_results from table (ut3_develop.ut.run(a_paths, a_reporter, a_tags => a_tags)); return l_results; end; - procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut3_latest_release.ut_matcher) is - l_suite ut3.ut_suite; + procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut_matcher) is + l_suite ut3_develop.ut_suite; begin --Arrange execute immediate 'delete from ut$test_table'; - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); + l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); l_suite.path := 'ut_transaction_control'; - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_TRANSACTION_CONTROL', 'setup', ut3.ut_utils.gc_before_all)); + l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_TRANSACTION_CONTROL', 'setup', ut3_develop.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => USER, a_object_name => 'ut_transaction_control',a_name => a_procedure_name, a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_transaction_control',a_name => a_procedure_name, a_line_no=> 1); l_suite.set_rollback_type(a_rollback_type); --Act @@ -568,7 +840,7 @@ create or replace package body run_helper is procedure create_dummy_long_test_package is pragma autonomous_transaction; begin - execute immediate q'[create or replace package ut3.dummy_long_test_package as + execute immediate q'[create or replace package ut3_develop.dummy_long_test_package as --%suitepath(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) --%suite(dummy_test_suite) @@ -577,7 +849,7 @@ create or replace package body run_helper is procedure some_dummy_test_procedure; end;]'; - execute immediate q'[create or replace package ut3.dummy_long_test_package1 as + execute immediate q'[create or replace package ut3_develop.dummy_long_test_package1 as --%suitepath(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) --%suite(dummy_test_suite1) @@ -590,39 +862,50 @@ create or replace package body run_helper is procedure drop_dummy_long_test_package is pragma autonomous_transaction; begin - execute immediate q'[drop package ut3.dummy_long_test_package]'; - execute immediate q'[drop package ut3.dummy_long_test_package1]'; + execute immediate q'[drop package ut3_develop.dummy_long_test_package]'; + execute immediate q'[drop package ut3_develop.dummy_long_test_package1]'; end; procedure create_ut3_suite is pragma autonomous_transaction; begin execute immediate q'[ - create or replace package ut3.some_test_package + create or replace package ut3_develop.some_test_package as --%suite --%test procedure some_test; + end;]'; + execute immediate q'[ + create or replace package ut3_develop.package_that_is_not_a_test + as + --%parameter(a comment inside) + --%parameters( description ) + + --%test + procedure some_test; + end;]'; end; procedure drop_ut3_suite is pragma autonomous_transaction; begin - execute immediate q'[drop package ut3.some_test_package]'; + execute immediate q'[drop package ut3_develop.package_that_is_not_a_test]'; + execute immediate q'[drop package ut3_develop.some_test_package]'; end; - function get_object_name(a_owner in varchar2) return ut3.ut_object_names is + function get_schema_ut_packages(a_owner in varchar2) return ut3_develop.ut_object_names is begin - return ut3.ut_suite_manager.get_schema_ut_packages(ut3.ut_varchar2_rows(a_owner)); + return ut3_develop.ut_suite_manager.get_schema_ut_packages(ut3_develop.ut_varchar2_rows(a_owner), null); end; function ut_output_buffer_tmp return t_out_buff_tab pipelined is l_buffer_tab t_out_buff_tab; cursor get_buffer is - select * from ut3.ut_output_buffer_tmp; + select * from ut3_develop.ut_output_buffer_tmp; begin open get_buffer; fetch get_buffer bulk collect into l_buffer_tab; @@ -633,7 +916,7 @@ create or replace package body run_helper is procedure delete_buffer is begin - delete from ut3.ut_output_buffer_tmp; + delete from ut3_develop.ut_output_buffer_tmp; end; function get_annotation_cache_info_cur( @@ -643,7 +926,7 @@ create or replace package body run_helper is l_result sys_refcursor; begin open l_result for - select * from ut3.ut_annotation_cache_info + select * from ut3_develop.ut_annotation_cache_info where object_owner = a_owner and object_type = a_type; return l_result; @@ -658,12 +941,46 @@ create or replace package body run_helper is begin open l_result for select * - from ut3.ut_annotation_cache_info i - join ut3.ut_annotation_cache c on c.cache_id = i.cache_id + from ut3_develop.ut_annotation_cache_info i + join ut3_develop.ut_annotation_cache c on c.cache_id = i.cache_id where object_owner = a_owner and object_type = a_type and object_name = nvl( a_name, object_name ); return l_result; end; + procedure slow_down_insert_into_table_buffer is + pragma autonomous_transaction; + begin + execute immediate q'[ + create or replace trigger ut3_develop.slow_down_buffer_insert + before insert on ut3_develop.ut_output_buffer_info_tmp + begin + dbms_session.sleep(1); + end;]'; + end; + + procedure cleanup_slow_down_insert_into_table_buffer is + pragma autonomous_transaction; + begin + execute immediate 'drop trigger ut3_develop.slow_down_buffer_insert'; + exception when others then + if sqlcode <> -4080 then raise; end if; + end; + + procedure run_as_job(a_job_action varchar2) is + l_job_name varchar2(50); + l_timestamp timestamp with time zone := current_timestamp; + pragma autonomous_transaction; + begin + l_job_name := 'utPLSQL__'||to_char(l_timestamp,'yyyymmddhh24missff'); + dbms_scheduler.create_job( + job_name => l_job_name, + job_type => 'PLSQL_BLOCK', + job_action => a_job_action, + start_date => l_timestamp, + enabled => TRUE, + auto_drop => TRUE + ); + end; end; / diff --git a/test/ut3_tester_helper/run_helper.pks b/test/ut3_tester_helper/run_helper.pks index 0f5e5a925..c46b99a3f 100644 --- a/test/ut3_tester_helper/run_helper.pks +++ b/test/ut3_tester_helper/run_helper.pks @@ -2,12 +2,12 @@ create or replace package run_helper is g_run_id integer; - type t_out_buff_tab is table of ut3.ut_output_buffer_tmp%rowtype; - type prof_runs_tab is table of ut3.plsql_profiler_runs%rowtype; + type t_out_buff_tab is table of ut3_develop.ut_output_buffer_tmp%rowtype; procedure setup_cache_objects; procedure setup_cache_objectstag; procedure setup_cache_twotags; + procedure setup_cache_context_disabled; procedure setup_cache; procedure cleanup_cache; procedure create_db_link; @@ -18,8 +18,8 @@ create or replace package run_helper is procedure create_suite_with_link; procedure drop_suite_with_link; - procedure create_ut3$user#_tests; - procedure drop_ut3$user#_tests; + procedure create_ut3_user_tests; + procedure drop_ut3_user_tests; procedure create_test_suite; procedure drop_test_suite; @@ -29,37 +29,37 @@ create or replace package run_helper is procedure create_trans_control; procedure drop_trans_control; - procedure run(a_reporter ut3.ut_reporter_base := null); - procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null); - procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null); - procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, - a_reporter ut3.ut_reporter_base); - function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; - function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, - a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; - function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) - return ut3.ut_varchar2_list; - function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) - return ut3.ut_varchar2_list; - function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) - return ut3.ut_varchar2_list; + procedure run(a_reporter ut3_develop.ut_reporter_base := null); + procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null); + procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null); + procedure run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, + a_reporter ut3_develop.ut_reporter_base); + function run(a_reporter ut3_develop.ut_reporter_base := null) return ut3_develop.ut_varchar2_list; + function run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, + a_reporter ut3_develop.ut_reporter_base) return ut3_develop.ut_varchar2_list; + function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null) + return ut3_develop.ut_varchar2_list; + function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null) + return ut3_develop.ut_varchar2_list; + function run(a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) + return ut3_develop.ut_varchar2_list; - procedure run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2); - procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null,a_tags varchar2); - procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2); - function run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2) return ut3.ut_varchar2_list; - function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) - return ut3.ut_varchar2_list; - function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) - return ut3.ut_varchar2_list; + procedure run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2); + procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2); + procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2); + function run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) return ut3_develop.ut_varchar2_list; + function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) + return ut3_develop.ut_varchar2_list; + function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) + return ut3_develop.ut_varchar2_list; - procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut3_latest_release.ut_matcher); + procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut_matcher); procedure create_dummy_long_test_package; procedure drop_dummy_long_test_package; procedure create_ut3_suite; procedure drop_ut3_suite; - function get_object_name(a_owner in varchar2) return ut3.ut_object_names; + function get_schema_ut_packages(a_owner in varchar2) return ut3_develop.ut_object_names; function ut_output_buffer_tmp return t_out_buff_tab pipelined; procedure delete_buffer; @@ -75,5 +75,10 @@ create or replace package run_helper is a_name varchar2 := null ) return sys_refcursor; + procedure slow_down_insert_into_table_buffer; + + procedure cleanup_slow_down_insert_into_table_buffer; + + procedure run_as_job(a_job_action varchar2); end; / diff --git a/test/ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps b/test/ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps new file mode 100644 index 000000000..5134fef21 --- /dev/null +++ b/test/ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps @@ -0,0 +1,17 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_DBLE_NEST_LST_OBJ'; + if l_exists > 0 then + execute immediate 'drop type test_dummy_dble_nest_lst_obj force'; + end if; +end; +/ + +CREATE TYPE test_dummy_dble_nest_lst_obj AS OBJECT +( + some_number_id NUMBER, + some_name VARCHAR2 (25), + dummy_list test_dummy_double_nested_list +); +/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_double_nested_list.tps b/test/ut3_tester_helper/test_dummy_double_nested_list.tps new file mode 100644 index 000000000..625462824 --- /dev/null +++ b/test/ut3_tester_helper/test_dummy_double_nested_list.tps @@ -0,0 +1,13 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_DOUBLE_NESTED_LIST'; + if l_exists > 0 then + execute immediate 'drop type test_dummy_double_nested_list force'; + end if; +end; +/ + +CREATE TYPE test_dummy_double_nested_list AS + TABLE OF test_dummy_nested_object_list; +/ diff --git a/test/ut3_tester_helper/test_dummy_double_nested_object.tps b/test/ut3_tester_helper/test_dummy_double_nested_object.tps new file mode 100644 index 000000000..8f74f7ecb --- /dev/null +++ b/test/ut3_tester_helper/test_dummy_double_nested_object.tps @@ -0,0 +1,15 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_DOUBLE_NESTED_OBJ'; + if l_exists > 0 then + execute immediate 'drop type test_dummy_double_nested_obj force'; + end if; +end; +/ + +create or replace type test_dummy_double_nested_obj as object ( + first_double_nested_obj test_dummy_nested_object, + "Value" varchar2(30) +) +/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_nested_object.tps b/test/ut3_tester_helper/test_dummy_nested_object.tps new file mode 100644 index 000000000..6aef3bef8 --- /dev/null +++ b/test/ut3_tester_helper/test_dummy_nested_object.tps @@ -0,0 +1,15 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_NESTED_OBJECT'; + if l_exists > 0 then + execute immediate 'drop type test_dummy_nested_object force'; + end if; +end; +/ + +create or replace type test_dummy_nested_object as object ( + first_nested_obj test_dummy_object, + sec_nested_obj test_dummy_object +) +/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_nested_object_list.tps b/test/ut3_tester_helper/test_dummy_nested_object_list.tps new file mode 100644 index 000000000..fd47b55bd --- /dev/null +++ b/test/ut3_tester_helper/test_dummy_nested_object_list.tps @@ -0,0 +1,15 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_NESTED_OBJECT_LIST'; + if l_exists > 0 then + execute immediate 'drop type test_dummy_nested_object_list force'; + end if; +end; +/ + +create or replace type test_dummy_nested_object_list as object ( + first_nested_obj test_dummy_object_list, + somename varchar2(50) +) +/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_object_list.tps b/test/ut3_tester_helper/test_dummy_object_list.tps index 67bba558e..849974da1 100644 --- a/test/ut3_tester_helper/test_dummy_object_list.tps +++ b/test/ut3_tester_helper/test_dummy_object_list.tps @@ -1,2 +1,12 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_OBJECT_LIST'; + if l_exists > 0 then + execute immediate 'drop type test_dummy_object_list force'; + end if; +end; +/ + create or replace type test_dummy_object_list as table of test_dummy_object / diff --git a/test/ut3_tester_helper/test_nested_tab_varray.tps b/test/ut3_tester_helper/test_nested_tab_varray.tps new file mode 100644 index 000000000..9f58d090e --- /dev/null +++ b/test/ut3_tester_helper/test_nested_tab_varray.tps @@ -0,0 +1,14 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_NESTED_TAB_VARRAY'; + if l_exists > 0 then + execute immediate 'drop type test_nested_tab_varray force'; + end if; +end; +/ + +create or replace type test_nested_tab_varray as object ( + n_varray t_varray +) +/ diff --git a/test/ut3_user/api/test_ut_run.pkb b/test/ut3_user/api/test_ut_run.pkb index 329b71357..12ab6cdba 100644 --- a/test/ut3_user/api/test_ut_run.pkb +++ b/test/ut3_user/api/test_ut_run.pkb @@ -6,31 +6,71 @@ create or replace package body test_ut_run is gc_client_info constant varchar2(32767) := 'test client info'; g_context_test_results clob; + g_timestamp timestamp; procedure clear_expectations is begin ut3_tester_helper.main_helper.clear_expectations(); end; - procedure create_ut3$user#_tests is + procedure create_ut3_user_tests is begin - ut3_tester_helper.run_helper.create_ut3$user#_tests(); + ut3_tester_helper.run_helper.create_ut3_user_tests(); end; - procedure drop_ut3$user#_tests is + procedure drop_ut3_user_tests is begin - ut3_tester_helper.run_helper.drop_ut3$user#_tests(); + ut3_tester_helper.run_helper.drop_ut3_user_tests(); + end; + + --a suite on suitepath "tests", as test_package_1 in ut3_tester_helper (see run_helper.create_ut3_user_tests) + procedure create_test_suite_in_ut3_user is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_suite_in_ut3_user is + --%suite + --%suitepath(tests) + + --%test + procedure test1; + end;]'; + execute immediate q'[create or replace package body test_suite_in_ut3_user is + procedure test1 is + begin + dbms_output.put_line('test_suite_in_ut3_user.test1 executed'); + end; + end;]'; + end; + + procedure drop_test_suite_in_ut3_user is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_suite_in_ut3_user'; + end; + + procedure run_groups_suites_by_schema is + l_results clob; + begin + --Act - ut3_user:tests sorts between ut3_tester_helper:tests and ut3_tester_helper:tests2 by path + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run( + ut3_develop.ut_varchar2_list('ut3_user:tests', 'ut3_tester_helper:tests', 'ut3_tester_helper:tests2'), + a_tags => null + ) + ); + --Assert - UT3_TESTER_HELPER comes before UT3_USER + ut.expect( l_results ).to_be_like( '%test_package_2.test1 executed%test_package_3.test1 executed%test_suite_in_ut3_user.test1 executed%' ); end; procedure ut_version is begin - ut.expect(ut3.ut.version()).to_match('^v\d+\.\d+\.\d+\.\d+(-\w+)?$'); + ut.expect(ut3_develop.ut.version()).to_match('^v\d+\.\d+\.\d+\.\d+(-\w+)?$'); end; procedure ut_fail is begin --Act - ut3.ut.fail('Testing failure message'); + ut3_develop.ut.fail('Testing failure message'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations(1)) .to_be_like('%Testing failure message%'); @@ -49,7 +89,7 @@ create or replace package body test_ut_run is l_results clob; begin --Act - ut3.ut.run('ut3_tester_helper',a_reporter => ut3.ut_documentation_reporter() ); + ut3_develop.ut.run('ut3_tester_helper',a_reporter => ut3_develop.ut_documentation_reporter() ); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); @@ -59,11 +99,11 @@ create or replace package body test_ut_run is l_results clob; begin --Act - ut3.ut.run( + ut3_develop.ut.run( 'ut3_tester_helper', - a_reporter => ut3.ut_sonar_test_reporter(), - a_source_files => ut3.ut_varchar2_list(), - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + a_reporter => ut3_develop.ut_sonar_test_reporter(), + a_source_files => ut3_develop.ut_varchar2_list(), + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb') ); @@ -78,7 +118,7 @@ create or replace package body test_ut_run is procedure run_proc_pkg_name is l_results clob; begin - ut3.ut.run('ut3_tester_helper.test_package_1'); + ut3_develop.ut.run('ut3_tester_helper.test_package_1'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%test_package_1%' ); @@ -89,10 +129,10 @@ create or replace package body test_ut_run is procedure run_proc_pkg_name_file_list is l_results clob; begin - ut3.ut.run( + ut3_develop.ut.run( 'ut3_tester_helper.test_package_3', - ut3.ut_sonar_test_reporter(), a_source_files => ut3.ut_varchar2_list(), - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + ut3_develop.ut_sonar_test_reporter(), a_source_files => ut3_develop.ut_varchar2_list(), + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb') ); @@ -106,7 +146,7 @@ create or replace package body test_ut_run is procedure run_proc_path_list is l_results clob; begin - ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list(':tests.test_package_1',':tests')); + ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests')); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%test_package_1%' ); @@ -118,9 +158,9 @@ create or replace package body test_ut_run is l_results clob; begin ut3_tester_helper.run_helper.run( - a_paths => ut3.ut_varchar2_list(':tests.test_package_1',':tests'), - a_reporter => ut3.ut_sonar_test_reporter(), - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + a_paths => ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'), + a_reporter => ut3_develop.ut_sonar_test_reporter(), + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb') ); @@ -135,7 +175,7 @@ create or replace package body test_ut_run is l_results clob; begin --Act - ut3.ut.run('ut3_tester_helper', cast(null as ut3.ut_reporter_base)); + ut3_develop.ut.run('ut3_tester_helper', cast(null as ut3_develop.ut_reporter_base)); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); @@ -153,7 +193,7 @@ create or replace package body test_ut_run is procedure run_proc_null_path_list is l_results clob; - l_paths ut3.ut_varchar2_list; + l_paths ut3_develop.ut_varchar2_list; begin --Act ut3_tester_helper.run_helper.run(l_paths); @@ -166,7 +206,7 @@ create or replace package body test_ut_run is l_results clob; begin --Act - ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list()); + ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list()); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); @@ -185,7 +225,7 @@ create or replace package body test_ut_run is execute immediate 'create or replace package body test_commit_warning is procedure does_commit is begin - ut3.ut.expect(1).to_equal(1); + ut3_develop.ut.expect(1).to_equal(1); commit; end; end;'; @@ -200,7 +240,7 @@ create or replace package body test_ut_run is procedure run_proc_warn_on_commit is l_results clob; begin - ut3.ut.run('test_commit_warning'); + ut3_develop.ut.run('test_commit_warning'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); ut.expect(l_results).to_be_like( '%Unable to perform automatic rollback after test%'|| @@ -236,7 +276,7 @@ create or replace package body test_ut_run is execute immediate 'create or replace package body child_suite is procedure does_stuff is begin - ut3.ut.expect(1).to_equal(1); + ut3_develop.ut.expect(1).to_equal(1); end; end;'; end; @@ -251,12 +291,12 @@ create or replace package body test_ut_run is procedure run_proc_fail_child_suites is l_results clob; begin - ut3.ut.run('child_suite'); + ut3_develop.ut.run('child_suite'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); ut.expect(l_results).to_be_like( '%1) does_stuff%' || 'ORA-01403: no data found%' || - 'ORA-06512: at "UT3$USER#.PARENT_SUITE%' + 'ORA-06512: at "UT3_USER.PARENT_SUITE%' ); end; @@ -314,7 +354,7 @@ create or replace package body test_ut_run is insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; --Act - ut3.ut.run('test_transaction.insert_row', a_force_manual_rollback => true); + ut3_develop.ut.run('test_transaction.insert_row', a_force_manual_rollback => true); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert @@ -339,7 +379,7 @@ create or replace package body test_ut_run is insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; --Act - ut3.ut.run('test_transaction.insert_and_raise', a_force_manual_rollback => true); + ut3_develop.ut.run('test_transaction.insert_and_raise', a_force_manual_rollback => true); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert @@ -364,7 +404,7 @@ create or replace package body test_ut_run is insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; --Act - ut3.ut.run('test_transaction.insert_row'); + ut3_develop.ut.run('test_transaction.insert_row'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert @@ -377,7 +417,7 @@ create or replace package body test_ut_run is end; procedure run_func_no_params is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin l_results := ut3_tester_helper.run_helper.run(); --Assert @@ -385,23 +425,23 @@ create or replace package body test_ut_run is end; procedure run_func_specific_reporter is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin --Act - l_results := ut3_tester_helper.run_helper.run(ut3.ut_documentation_reporter()); + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_documentation_reporter()); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); end; procedure run_func_cov_file_list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin --Act select * bulk collect into l_results from table ( - ut3.ut.run('ut3_tester_helper', - ut3.ut_sonar_test_reporter(), - a_source_files => ut3.ut_varchar2_list(), - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + ut3_develop.ut.run('ut3_tester_helper', + ut3_develop.ut_sonar_test_reporter(), + a_source_files => ut3_develop.ut_varchar2_list(), + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb') )); @@ -410,9 +450,9 @@ create or replace package body test_ut_run is end; procedure run_func_pkg_name is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run('ut3_tester_helper.test_package_1')); + select * bulk collect into l_results from table (ut3_develop.ut.run('ut3_tester_helper.test_package_1')); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2%' ); @@ -420,13 +460,13 @@ create or replace package body test_ut_run is end; procedure run_func_pkg_name_file_list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin select * bulk collect into l_results from table ( - ut3.ut.run('ut3_tester_helper.test_package_3', - ut3.ut_sonar_test_reporter(), - a_source_files => ut3.ut_varchar2_list(), - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + ut3_develop.ut.run('ut3_tester_helper.test_package_3', + ut3_develop.ut_sonar_test_reporter(), + a_source_files => ut3_develop.ut_varchar2_list(), + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb') )); @@ -437,9 +477,9 @@ create or replace package body test_ut_run is end; procedure run_func_path_list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin - l_results := ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list(':tests.test_package_1',':tests')); + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests')); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); @@ -447,12 +487,12 @@ create or replace package body test_ut_run is end; procedure run_func_path_list_file_list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin l_results := ut3_tester_helper.run_helper.run( - a_paths => ut3.ut_varchar2_list(':tests.test_package_1',':tests'), - a_reporter => ut3.ut_sonar_test_reporter(), - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + a_paths => ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'), + a_reporter => ut3_develop.ut_sonar_test_reporter(), + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb') ); @@ -463,16 +503,16 @@ create or replace package body test_ut_run is end; procedure run_func_null_reporter is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin --Act - select * bulk collect into l_results from table (ut3.ut.run('ut3_tester_helper',cast(null as ut3.ut_reporter_base))); + select * bulk collect into l_results from table (ut3_develop.ut.run('ut3_tester_helper',cast(null as ut3_develop.ut_reporter_base))); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); end; procedure run_func_null_path is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin --Act l_results := ut3_tester_helper.run_helper.run(cast(null as varchar2)); @@ -481,8 +521,8 @@ create or replace package body test_ut_run is end; procedure run_func_null_path_list is - l_results ut3.ut_varchar2_list; - l_paths ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; + l_paths ut3_develop.ut_varchar2_list; begin --Act l_results := ut3_tester_helper.run_helper.run(l_paths); @@ -491,29 +531,29 @@ create or replace package body test_ut_run is end; procedure run_func_empty_path_list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin --Act - l_results := ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list()); + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list()); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); end; procedure run_func_cov_file_lst_null_rep is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin --Act l_results := ut3_tester_helper.run_helper.run( - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb'), - a_reporter => cast(null as ut3.ut_reporter_base)); + a_reporter => cast(null as ut3_develop.ut_reporter_base)); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); end; procedure run_func_empty_suite is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_expected varchar2(32767); pragma autonomous_transaction; begin @@ -528,7 +568,7 @@ create or replace package body test_ut_run is end;]'; l_expected := '%empty_suite%0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'; --Act - select * bulk collect into l_results from table(ut3.ut.run('empty_suite')); + select * bulk collect into l_results from table(ut3_develop.ut.run('empty_suite')); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); @@ -538,7 +578,7 @@ create or replace package body test_ut_run is end; procedure raise_in_invalid_state is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_expected varchar2(32767); begin --Arrange @@ -550,11 +590,11 @@ Failures:% ORA-04068: existing state of packages (DB_LOOPBACK%) has been discarded ORA-04061: existing state of package body "%.STATEFUL_PACKAGE" has been invalidated ORA-04065: not executed, altered or dropped package body "%.STATEFUL_PACKAGE"% - ORA-06512: at line 6% + ORA-06512: at line 7% 1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)%'; --Act - select * bulk collect into l_results from table(ut3.ut.run('ut3_tester_helper.test_stateful')); + select * bulk collect into l_results from table(ut3_develop.ut.run('ut3_tester_helper.test_stateful')); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); @@ -576,11 +616,11 @@ Failures:% end; procedure run_in_invalid_state is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; l_expected varchar2(32767); begin - select * bulk collect into l_results from table(ut3.ut.run('failing_invalid_spec')); + select * bulk collect into l_results from table(ut3_develop.ut.run('failing_invalid_spec')); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Call params for % are not valid: package %FAILING_INVALID_SPEC% does not exist or is invalid.%'); @@ -618,15 +658,15 @@ Failures:% end; procedure run_and_revalidate_specs is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; l_is_invalid number; begin execute immediate q'[select count(1) from all_objects o where o.owner = :object_owner and o.object_type = 'PACKAGE' and o.status = 'INVALID' and o.object_name= :object_name]' into l_is_invalid - using 'UT3$USER#','INVALID_PCKAG_THAT_REVALIDATES'; + using 'UT3_USER','INVALID_PCKAG_THAT_REVALIDATES'; - select * bulk collect into l_results from table(ut3.ut.run('invalid_pckag_that_revalidates')); + select * bulk collect into l_results from table(ut3_develop.ut.run('invalid_pckag_that_revalidates')); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(1).to_equal(l_is_invalid); @@ -681,14 +721,14 @@ Failures:% end; procedure run_and_report_warnings is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin - select * bulk collect into l_results from table(ut3.ut.run('bad_annotations')); + select * bulk collect into l_results from table(ut3_develop.ut.run('bad_annotations')); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Invalid annotation "--%context". Cannot find following "--%endcontext". Annotation ignored.% + ut.expect(l_actual).to_be_like('%Missing "--%endcontext" annotation for a "--%context" annotation. The end of package is considered end of context.% %1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s)%'); end; @@ -733,25 +773,25 @@ Failures:% procedure savepoints_on_db_links is l_results clob; begin - ut3.ut.run('ut3_tester_helper.test_distributed_savepoint'); + ut3_develop.ut.run('ut3_tester_helper.test_distributed_savepoint'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); ut.expect(l_results).to_be_like('%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; - procedure remove_time_from_results(a_results in out nocopy ut3.ut_varchar2_list) is + procedure remove_time_from_results(a_results in out nocopy ut3_develop.ut_varchar2_list) is begin for i in 1 .. a_results.count loop - a_results(i) := regexp_replace(a_results(i),'\[[0-9]*[\.,][0-9]+ sec\]',''); + a_results(i) := regexp_replace(a_results(i),'\[[0-9]*[\.,]?[0-9]+ sec\]',''); a_results(i) := regexp_replace(a_results(i),'Finished in [0-9]*[\.,][0-9]+ seconds',''); end loop; end; procedure run_schema_name_test is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_expected clob; begin select * bulk collect into l_results - from table ( ut3.ut.run( gc_owner||'.'||gc_owner ) ); + from table ( ut3_develop.ut.run( gc_owner||'.'||gc_owner ) ); l_expected := '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'; ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); end; @@ -780,17 +820,85 @@ Failures:% execute immediate 'drop package '||gc_owner||'.'||gc_owner; end; + procedure create_suites_with_path is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ut_abc is + -- %suite + -- %suitepath(main.abc) + + -- %test + procedure ut_test_01; + end ut_abc;]'; + + execute immediate q'[create or replace package body ut_abc + is + procedure ut_test_01 as begin ut.expect(true).to_be_true(); end; + end;]'; + + execute immediate q'[create or replace package ut_abc_def + is + -- %suite + -- %suitepath(main.abc_def) + + -- %test + procedure ut_test_01; + end ut_abc_def;]'; + + execute immediate q'[create or replace package body ut_abc_def + is + procedure ut_test_01 as begin ut.expect(true).to_be_true(); end; + end;]'; + + end; + + procedure drop_suites_with_path is + pragma autonomous_transaction; + begin + execute immediate q'[drop package ut_abc]'; + execute immediate q'[drop package ut_abc_def]'; + end; + + procedure run_suite_with_nls_sort is + L_current_sort varchar2(2000); + l_results ut3_develop.ut_varchar2_list; + l_expected clob; + begin + --Arrange + select value + into l_current_sort + from nls_session_parameters where parameter = 'NLS_SORT'; + + execute immediate 'alter session set nls_sort=GERMAN'; + + --Act + select * + bulk collect into l_results + from table ( ut3_develop.ut.run( gc_owner||':main' ) ); + --Assert + l_expected := q'[main% + abc_def% + ut_abc_def% + ut_test_01% + abc% + ut_abc% + ut_test_01%]'; + ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); + + execute immediate 'alter session set nls_sort='||l_current_sort; + end; + procedure run_with_random_order is - l_random_results ut3.ut_varchar2_list; - l_results ut3.ut_varchar2_list; + l_random_results ut3_develop.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin select * bulk collect into l_random_results - from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ) + from table ( ut3_develop.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 123 ) ) where trim(column_value) is not null and column_value not like 'Finished in %' and column_value not like '%Tests were executed with random order %'; select * bulk collect into l_results - from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1' ) ) + from table ( ut3_develop.ut.run( 'ut3_tester_helper.test_package_1' ) ) --TODO this condition should be removed once issues with unordered compare and 'blank text rows' are resolved. where trim(column_value) is not null and column_value not like 'Finished in %'; @@ -802,23 +910,23 @@ Failures:% end; procedure run_and_report_random_ord_seed is - l_actual ut3.ut_varchar2_list; + l_actual ut3_develop.ut_varchar2_list; begin select * bulk collect into l_actual - from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 123456789 ) ); + from table ( ut3_develop.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 123456789 ) ); ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_actual) ).to_be_like( q'[%Tests were executed with random order seed '123456789'.%]' ); end; procedure run_with_random_order_seed is - l_expected ut3.ut_varchar2_list; - l_actual ut3.ut_varchar2_list; + l_expected ut3_develop.ut_varchar2_list; + l_actual ut3_develop.ut_varchar2_list; begin select * bulk collect into l_expected - from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ); + from table ( ut3_develop.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ); select * bulk collect into l_actual - from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ); + from table ( ut3_develop.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ); remove_time_from_results(l_actual); remove_time_from_results(l_expected); @@ -827,6 +935,38 @@ Failures:% ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; + + procedure run_proc_prints_support_info is + begin + ut3_develop.ut.run('ut3_tester_helper.test_package_1'); + + ut.expect( ut3_tester_helper.main_helper.get_dbms_output_as_clob() ).to_be_like( '%' || reporters.gc_support_line || '%' ); + end; + + procedure run_proc_omits_support_info is + begin + ut3_develop.ut.run('ut3_tester_helper.test_package_1', a_support_info => false); + + ut.expect( ut3_tester_helper.main_helper.get_dbms_output_as_clob() ).not_to_be_like( '%' || reporters.gc_support_line || '%' ); + end; + + procedure run_func_prints_support_info is + l_results ut3_develop.ut_varchar2_list; + begin + select * bulk collect into l_results + from table ( ut3_develop.ut.run('ut3_tester_helper.test_package_1') ); + + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%' || reporters.gc_support_line || '%' ); + end; + + procedure run_func_omits_support_info is + l_results ut3_develop.ut_varchar2_list; + begin + select * bulk collect into l_results + from table ( ut3_develop.ut.run('ut3_tester_helper.test_package_1', a_support_info => 0) ); + + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%' || reporters.gc_support_line || '%' ); + end; procedure test_run_by_one_tag is l_results clob; @@ -879,7 +1019,7 @@ Failures:% procedure two_test_run_by_two_tags is l_results clob; begin - ut3_tester_helper.run_helper.run(a_tags => 'subtest1,subtest2'); + ut3_tester_helper.run_helper.run(a_tags => 'subtest1|subtest2'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%test_package_1%' ); @@ -889,7 +1029,21 @@ Failures:% ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); end; - + + procedure two_test_run_by_two_tags_leg is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'subtest1,subtest2'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_1.test2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2.test2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + procedure suite_with_children_tag is l_results clob; begin @@ -948,7 +1102,7 @@ Failures:% procedure run_proc_pkg_name_tag is l_results clob; begin - ut3.ut.run('ut3_tester_helper.test_package_1',a_tags => 'suite1test1'); + ut3_develop.ut.run('ut3_tester_helper.test_package_1',a_tags => 'suite1test1'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%test_package_1%' ); @@ -961,7 +1115,7 @@ Failures:% procedure run_pkg_name_file_list_tag is l_results clob; begin - ut3.ut.run('ut3_tester_helper.test_package_1',a_tags => 'suite1test1'); + ut3_develop.ut.run('ut3_tester_helper.test_package_1',a_tags => 'suite1test1'); l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); --Assert ut.expect( l_results ).to_be_like( '%test_package_1%' ); @@ -974,10 +1128,10 @@ Failures:% procedure run_proc_path_list_tag is l_results clob; begin - ut3.ut.run( + ut3_develop.ut.run( 'ut3_tester_helper.test_package_1', - ut3.ut_sonar_test_reporter(), a_source_files => ut3.ut_varchar2_list(),a_tags => 'suite1', - a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + ut3_develop.ut_sonar_test_reporter(), a_source_files => ut3_develop.ut_varchar2_list(),a_tags => 'suite1', + a_test_files => ut3_develop.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', 'tests/ut3_tester_helper.test_package_2.pkb', 'tests/ut3_tester_helper.test_package_3.pkb') ); @@ -989,7 +1143,7 @@ Failures:% end; procedure tag_run_func_no_params is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin l_results := ut3_tester_helper.run_helper.run(a_tags => 'helper'); --Assert @@ -997,9 +1151,9 @@ Failures:% end; procedure tag_run_func_pkg_name is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_results from table (ut3.ut.run('ut3_tester_helper.test_package_1', a_tags => 'suite1test1')); + select * bulk collect into l_results from table (ut3_develop.ut.run('ut3_tester_helper.test_package_1', a_tags => 'suite1test1')); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); @@ -1008,9 +1162,23 @@ Failures:% end; procedure tag_run_func_path_list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => 'suite1test1|suite2test1'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure tag_run_func_path_list_leg is + l_results ut3_develop.ut_varchar2_list; begin - l_results := ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => 'suite1test1,suite2test1'); + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => 'suite1test1,suite2test1'); --Assert ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); @@ -1021,6 +1189,263 @@ Failures:% ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); end; + procedure tag_inc_exc_run_func_path_list is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => '(suite1test1|suite2test1)&!suite2'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure tag_inc_exc_run_fun_pth_lst_lg is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => 'suite1test1,suite2test1,-suite2'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure tag_exclude_run_func_path_list is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2'),a_tags => '!suite1test2&!suite2test1&!test1suite3'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_3%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_3.test2%executed%' ); + end; + +procedure tag_exclude_run_fun_pth_lst_lg is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2'),a_tags => '-suite1test2,-suite2test1,-test1suite3'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_3%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_3.test2%executed%' ); + end; + + procedure tag_include_exclude_run_func is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(a_tags => '(suite1)&(!suite1test2&!suite2test1&!test1suite3)'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test2%executed%' ); + end; + + procedure tag_include_exclude_run_fun_lg is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(a_tags => 'suite1,-suite1test2,-suite2test1,-test1suite3'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test2%executed%' ); + end; + + procedure tag_complex_expressions is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(a_tags => 'release_3_1_13&(fast|simple)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test6 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test3%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); + + l_results := ut3_tester_helper.run_helper.run(a_tags => 'release_3_1_13&(!patch_3_1_13&!patch_3_1_14)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test3%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test5%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test6%executed%' ); + + l_results := ut3_tester_helper.run_helper.run(a_tags => 'release_3_1_13&(patch_3_1_13&!slow)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test3%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test6%executed%' ); + + l_results := ut3_tester_helper.run_helper.run(a_tags => '(simple&end_to_end)|(development&fast)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_2.test3 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test6 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); + + l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&end_to_end)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test3%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test6%executed%' ); + + l_results := ut3_tester_helper.run_helper.run(a_tags => 'any'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_level1_pkg.test1_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_level1_pkg.test2_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_level1_pkg.test1_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_2_level2_pkg.suite2_2_test1_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_2_level2_pkg.suite2_2_test2_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_2_level2_pkg.suite1_2_test1_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_2_level2_pkg.suite1_2_test2_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_1_level2_pkg.suite1_1_test1_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_level1_pkg.test2_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_1_level2_pkg.suite1_1_test2_level2 executed%' ); + + l_results := ut3_tester_helper.run_helper.run(a_tags => 'none'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_level1_pkg.test2_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_1_level2_pkg.suite1_1_test2_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_level1_pkg.test1_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_level1_pkg.test2_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_level1_pkg.test1_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_2_level2_pkg.suite2_2_test1_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_2_level2_pkg.suite2_2_test2_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_2_level2_pkg.suite1_2_test1_level2 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_2_level2_pkg.suite1_2_test2_level1 executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_1_level2_pkg.suite1_1_test1_level2 executed%' ); + + + end; + + procedure invalid_tag_expression is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development!&end_to_end)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + + l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&&end_to_end)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + + l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&end_to_end|)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + + l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&!!end_to_end)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + + l_results := ut3_tester_helper.run_helper.run(a_tags => '(&development&end_to_end)'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + + l_results := ut3_tester_helper.run_helper.run(a_tags => '(development|end_to_end))'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + + end; + + procedure invalid_tag_expression_no_tests is + l_results ut3_develop.ut_varchar2_list; + begin + --the package does not exist, so no test is there to evaluate the tag expression on + l_results := ut3_tester_helper.run_helper.run('ut3_tester_helper.no_such_test_package', a_tags => '(development|end_to_end))'); + end; + + procedure tag_run_pkg_wildcard is + l_results clob; + begin + --test_tag_pkg_3 has no test tagged fast + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run('ut3_tester_helper.test_tag_pkg_*', a_tags => 'fast') + ); + --Assert + ut.expect( l_results ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( l_results ).to_be_like( '%test_tag_pkg_2.test3 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_1.test2 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_2.test4 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_3%' ); + end; + + procedure tag_run_proc_wildcard is + l_results clob; + begin + --test_tag_pkg_1.test2 is not tagged fast + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run('ut3_tester_helper.test_tag_pkg_1.test*', a_tags => 'fast') + ); + --Assert + ut.expect( l_results ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_1.test2 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_3%' ); + end; + + procedure tag_run_suitepath_wildcard is + l_results clob; + begin + --suitepath suite3 (test_tag_pkg_3) has no test tagged fast + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run('ut3_tester_helper:suite*', a_tags => 'fast') + ); + --Assert + ut.expect( l_results ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( l_results ).to_be_like( '%test_tag_pkg_2.test3 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_1.test2 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_2.test4 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_3%' ); + end; + + procedure tag_run_wildcard_none_left is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run('ut3_tester_helper.test_tag_pkg_*', a_tags => 'nonexisting'); + ut.fail('Expected exception ORA-20204 was not raised'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%ORA-20204: Suite package ut3_tester_helper.test_tag_pkg_* does not exist%'); + end; + + procedure blank_tags_run_all_tests is + l_expected ut3_develop.ut_varchar2_list; + l_actual ut3_develop.ut_varchar2_list; + begin + l_expected := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2')); + l_actual := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2'), a_tags => ' '||chr(9)||' '); + + remove_time_from_results(l_expected); + remove_time_from_results(l_actual); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_actual) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( anydata.convertCollection(l_actual) ).to_equal( anydata.convertCollection(l_expected) ); + end; + procedure set_application_info is begin dbms_application_info.set_module( gc_module, gc_action ); @@ -1038,9 +1463,8 @@ Failures:% --%beforeall procedure before_suite; - --%context(some_context) - - --%displayname(context description) + --%context(context description) + --%name(some_context) --%beforeall procedure before_context; @@ -1079,7 +1503,7 @@ Failures:% begin select attribute||'='||value bulk collect into l_results - from session_context where namespace = 'UT3_INFO' + from session_context where namespace = 'UT3_DEVELOP_INFO' order by attribute; for i in 1 .. l_results.count loop dbms_output.put_line( upper(a_procedure_name) ||':'|| l_results(i) ); @@ -1147,23 +1571,25 @@ Failures:% end; procedure run_context_test_suite is - l_lines ut3.ut_varchar2_list; + l_lines ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_lines from table(ut3.ut.run('check_context')); + select * bulk collect into l_lines from table(ut3_develop.ut.run('check_context')); g_context_test_results := ut3_tester_helper.main_helper.table_to_clob(l_lines); + g_timestamp := current_timestamp; end; procedure sys_ctx_on_suite_beforeall is begin ut.expect(g_context_test_results).to_be_like( - '%BEFORE_SUITE:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_suite' + '%BEFORE_SUITE:COVERAGE_RUN_ID=________________________________%' + ||'%BEFORE_SUITE:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_suite' ||'%BEFORE_SUITE:CURRENT_EXECUTABLE_TYPE=beforeall' ||'%BEFORE_SUITE:RUN_PATHS=check_context' ||'%BEFORE_SUITE:SUITE_DESCRIPTION=Suite description' ||'%BEFORE_SUITE:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%BEFORE_SUITE:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_SUITE:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_SUITE:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=before_suite%' @@ -1178,14 +1604,14 @@ Failures:% '%BEFORE_CONTEXT:CONTEXT_DESCRIPTION=context description' ||'%BEFORE_CONTEXT:CONTEXT_NAME=some_context' ||'%BEFORE_CONTEXT:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%BEFORE_CONTEXT:CONTEXT_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_CONTEXT:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%BEFORE_CONTEXT:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_context' ||'%BEFORE_CONTEXT:CURRENT_EXECUTABLE_TYPE=beforeall' ||'%BEFORE_CONTEXT:RUN_PATHS=check_context' ||'%BEFORE_CONTEXT:SUITE_DESCRIPTION=Suite description' ||'%BEFORE_CONTEXT:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%BEFORE_CONTEXT:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_CONTEXT:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_CONTEXT:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=before_context%' @@ -1199,17 +1625,17 @@ Failures:% '%BEFORE_EACH_TEST:CONTEXT_DESCRIPTION=context description' ||'%BEFORE_EACH_TEST:CONTEXT_NAME=some_context' ||'%BEFORE_EACH_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%BEFORE_EACH_TEST:CONTEXT_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_EACH_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%BEFORE_EACH_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_each_test' ||'%BEFORE_EACH_TEST:CURRENT_EXECUTABLE_TYPE=beforeeach' ||'%BEFORE_EACH_TEST:RUN_PATHS=check_context' ||'%BEFORE_EACH_TEST:SUITE_DESCRIPTION=Suite description' ||'%BEFORE_EACH_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%BEFORE_EACH_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_EACH_TEST:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_EACH_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%BEFORE_EACH_TEST:TEST_DESCRIPTION=Some test description' ||'%BEFORE_EACH_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%BEFORE_EACH_TEST:TEST_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_EACH_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=before_each_test%' @@ -1222,17 +1648,17 @@ Failures:% '%BEFORE_TEST:CONTEXT_DESCRIPTION=context description' ||'%BEFORE_TEST:CONTEXT_NAME=some_context' ||'%BEFORE_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%BEFORE_TEST:CONTEXT_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%BEFORE_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_test' ||'%BEFORE_TEST:CURRENT_EXECUTABLE_TYPE=beforetest' ||'%BEFORE_TEST:RUN_PATHS=check_context' ||'%BEFORE_TEST:SUITE_DESCRIPTION=Suite description' ||'%BEFORE_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%BEFORE_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_TEST:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%BEFORE_TEST:TEST_DESCRIPTION=Some test description' ||'%BEFORE_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%BEFORE_TEST:TEST_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%BEFORE_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=before_test%' @@ -1245,17 +1671,17 @@ Failures:% '%THE_TEST:CONTEXT_DESCRIPTION=context description' ||'%THE_TEST:CONTEXT_NAME=some_context' ||'%THE_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%THE_TEST:CONTEXT_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%THE_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%THE_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.the_test' ||'%THE_TEST:CURRENT_EXECUTABLE_TYPE=test' ||'%THE_TEST:RUN_PATHS=check_context' ||'%THE_TEST:SUITE_DESCRIPTION=Suite description' ||'%THE_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%THE_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%THE_TEST:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%THE_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%THE_TEST:TEST_DESCRIPTION=Some test description' ||'%THE_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%THE_TEST:TEST_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%THE_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=the_test%' @@ -1268,17 +1694,17 @@ Failures:% '%AFTER_TEST:CONTEXT_DESCRIPTION=context description' ||'%AFTER_TEST:CONTEXT_NAME=some_context' ||'%AFTER_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%AFTER_TEST:CONTEXT_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%AFTER_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.after_test' ||'%AFTER_TEST:CURRENT_EXECUTABLE_TYPE=aftertest' ||'%AFTER_TEST:RUN_PATHS=check_context' ||'%AFTER_TEST:SUITE_DESCRIPTION=Suite description' ||'%AFTER_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%AFTER_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_TEST:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%AFTER_TEST:TEST_DESCRIPTION=Some test description' ||'%AFTER_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%AFTER_TEST:TEST_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=after_test%' @@ -1291,17 +1717,17 @@ Failures:% '%AFTER_EACH_TEST:CONTEXT_DESCRIPTION=context description' ||'%AFTER_EACH_TEST:CONTEXT_NAME=some_context' ||'%AFTER_EACH_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%AFTER_EACH_TEST:CONTEXT_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_EACH_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%AFTER_EACH_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.after_each_test' ||'%AFTER_EACH_TEST:CURRENT_EXECUTABLE_TYPE=aftereach' ||'%AFTER_EACH_TEST:RUN_PATHS=check_context' ||'%AFTER_EACH_TEST:SUITE_DESCRIPTION=Suite description' ||'%AFTER_EACH_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%AFTER_EACH_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_EACH_TEST:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_EACH_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%AFTER_EACH_TEST:TEST_DESCRIPTION=Some test description' ||'%AFTER_EACH_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%AFTER_EACH_TEST:TEST_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_EACH_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=after_each_test%' @@ -1314,14 +1740,14 @@ Failures:% '%AFTER_CONTEXT:CONTEXT_DESCRIPTION=context description' ||'%AFTER_CONTEXT:CONTEXT_NAME=some_context' ||'%AFTER_CONTEXT:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%AFTER_CONTEXT:CONTEXT_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_CONTEXT:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%AFTER_CONTEXT:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.after_context' ||'%AFTER_CONTEXT:CURRENT_EXECUTABLE_TYPE=afterall' ||'%AFTER_CONTEXT:RUN_PATHS=check_context' ||'%AFTER_CONTEXT:SUITE_DESCRIPTION=Suite description' ||'%AFTER_CONTEXT:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%AFTER_CONTEXT:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_CONTEXT:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_CONTEXT:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=after_context%' @@ -1338,7 +1764,7 @@ Failures:% ||'%AFTER_SUITE:SUITE_DESCRIPTION=Suite description' ||'%AFTER_SUITE:SUITE_PACKAGE='||gc_owner||'.check_context' ||'%AFTER_SUITE:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_SUITE:SUITE_START_TIME='||to_char(current_timestamp,'yyyy-mm-dd"T"hh24:mi') + ||'%AFTER_SUITE:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') ||'%APPLICATION_INFO:MODULE=utPLSQL' ||'%APPLICATION_INFO:ACTION=check_context' ||'%APPLICATION_INFO:CLIENT_INFO=after_suite%' @@ -1352,7 +1778,7 @@ Failures:% begin open l_actual for select attribute||'='||value - from session_context where namespace = 'UT3_INFO'; + from session_context where namespace = 'UT3_DEVELOP_INFO'; ut.expect(l_actual).to_be_empty(); end; diff --git a/test/ut3_user/api/test_ut_run.pks b/test/ut3_user/api/test_ut_run.pks index 38a6eee2c..552c5dbf3 100644 --- a/test/ut3_user/api/test_ut_run.pks +++ b/test/ut3_user/api/test_ut_run.pks @@ -4,8 +4,8 @@ create or replace package test_ut_run is procedure clear_expectations; - procedure create_ut3$user#_tests; - procedure drop_ut3$user#_tests; + procedure create_ut3_user_tests; + procedure drop_ut3_user_tests; --%test(ut.version() returns version of the framework) procedure ut_version; @@ -17,8 +17,8 @@ create or replace package test_ut_run is --%context(ut_run_procedure) --%displayname(ut.run() procedure options) - --%beforeall(create_ut3$user#_tests) - --%afterall(drop_ut3$user#_tests) + --%beforeall(create_ut3_user_tests) + --%afterall(drop_ut3_user_tests) --%test(Runs all tests in current schema with default reporter when no parameters given) procedure run_proc_no_params; @@ -88,8 +88,8 @@ create or replace package test_ut_run is --%context(ut_run_function) --%displayname(ut.run() function options) - --%beforeall(create_ut3$user#_tests) - --%afterall(drop_ut3$user#_tests) + --%beforeall(create_ut3_user_tests) + --%afterall(drop_ut3_user_tests) --%test(Runs all tests in current schema with default reporter when no parameters given) procedure run_func_no_params; @@ -155,13 +155,20 @@ create or replace package test_ut_run is procedure create_schema_name_package; procedure drop_schema_name_package; + --%test(Runs properly formed suite hierarchy regardless of NLS_SORT settings - Issue #1060) + --%beforetest(create_suites_with_path) + --%aftertest(drop_suites_with_path) + procedure run_suite_with_nls_sort; + procedure create_suites_with_path; + procedure drop_suites_with_path; + --%endcontext --%context(random_order) --%displayname(Random test execution order) - --%beforeall(create_ut3$user#_tests) - --%afterall(drop_ut3$user#_tests) + --%beforeall(create_ut3_user_tests) + --%afterall(drop_ut3_user_tests) --%test(Runs tests in random order) procedure run_with_random_order; @@ -174,60 +181,143 @@ create or replace package test_ut_run is --%endcontext + --%context(support_info) + + --%displayname(Support line) + --%beforeall(create_ut3_user_tests) + --%afterall(drop_ut3_user_tests) + + --%test(ut.run() procedure prints support line by default) + procedure run_proc_prints_support_info; + + --%test(ut.run() procedure omits support line when a_support_info is false) + procedure run_proc_omits_support_info; + + --%test(ut.run() function prints support line by default) + procedure run_func_prints_support_info; + + --%test(ut.run() function omits support line when a_support_info is 0) + procedure run_func_omits_support_info; + + --%endcontext + + --%context(run with paths in several schemas) + + --%beforeall(create_ut3_user_tests, create_test_suite_in_ut3_user) + --%afterall(drop_test_suite_in_ut3_user, drop_ut3_user_tests) + + --%test(Runs the suites of each schema together, in order of schema names) + procedure run_groups_suites_by_schema; + + --%endcontext + + procedure create_test_suite_in_ut3_user; + procedure drop_test_suite_in_ut3_user; + --%context(run with tags) - --%displayname(Call ut.run with #tags) - --%beforeall(create_ut3$user#_tests) - --%afterall(drop_ut3$user#_tests) - - --%test(Execute test by tag ut_run) - procedure test_run_by_one_tag; - - --%test( Execute suite by one tag) - procedure suite_run_by_one_tag; - - --%test(Execute two tests by one tag) - procedure two_test_run_by_one_tag; - - --%test(Execute all suites tests with tag) - procedure all_suites_run_by_one_tag; - - --%test(Execute tests by passing two tags) - procedure two_test_run_by_two_tags; - - --%test(Execute suite and all of its children) - procedure suite_with_children_tag; - - --%test(Execute suite and parents) - procedure suite_with_tag_parent; - - --%test(Execute test for non existing tag) - procedure test_nonexists_tag; - - --%test(Execute test for duplicate list tags) - procedure test_duplicate_tag; - - --%test(Execute suite test for duplicate list tags) - procedure suite_duplicate_tag; - --%test(Runs given package only with package name given as path and filter by tag) - procedure run_proc_pkg_name_tag; - - --%test(Runs all from given package with package name given as path and coverage file list with tag) - procedure run_pkg_name_file_list_tag; - - --%test(Runs tests from given paths with paths list and tag) - procedure run_proc_path_list_tag; - - --%test(Runs all tests in current schema with default reporter when only tag is given) - procedure tag_run_func_no_params; + --%beforeall(create_ut3_user_tests) + --%afterall(drop_ut3_user_tests) + + --%test(Execute test by tag ut_run) + procedure test_run_by_one_tag; + + --%test( Execute suite by one tag) + procedure suite_run_by_one_tag; + + --%test(Execute two tests by one tag) + procedure two_test_run_by_one_tag; + + --%test(Execute all suites tests with tag) + procedure all_suites_run_by_one_tag; + + --%test(Execute tests by passing two tags) + procedure two_test_run_by_two_tags; + + --%test(Execute tests by passing two tags - Legacy notation) + procedure two_test_run_by_two_tags_leg; + + --%test(Execute suite and all of its children) + procedure suite_with_children_tag; + + --%test(Execute suite and parents) + procedure suite_with_tag_parent; + + --%test(Execute test for non existing tag) + procedure test_nonexists_tag; + + --%test(Execute test for duplicate list tags) + procedure test_duplicate_tag; + + --%test(Execute suite test for duplicate list tags) + procedure suite_duplicate_tag; + + --%test(Runs given package only with package name given as path and filter by tag) + procedure run_proc_pkg_name_tag; + + --%test(Runs all from given package with package name given as path and coverage file list with tag) + procedure run_pkg_name_file_list_tag; + + --%test(Runs tests from given paths with paths list and tag) + procedure run_proc_path_list_tag; + + --%test(Runs all tests in current schema with default reporter when only tag is given) + procedure tag_run_func_no_params; + + --%test(Runs given package only with package name given as path and filter by tag) + procedure tag_run_func_pkg_name; + + --%test(Runs tests from given paths with paths list and a tag) + procedure tag_run_func_path_list; + + --%test(Runs tests from given paths with paths list and a tag - Legacy Notation) + procedure tag_run_func_path_list_leg; + + --%test(Runs tests from given paths with paths list and include/exclude tags) + procedure tag_inc_exc_run_func_path_list; + + --%test(Runs tests from given paths with paths list and include/exclude tags - Legacy Notation) + procedure tag_inc_exc_run_fun_pth_lst_lg; + + --%test(Runs tests from given path and excludes specific tags) + procedure tag_exclude_run_func_path_list; + + --%test(Runs tests from given path and excludes specific tags - Legacy Notation) + procedure tag_exclude_run_fun_pth_lst_lg; + + --%test(Runs tests from given tags and exclude tags) + procedure tag_include_exclude_run_func; + + --%test(Runs tests from given tags and exclude tags - Legacy Notation) + procedure tag_include_exclude_run_fun_lg; + + --%test(Runs tests suing complex expressions) + procedure tag_complex_expressions; + + --%test(Testing invalid tag expression) + --%throws(-20219) + procedure invalid_tag_expression; + + --%test(Raises an error for an invalid tag expression when the path selects no tests) + --%throws(-20219) + procedure invalid_tag_expression_no_tests; + + --%test(Runs tests matching the tags from packages selected by a wildcard, skipping packages without such tests) + procedure tag_run_pkg_wildcard; + + --%test(Runs tests matching the tags from tests selected by a wildcard, skipping the other tests) + procedure tag_run_proc_wildcard; + + --%test(Runs tests matching the tags from suitepaths selected by a wildcard, skipping suites without such tests) + procedure tag_run_suitepath_wildcard; + + --%test(Raises an error naming the wildcard path when the tags exclude all tests it selects) + procedure tag_run_wildcard_none_left; - --%test(Runs given package only with package name given as path and filter by tag) - procedure tag_run_func_pkg_name; + --%test(Runs the same tests as without tags when the tag expression is made of spaces and tabs) + procedure blank_tags_run_all_tests; - --%test(Runs tests from given paths with paths list and a tag) - procedure tag_run_func_path_list; - --%endcontext --%context(ut3_info context) diff --git a/test/ut3_user/api/test_ut_runner.pkb b/test/ut3_user/api/test_ut_runner.pkb index e29bada11..9ef709e91 100644 --- a/test/ut3_user/api/test_ut_runner.pkb +++ b/test/ut3_user/api/test_ut_runner.pkb @@ -25,6 +25,11 @@ create or replace package body test_ut_runner is ut3_tester_helper.run_helper.cleanup_cache(); end; + procedure setup_cache_context_disabled is + begin + ut3_tester_helper.run_helper.setup_cache_context_disabled(); + end; + procedure create_test_spec as pragma autonomous_transaction; @@ -45,7 +50,7 @@ end; execute immediate 'create or replace package body test_cache as procedure failing_test is begin - ut3.ut.expect('||a_number||').to_be_null; + ut3_develop.ut.expect('||a_number||').to_be_null; end; end;'; end; @@ -69,7 +74,7 @@ end;'; create_test_body(0); l_expected := dbms_transaction.local_transaction_id(true); --Act - ut3.ut.run('test_cache'); + ut3_develop.ut.run('test_cache'); dbms_output.get_lines( l_output_data, l_num_lines); --Assert ut.expect(dbms_transaction.local_transaction_id()).to_equal(l_expected); @@ -86,7 +91,7 @@ end;'; create_test_body(0); rollback; --Act - ut3.ut.run('test_cache'); + ut3_develop.ut.run('test_cache'); dbms_output.get_lines( l_output_data, l_num_lines); --Assert ut.expect(dbms_transaction.local_transaction_id()).to_be_null(); @@ -95,35 +100,35 @@ end;'; procedure version_comp_check_compare is begin - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.0.0') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.123.0') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.0','v3.123.0.0') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.0','v3.13.31.0') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.1.0','v3.0.0.0') ).to_equal(0); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.1.0.0','v3.0.0.0') ).to_equal(0); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.0','v2.0.0.0') ).to_equal(0); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.0','v4.0.0.0') ).to_equal(0); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.0.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.123.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.123.0.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.13.31.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.1.0','v3.0.0.0') ).to_equal(0); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.1.0.0','v3.0.0.0') ).to_equal(0); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v2.0.0.0') ).to_equal(0); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v4.0.0.0') ).to_equal(0); end; procedure version_comp_check_ignore is begin - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.123','v3.0.0.0') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.0.123') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0','v3.0.0.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.123','v3.0.0.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.0.123') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0','v3.0.0.0') ).to_equal(1); end; procedure version_comp_check_short is begin - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0.0','v3.0.0.0') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3.0','v3.0.123.0') ).to_equal(1); - ut.expect( ut3.ut_runner.version_compatibility_check('v3','v3.123.0.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0','v3.0.0.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0','v3.0.123.0') ).to_equal(1); + ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3','v3.123.0.0') ).to_equal(1); end; procedure version_comp_check_exception is procedure throws(a_requested varchar2, a_current varchar2) is l_compatible integer; begin - l_compatible := ut3.ut_runner.version_compatibility_check(a_requested,a_current); + l_compatible := ut3_develop.ut_runner.version_compatibility_check(a_requested,a_current); ut.fail('Expected exception but nothing was raised'); exception when others then @@ -135,7 +140,7 @@ end;'; end; procedure run_reset_package_body_cache is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_expected clob; l_actual clob; begin @@ -144,16 +149,16 @@ end;'; create_test_body(0); select * bulk collect into l_results - from table(ut3.ut.run('test_cache')); + from table(ut3_develop.ut.run('test_cache')); --Act create_test_body(1); select * bulk collect into l_results - from table(ut3.ut.run('test_cache')); + from table(ut3_develop.ut.run('test_cache')); --Assert l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - l_expected := '%ut3.ut.expect(1).to_be_null;%'; + l_expected := '%ut3_develop.ut.expect(1).to_be_null;%'; ut.expect(l_actual).to_be_like(l_expected); drop_test_package(); end; @@ -161,7 +166,7 @@ end;'; procedure run_keep_dbms_output_buffer is l_expected dbmsoutput_linesarray; l_actual dbmsoutput_linesarray; - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_lines number := 10000; begin --Arrange @@ -185,7 +190,7 @@ end;'; --Act select * bulk collect into l_results - from table(ut3.ut.run('test_cache')); + from table(ut3_develop.ut.run('test_cache')); --Assert dbms_output.get_lines(lines => l_actual, numlines => l_lines); @@ -207,7 +212,7 @@ end;'; ut.expect(l_actual).not_to_be_empty(); --Act - ut3.ut_runner.purge_cache(sys_context('USERENV', 'CURRENT_USER'),'PROCEDURE'); + ut3_develop.ut_runner.purge_cache(sys_context('USERENV', 'CURRENT_USER'),'PROCEDURE'); --Assert @@ -238,7 +243,7 @@ end;'; l_actual sys_refcursor; begin --Act - ut3.ut_runner.rebuild_annotation_cache( sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE' ); + ut3_develop.ut_runner.rebuild_annotation_cache( sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE' ); --Assert l_actual := ut3_tester_helper.run_helper.get_annotation_cache_cursor( a_owner => sys_context('USERENV', 'CURRENT_USER'), @@ -254,7 +259,7 @@ end;'; a_type => 'PACKAGE' ); - --Did not rebuild cache for ut3/procedures + --Did not rebuild cache for ut3_develop/procedures ut.expect(l_actual).to_have_count(0); end; @@ -265,27 +270,27 @@ end;'; --Arrange open l_expected for select - 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, - 'some.path.dummy_test_package' path, 0 disabled_flag,null tags + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,null tags from dual union all select - 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, - 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,null tags + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,null tags from dual union all select - 'UT3$USER#' object_owner, 'PATH' object_name, 'PATH' item_name, + 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some.path' path, 0 disabled_flag, null tags + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags from dual union all select - 'UT3$USER#' object_owner, 'SOME' object_name, 'SOME' item_name, + 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some' path, 0 disabled_flag, null tags + 'some' path, 0 disabled_flag, null disabled_reason, null tags from dual; --Act - open l_actual for select * from table(ut3.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3_USER','DUMMY_TEST_PACKAGE')); --Assert ut.expect(l_actual).to_equal(l_expected); end; @@ -297,27 +302,27 @@ end;'; --Arrange open l_expected for select - 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, - 'some.path.dummy_test_package' path, 0 disabled_flag,'dummy' tags + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,'dummy' tags from dual union all select - 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, 'dummy_test' item_description, 'UT_TEST' item_type, 7 item_line_no, - 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,'testtag' tags + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,'testtag' tags from dual union all select - 'UT3$USER#' object_owner, 'PATH' object_name, 'PATH' item_name, + 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some.path' path, 0 disabled_flag, null tags + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags from dual union all select - 'UT3$USER#' object_owner, 'SOME' object_name, 'SOME' item_name, + 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some' path, 0 disabled_flag, null tags + 'some' path, 0 disabled_flag, null disabled_reason, null tags from dual; --Act - open l_actual for select * from table(ut3.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3_USER','DUMMY_TEST_PACKAGE')); --Assert ut.expect(l_actual).to_equal(l_expected); end; @@ -329,17 +334,123 @@ end;'; --Arrange open l_expected for select - 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, + 'dummy_test_package' path, 0 disabled_flag, null disabled_reason,'suitetag1,suitetag2' tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, + 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,'testtag1,testtag2' tags + from dual; + --Act + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3_USER','DUMMY_TEST_PACKAGE')); + --Assert + ut.expect(l_actual).to_equal(l_expected); + end; + + procedure test_get_suites_info_by_path is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + --Arrange + open l_expected for + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,null tags + from dual union all + select + 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some' path, 0 disabled_flag, null disabled_reason, null tags + from dual; + --Act + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('ut3_user:some.path.dummy_test_package')); + --Assert + ut.expect(l_actual).to_equal(l_expected); + end; + + procedure test_get_suites_info_context is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + --Arrange + open l_expected for + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'dummy_test' item_description, 'UT_TEST' item_type, 5 item_line_no, + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'NESTED_CONTEXT_#1' item_name, + 'dummy_context' item_description, 'UT_SUITE_CONTEXT' item_type, 8 item_line_no, + 'some.path.dummy_test_package.nested_context_#1' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DISABLED_TEST_PROCEDURE' item_name, + 'disabled_test' item_description, 'UT_TEST' item_type, 10 item_line_no, + 'some.path.dummy_test_package.nested_context_#1.disabled_test_procedure' path, 1 disabled_flag, 'not ready' disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some' path, 0 disabled_flag, null disabled_reason, null tags + from dual; + --Act + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3_USER','DUMMY_TEST_PACKAGE')); + --Assert + ut.expect(l_actual).to_equal(l_expected); + end; + + procedure test_get_suites_info_by_proc is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + --Arrange + open l_expected for + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, - 'dummy_test_package' path, 0 disabled_flag,'suitetag1,suitetag2' tags + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason, null tags from dual union all select - 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, - 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,'testtag1,testtag2' tags + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some' path, 0 disabled_flag, null disabled_reason, null tags from dual; --Act - open l_actual for select * from table(ut3.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('ut3_user.dummy_test_package.some_dummy_test_procedure')); --Assert ut.expect(l_actual).to_equal(l_expected); end; @@ -350,21 +461,21 @@ end;'; begin --Arrange open l_expected for - select 'UT3.UT_COVERAGE_COBERTURA_REPORTER' reporter_object_name, 'Y' is_output_reporter from dual union all - select 'UT3.UT_DEBUG_REPORTER', 'Y' from dual union all - select 'UT3.UT_COVERAGE_HTML_REPORTER', 'Y' from dual union all - select 'UT3.UT_COVERAGE_SONAR_REPORTER', 'Y' from dual union all - select 'UT3.UT_COVERALLS_REPORTER', 'Y' from dual union all - select 'UT3.UT_DOCUMENTATION_REPORTER', 'Y' from dual union all - select 'UT3.UT_JUNIT_REPORTER', 'Y' from dual union all - select 'UT3.UT_REALTIME_REPORTER', 'Y' from dual union all - select 'UT3.UT_SONAR_TEST_REPORTER', 'Y' from dual union all - select 'UT3.UT_TEAMCITY_REPORTER', 'Y' from dual union all - select 'UT3.UT_TFS_JUNIT_REPORTER', 'Y' from dual union all - select 'UT3.UT_XUNIT_REPORTER', 'Y' from dual + select 'UT3_DEVELOP.UT_COVERAGE_COBERTURA_REPORTER' reporter_object_name, 'Y' is_output_reporter from dual union all + select 'UT3_DEVELOP.UT_DEBUG_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_COVERAGE_HTML_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_COVERAGE_SONAR_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_DOCUMENTATION_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_JUNIT_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_REALTIME_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_SONAR_TEST_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_TEAMCITY_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_TFS_JUNIT_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_XUNIT_REPORTER', 'Y' from dual union all + select 'UT3_DEVELOP.UT_TAP_REPORTER', 'Y' from dual order by 1; --Act - open l_actual for select * from table(ut3.ut_runner.GET_REPORTERS_LIST()) order by 1; + open l_actual for select * from table(ut3_develop.ut_runner.GET_REPORTERS_LIST()) order by 1; --Assert ut.expect(l_actual).to_equal(l_expected); end; @@ -382,13 +493,13 @@ end;'; end; procedure raises_20213_on_fail_link is - l_reporter ut3.ut_documentation_reporter := ut3.ut_documentation_reporter(); - l_lines ut3.ut_varchar2_list; + l_reporter ut3_develop.ut_documentation_reporter := ut3_develop.ut_documentation_reporter(); + l_lines ut3_develop.ut_varchar2_list; pragma autonomous_transaction; begin --Arrange --Act - ut3.ut_runner.run(ut3.ut_varchar2_list('test_db_link'), ut3.ut_reporters(l_reporter), a_fail_on_errors=> true); + ut3_develop.ut_runner.run(ut3_develop.ut_varchar2_list('test_db_link'), ut3_develop.ut_reporters(l_reporter), a_fail_on_errors=> true); ut.fail('Expected exception but nothing was raised'); exception when others then @@ -419,12 +530,12 @@ end;'; procedure one_is_one is begin - ut3.ut.expect(1).to_equal(1); + ut3_develop.ut.expect(1).to_equal(1); end; procedure two_is_two is begin - ut3.ut.expect(2).to_equal(2); + ut3_develop.ut.expect(2).to_equal(2); end; end; @@ -449,12 +560,12 @@ end;'; procedure one_is_one is begin - ut3.ut.expect(1).to_equal(1); + ut3_develop.ut.expect(1).to_equal(1); end; procedure two_is_two is begin - ut3.ut.expect(2).to_equal(2); + ut3_develop.ut.expect(2).to_equal(2); end; end; @@ -470,12 +581,12 @@ end;'; end; procedure pass_varchar2_name_list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin select * bulk collect into l_results - from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2'))); + from table(ut3_develop.ut.run(ut3_develop.ut_varchar2_list('test_csl_names1','test_csl_names2'))); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds @@ -483,12 +594,12 @@ end;'; end; procedure pass_varchar2_name is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin select * bulk collect into l_results - from table(ut3.ut.run('test_csl_names1')); + from table(ut3_develop.ut.run('test_csl_names1')); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds @@ -496,12 +607,12 @@ end;'; end; procedure pass_varchar2_suite_csl is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin select * bulk collect into l_results - from table(ut3.ut.run('test_csl_names1,test_csl_names2')); + from table(ut3_develop.ut.run('test_csl_names1,test_csl_names2')); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds @@ -509,12 +620,12 @@ end;'; end; procedure pass_varchar2_test_csl is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin select * bulk collect into l_results - from table(ut3.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one')); + from table(ut3_develop.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one')); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds @@ -522,12 +633,12 @@ end;'; end; procedure pass_varch_test_csl_spc is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin select * bulk collect into l_results - from table(ut3.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one')); + from table(ut3_develop.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one')); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds @@ -535,17 +646,17 @@ end;'; end; procedure pass_csl_with_srcfile is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin select * bulk collect into l_results from table( - ut3.ut.run( + ut3_develop.ut.run( a_path => 'test_csl_names1.one_is_one,test_csl_names2.one_is_one', - a_source_files => ut3.ut_varchar2_list('ut3.ut'), - a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2') + a_source_files => ut3_develop.ut_varchar2_list('ut3_develop.ut'), + a_test_files => ut3_develop.ut_varchar2_list('ut3_tester.test_csl_names2') ) ); @@ -555,12 +666,12 @@ end;'; end; procedure pass_csl_within_var2list is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin select * bulk collect into l_results - from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1.one_is_one,test_csl_names2.one_is_one'))); + from table(ut3_develop.ut.run(ut3_develop.ut_varchar2_list('test_csl_names1.one_is_one,test_csl_names2.one_is_one'))); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds @@ -570,55 +681,55 @@ end;'; procedure is_test_true is begin ut.expect( - ut3.ut_runner.is_test( - a_owner => 'UT3$USER#', + ut3_develop.ut_runner.is_test( + a_owner => 'UT3_USER', a_package_name => 'DUMMY_TEST_PACKAGE', a_procedure_name => 'SOME_DUMMY_TEST_PROCEDURE' ) ).to_be_true(); - ut.expect( ut3.ut_runner.is_test( 'ut3$user#','dummy_test_package','some_dummy_test_procedure' ) ).to_be_true(); + ut.expect( ut3_develop.ut_runner.is_test( 'ut3_user','dummy_test_package','some_dummy_test_procedure' ) ).to_be_true(); end; procedure is_test_false is begin - ut.expect( ut3.ut_runner.is_test( 'UT3$USER#','DUMMY_TEST_PACKAGE', 'BAD' ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_test( 'UT3$USER#','BAD_TEST_PACKAGE', 'some_dummy_test_procedure' ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_test( 'UT3$USER#','DUMMY_TEST_PACKAGE', null ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_test( 'UT3$USER#',null,'some_dummy_test_procedure' ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_test( null,'DUMMY_TEST_PACKAGE','some_dummy_test_procedure' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_test( 'UT3_USER','DUMMY_TEST_PACKAGE', 'BAD' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_test( 'UT3_USER','BAD_TEST_PACKAGE', 'some_dummy_test_procedure' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_test( 'UT3_USER','DUMMY_TEST_PACKAGE', null ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_test( 'UT3_USER',null,'some_dummy_test_procedure' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_test( null,'DUMMY_TEST_PACKAGE','some_dummy_test_procedure' ) ).to_be_false(); end; procedure is_suite_true is begin ut.expect( - ut3.ut_runner.is_suite( - a_owner => 'UT3$USER#', + ut3_develop.ut_runner.is_suite( + a_owner => 'UT3_USER', a_package_name => 'DUMMY_TEST_PACKAGE' ) ).to_be_true(); - ut.expect( ut3.ut_runner.is_suite( 'ut3$user#','dummy_test_package' ) ).to_be_true(); + ut.expect( ut3_develop.ut_runner.is_suite( 'ut3_user','dummy_test_package' ) ).to_be_true(); end; procedure is_suite_false is begin - ut.expect( ut3.ut_runner.is_suite( 'UT3$USER#','BAD' ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_suite( 'UT3$USER#', null ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_suite( null,'DUMMY_TEST_PACKAGE' ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_suite( 'UT3$USER#','bad_test_package' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_suite( 'UT3_USER','BAD' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_suite( 'UT3_USER', null ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_suite( null,'DUMMY_TEST_PACKAGE' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.is_suite( 'UT3_USER','bad_test_package' ) ).to_be_false(); end; procedure has_suites_true is begin - ut.expect( ut3.ut_runner.has_suites( a_owner => 'UT3$USER#' ) ).to_be_true(); - ut.expect( ut3.ut_runner.has_suites( 'ut3$user#' ) ).to_be_true(); + ut.expect( ut3_develop.ut_runner.has_suites( a_owner => 'UT3_USER' ) ).to_be_true(); + ut.expect( ut3_develop.ut_runner.has_suites( 'ut3_user' ) ).to_be_true(); end; procedure has_suites_false is begin - ut.expect( ut3.ut_runner.has_suites( 'UT3_LATEST_RELEASE' ) ).to_be_false(); - ut.expect( ut3.ut_runner.has_suites( 'BAD' ) ).to_be_false(); - ut.expect( ut3.ut_runner.has_suites( null ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.has_suites( 'UT3' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.has_suites( 'BAD' ) ).to_be_false(); + ut.expect( ut3_develop.ut_runner.has_suites( null ) ).to_be_false(); end; end; diff --git a/test/ut3_user/api/test_ut_runner.pks b/test/ut3_user/api/test_ut_runner.pks index 08282e997..742d4ad1c 100644 --- a/test/ut3_user/api/test_ut_runner.pks +++ b/test/ut3_user/api/test_ut_runner.pks @@ -65,6 +65,23 @@ create or replace package test_ut_runner is --%aftertest(cleanup_cache) procedure test_get_suites_info_twotag; + --%test(get_suites_info returns a cursor containing records for a newly created test with passed path) + --%beforetest(setup_cache_objects) + --%aftertest(cleanup_cache) + procedure test_get_suites_info_by_path; + + procedure setup_cache_context_disabled; + + --%test(get_suites_info returns contexts and disabled tests) + --%beforetest(setup_cache_context_disabled) + --%aftertest(cleanup_cache) + procedure test_get_suites_info_context; + + --%test(get_suites_info returns a test and its parents for a procedure path) + --%beforetest(setup_cache_objects) + --%aftertest(cleanup_cache) + procedure test_get_suites_info_by_proc; + --%test(get_reporters_list returns a cursor containing all built-in reporters and information about output-reporter) --%beforetest(setup_cache_objects) --%aftertest(cleanup_cache) diff --git a/test/ut3_user/expectations.pkb b/test/ut3_user/expectations.pkb index 3f2ae543d..be8627712 100644 --- a/test/ut3_user/expectations.pkb +++ b/test/ut3_user/expectations.pkb @@ -8,22 +8,22 @@ create or replace package body expectations as --Arrange --Act execute immediate 'begin some_pkg.some_procedure; end;'; - ut3.ut.expect(1).to_equal(0); - ut3.ut.expect(0).to_equal(0); + ut3_develop.ut.expect(1).to_equal(0); + ut3_develop.ut.expect(0).to_equal(0); --Assert l_actual := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); l_expected := q'[FAILURE Actual: 1 (number) was expected to equal: 0 (number) - at "UT3$USER#.SOME_PKG%", line 4 ut3.ut.expect(1).to_equal(0); + at "UT3_USER.SOME_PKG%", line 4 ut3_develop.ut.expect(1).to_equal(0); at "anonymous block", line 1 - at "UT3$USER#.EXPECTATIONS%", line 10 + at "UT3_USER.EXPECTATIONS%", line 10 SUCCESS Actual: 0 (number) was expected to equal: 0 (number) FAILURE Actual: 1 (number) was expected to equal: 0 (number) - at "UT3$USER#.EXPECTATIONS%", line 11 ut3.ut.expect(1).to_equal(0); + at "UT3_USER.EXPECTATIONS%", line 11 ut3_develop.ut.expect(1).to_equal(0); SUCCESS Actual: 0 (number) was expected to equal: 0 (number) ]'; @@ -44,8 +44,8 @@ SUCCESS create or replace package body some_pkg is procedure some_procedure is begin - ut3.ut.expect(1).to_equal(0); - ut3.ut.expect(0).to_equal(0); + ut3_develop.ut.expect(1).to_equal(0); + ut3_develop.ut.expect(0).to_equal(0); end; end;]'; end; diff --git a/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb index 5d99d07b6..3f92c84c7 100644 --- a/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb +++ b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb @@ -254,7 +254,7 @@ create or replace package body test_be_greater_or_equal is procedure actual_clob is begin --Act - ut3.ut.expect(to_clob('3')).to_( ut3.be_greater_or_equal(3) ); + ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_greater_or_equal(3) ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; diff --git a/test/ut3_user/expectations/binary/test_be_greater_than.pkb b/test/ut3_user/expectations/binary/test_be_greater_than.pkb index 37e15f633..6724b5c41 100644 --- a/test/ut3_user/expectations/binary/test_be_greater_than.pkb +++ b/test/ut3_user/expectations/binary/test_be_greater_than.pkb @@ -254,7 +254,7 @@ create or replace package body test_be_greater_than is procedure actual_clob is begin --Act - ut3.ut.expect(to_clob('3')).to_( ut3.be_greater_than(2) ); + ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_greater_than(2) ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; diff --git a/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb b/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb index bf7632cc4..aefb58849 100644 --- a/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb +++ b/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb @@ -254,7 +254,7 @@ create or replace package body test_be_less_or_equal is procedure actual_clob is begin --Act - ut3.ut.expect(to_clob('3')).to_( ut3.be_less_or_equal(3) ); + ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_less_or_equal(3) ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; diff --git a/test/ut3_user/expectations/binary/test_equal.pkb b/test/ut3_user/expectations/binary/test_equal.pkb index 95fd594c7..735915348 100644 --- a/test/ut3_user/expectations/binary/test_equal.pkb +++ b/test/ut3_user/expectations/binary/test_equal.pkb @@ -26,7 +26,7 @@ create or replace package body test_equal is l_actual '||a_actual_type||' := '||a_actual||'; l_expected '||a_expected_type||' := '||a_expected||'; begin - ut3.ut.expect( l_actual ).'||a_matcher_name||'(l_expected, a_nulls_are_equal=>'||l_nulls_equal||'); + ut3_develop.ut.expect( l_actual ).'||a_matcher_name||'(l_expected, a_nulls_are_equal=>'||l_nulls_equal||'); end;'; end; diff --git a/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb index d7bf5533b..dbf6e30a4 100644 --- a/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb +++ b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb @@ -254,7 +254,7 @@ create or replace package body test_expect_to_be_less_than is procedure actual_clob is begin --Act - ut3.ut.expect(to_clob('3')).to_( ut3.be_less_than(4) ); + ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_less_than(4) ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; diff --git a/test/ut3_user/expectations/binary/test_to_be_within.pkb b/test/ut3_user/expectations/binary/test_to_be_within.pkb new file mode 100644 index 000000000..c9aae6ee2 --- /dev/null +++ b/test/ut3_user/expectations/binary/test_to_be_within.pkb @@ -0,0 +1,360 @@ +create or replace package body test_to_be_within is + + procedure cleanup_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations( ); + end; + + function be_within_expectation_block( + a_matcher_name varchar2, + a_actual_data_type varchar2, + a_actual_data varchar2, + a_expected_data_type varchar2, + a_expected_data varchar2, + a_distance varchar2, + a_distance_data_type varchar2, + a_matcher_end varchar2 + ) return varchar2 + is + l_execute varchar2(32000); + begin + l_execute := ' + declare + l_actual '||a_actual_data_type||' := '||a_actual_data||'; + l_expected '||a_expected_data_type||' := '||a_expected_data||'; + l_distance '||a_distance_data_type||' := '||a_distance||'; + begin + --act - execute the expectation + ut3_develop.ut.expect( l_actual ).'||a_matcher_name||'(l_distance).of_(l_expected)'||a_matcher_end||'; + end;'; + return l_execute; + end; + + procedure test_to_be_within_fail( + a_matcher_name varchar2, + a_data_type varchar2, + a_actual varchar2, + a_expected varchar2, + a_distance varchar2, + a_distance_data_type varchar2, + a_matcher_end varchar2 := null + ) is + begin + execute immediate be_within_expectation_block( + a_matcher_name,a_data_type, a_actual, a_data_type, a_expected, + a_distance,a_distance_data_type, a_matcher_end + ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).not_to_equal(0); + cleanup_expectations; + end; + + procedure test_to_be_within_success( + a_matcher_name varchar2, + a_data_type varchar2, + a_actual varchar2, + a_expected varchar2, + a_distance varchar2, + a_distance_data_type varchar2, + a_matcher_end varchar2 := null + ) is + begin + execute immediate be_within_expectation_block( + a_matcher_name,a_data_type, a_actual, a_data_type, a_expected, + a_distance,a_distance_data_type, a_matcher_end + ); + ut.expect + (ut3_tester_helper.main_helper.get_failed_expectations_num + ,be_within_expectation_block( + a_matcher_name,a_data_type, a_actual, a_data_type, a_expected, + a_distance,a_distance_data_type, a_matcher_end + ) + ).to_equal(0); + cleanup_expectations; + end; + + procedure success_tests is + begin + test_to_be_within_success('to_be_within','number', '2', '4','2','number'); + test_to_be_within_success('to_be_within','number', '4', '2','2','number'); + test_to_be_within_success('to_be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month'); + test_to_be_within_success('to_be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month'); + + test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2017-08-09 07:00:00']', q'[TIMESTAMP '2017-08-08 06:59:48.667']','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2017-08-08 06:59:48.667']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2017-08-09 07:00:00']', q'[TIMESTAMP '2018-08-09 07:00:00']','''1-0''','interval year to month'); + test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month'); + test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); + test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); + test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1 0:00:11.333''','interval day to second'); + test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); + test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); + + test_to_be_within_success('to_( ut3_develop.be_within','number', '2', '4','2','number', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','number', '4', '2','2','number', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); + test_to_be_within_success('to_( ut3_develop.be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); + test_to_be_within_fail('not_to_be_within','number', '2', '4','2','number'); + test_to_be_within_fail('not_to_be_within','number', '4', '2','2','number'); + test_to_be_within_fail('not_to_be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second'); + test_to_be_within_fail('not_to_be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second'); + test_to_be_within_fail('not_to_be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month'); + test_to_be_within_fail('not_to_be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month'); + test_to_be_within_fail('not_to( ut3_develop.be_within','number', '2', '4','2','number',')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','number', '4', '2','2','number',')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second',')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second',')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month',')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month',')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month', ')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); + test_to_be_within_fail('not_to( ut3_develop.be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); + test_to_be_within_fail('not_to_be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month'); + test_to_be_within_fail('not_to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); + test_to_be_within_fail('not_to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); + end; + + procedure failed_tests is + begin + test_to_be_within_fail('to_be_within','number', '2', '4','1','number'); + test_to_be_within_fail('to_be_within','number', '4', '2','1','number'); + test_to_be_within_fail('to_be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second'); + test_to_be_within_fail('to_be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second'); + test_to_be_within_fail('to_be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month'); + test_to_be_within_fail('to_be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month'); + test_to_be_within_fail('to_( ut3_develop.be_within','number', '2', '4','1','number',')'); + test_to_be_within_fail('to_( ut3_develop.be_within','number', '4', '2','1','number',')'); + test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second',')'); + test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second',')'); + test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month',')'); + test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month',')'); + test_to_be_within_success('not_to_be_within','number', '2', '4','1','number'); + test_to_be_within_success('not_to_be_within','number', '4', '2','1','number'); + test_to_be_within_success('not_to_be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second'); + test_to_be_within_success('not_to_be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second'); + test_to_be_within_success('not_to_be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month'); + test_to_be_within_success('not_to_be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month'); + test_to_be_within_success('not_to( ut3_develop.be_within','number', '2', '4','1','number',')'); + test_to_be_within_success('not_to( ut3_develop.be_within','number', '4', '2','1','number',')'); + test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second',')'); + test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second',')'); + test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month',')'); + test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month',')'); + end; + + procedure fail_for_number_not_within is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + --Act + ut3_develop.ut.expect(4).to_be_within(1).of_(7); + --Assert + l_expected_message := q'[Actual: 4 (number) was expected to be within 1 of 7 (number)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_for_ds_int_not_within is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + --Act + ut3_develop.ut.expect(sysdate).to_be_within(interval '1' second).of_(sysdate+1); + --Assert + l_expected_message := q'[Actual: % (date) was expected to be within 1 second of % (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_for_custom_ds_int is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + --Act + ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '2 3:04:11.333' DAY TO SECOND).of_(sysdate+100); + --Assert + l_expected_message := q'[Actual: % (date) was expected to be within 2 days 3 hours 4 minutes 11.333 seconds of % (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_for_ym_int_not_within is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + --Act + ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '1' MONTH).of_(sysdate+ 47); + --Assert + l_expected_message := q'[Actual: % (date) was expected to be within 1 month of % (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_for_custom_ym_int is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + --Act + ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '1-3' YEAR TO MONTH).of_(sysdate+720); + --Assert + l_expected_message := q'[Actual: % (date) was expected to be within 1 year 3 months % (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_msg_when_not_within is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + --Act + ut3_develop.ut.expect(1).to_be_within(3).of_(12); + --Assert + l_expected_message := q'[Actual: 1 (number) was expected to be within 3 of 12 (number)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_msg_wrong_types is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(sysdate).to_be_within(interval '1' second).of_(systimestamp); + --Assert + l_expected_message := q'[Matcher 'be within' cannot be used to compare Actual (date) with Expected (timestamp with time zone) using distance (interval day to second).]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure null_expected is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(sysdate).to_be_within(interval '1' second).of_(to_date(null)); + --Assert + l_expected_message := q'[Actual: % (date) was expected to be within 1 second of NULL (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure null_actual_and_expected is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(to_date(null)).to_be_within(interval '1' second).of_(to_date(null)); + --Assert + l_expected_message := q'[Actual: NULL (date) was expected to be within 1 second of NULL (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure null_actual is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(to_date(null)).to_be_within(interval '1' second).of_(sysdate); + --Assert + l_expected_message := q'[Actual: NULL (date) was expected to be within 1 second of % (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + + procedure null_distance is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(sysdate).to_be_within(cast(null as interval day to second)).of_(sysdate); + --Assert + l_expected_message := q'[Actual: % (date) was expected to be within NULL of % (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + + procedure invalid_distance_for_number is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(2).to_be_within(interval '1' second).of_(1); + --Assert + l_expected_message := q'[Matcher 'be within' cannot be used to compare Actual (number) with Expected (number) using distance (interval day to second).]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + + procedure invalid_distance_for_timestamp is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(sysdate).to_be_within(1).of_(sysdate); + --Assert + l_expected_message := q'[Matcher 'be within' cannot be used to compare Actual (date) with Expected (date) using distance (number).]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure failure_on_tiny_time_diff is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(timestamp'2022-01-29 23:23:23.000000009').to_be_within(interval '0.000000001' second).of_(timestamp'2022-01-29 23:23:23.000000001'); + --Assert + l_expected_message := q'[Actual: 2022-01-29T23:23:23.000000009 (timestamp) was expected to be within .000000001 seconds of 2022-01-29T23:23:23.000000001 (timestamp)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + + procedure failure_on_large_years_compare is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Act + ut3_develop.ut.expect(to_date('-4000-01-01','syyyy-mm-dd')).to_be_within(interval '9990' year).of_(date '9999-12-31'); + --Assert + l_expected_message := q'[Actual: -4000-01-01T00:00:00 (date) was expected to be within 9990 years of 9999-12-31T00:00:00 (date)]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + +end; +/ diff --git a/test/ut3_user/expectations/binary/test_to_be_within.pks b/test/ut3_user/expectations/binary/test_to_be_within.pks new file mode 100644 index 000000000..966e9baaf --- /dev/null +++ b/test/ut3_user/expectations/binary/test_to_be_within.pks @@ -0,0 +1,61 @@ +create or replace package test_to_be_within is + + --%suite((not)to_be_within) + --%suitepath(utplsql.test_user.expectations.binary) + + --%aftereach + procedure cleanup_expectations; + + --%test(gives success for values within a distance) + procedure success_tests; + + --%test(gives failure when value is not within distance) + procedure failed_tests; + + --%test(returns well formatted failure message when expectation fails) + procedure fail_for_number_not_within; + + --%test(returns well formatted failure message for inteval of 1 sec not within) + procedure fail_for_ds_int_not_within; + + --%test(returns well formatted failure message for custom ds interval not within) + procedure fail_for_custom_ds_int; + + --%test(returns well formatted failure message for inteval of 1 month not within) + procedure fail_for_ym_int_not_within; + + --%test(returns well formatted failure message for custom ym interval not within) + procedure fail_for_custom_ym_int; + + --%test(returns well formatted failure message for simple within) + procedure fail_msg_when_not_within; + + --%test(returns well formatted failure message when comparing different datatypes) + procedure fail_msg_wrong_types; + + --%test(failure on null expected value) + procedure null_expected; + + --%test(failure on null actual value) + procedure null_actual; + + --%test(failure on null expected and actual value) + procedure null_actual_and_expected; + + --%test(failure on null distance value) + procedure null_distance; + + --%test(failure on invalid distance datatype for number expected) + procedure invalid_distance_for_number; + + --%test(failure on invalid distance datatype for timestamp expected) + procedure invalid_distance_for_timestamp; + + --%test(failure on exceeding difference in day second time by nanosecond) + procedure failure_on_tiny_time_diff; + + --%test(failure when comparing very large year difference) + procedure failure_on_large_years_compare; + +end; +/ diff --git a/test/ut3_user/expectations/binary/test_to_be_within_pct.pkb b/test/ut3_user/expectations/binary/test_to_be_within_pct.pkb new file mode 100644 index 000000000..da634d90e --- /dev/null +++ b/test/ut3_user/expectations/binary/test_to_be_within_pct.pkb @@ -0,0 +1,221 @@ +create or replace package body test_to_be_within_pct is + + procedure cleanup_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations( ); + end; + + function be_within_expectation_block( + a_matcher varchar2, + a_actual_type varchar2, + a_actual varchar2, + a_expected_type varchar2, + a_expected varchar2, + a_distance varchar2, + a_distance_type varchar2, + a_matcher_end varchar2 + ) return varchar2 + is + l_execute varchar2(32000); + begin + l_execute := ' + declare + l_actual '||a_actual_type||' := '||a_actual||'; + l_expected '||a_expected_type||' := '||a_expected||'; + l_distance '||a_distance_type||' := '||a_distance||'; + begin + --act - execute the expectation + ut3_develop.ut.expect( l_actual ).'||a_matcher||'( l_distance ).of_( l_expected )'||a_matcher_end||'; + end;'; + return l_execute; + end; + + procedure test_to_be_within_fail( + a_matcher varchar2, + a_actual_type varchar2, + a_actual varchar2, + a_expected_type varchar2, + a_expected varchar2, + a_distance varchar2, + a_distance_type varchar2, + a_failure_message varchar2 := null, + a_matcher_end varchar2 := null + ) is + l_failure_text varchar2(4000); + begin + execute immediate be_within_expectation_block( + a_matcher,a_actual_type, a_actual, a_expected_type, a_expected, + a_distance,a_distance_type, a_matcher_end + ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); + if a_failure_message is not null then + l_failure_text := ut3_tester_helper.main_helper.get_failed_expectations(1); + ut.expect( l_failure_text ).to_be_like('%'||a_failure_message||'%' ); + end if; + cleanup_expectations; + end; + + procedure test_to_be_within_success( + a_matcher varchar2, + a_actual_type varchar2, + a_actual varchar2, + a_expected_type varchar2, + a_expected varchar2, + a_distance varchar2, + a_distance_type varchar2, + a_matcher_end varchar2 := null + ) is + begin + execute immediate be_within_expectation_block( + a_matcher,a_actual_type, a_actual, a_expected_type, a_expected, + a_distance,a_distance_type, a_matcher_end + ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + cleanup_expectations; + end; + + + procedure test_to_be_within_error( + a_matcher varchar2, + a_actual_type varchar2, + a_actual varchar2, + a_expected_type varchar2, + a_expected varchar2, + a_distance varchar2, + a_distance_type varchar2, + a_error_message varchar2, + a_matcher_end varchar2 := null + ) is + begin + execute immediate be_within_expectation_block( + a_matcher,a_actual_type, a_actual, a_expected_type, a_expected, + a_distance,a_distance_type, a_matcher_end + ); + cleanup_expectations; + ut.fail('Expected exception but nothing was raised'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%'||a_error_message||'%'); + cleanup_expectations; + end; + + + procedure expect_success is + begin + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + cleanup_expectations; + end; + + procedure expect_failure is + begin + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); + cleanup_expectations; + end; + + procedure success_tests is + begin + ut3_develop.ut.expect( 1 ).to_be_within_pct( 0.01 ).of_(1.0001); + expect_success; + + ut3_develop.ut.expect( 1.0001 ).to_( ut3_develop.be_within_pct( 0.01 ).of_(1) ); + expect_success; + + ut3_develop.ut.expect( 1.0002 ).not_to_be_within_pct( 0.01 ).of_(1); + expect_success; + + ut3_develop.ut.expect( 1 ).not_to( ut3_develop.be_within_pct( 0.01 ).of_(1.0002) ); + expect_success; + + ut3_develop.ut.expect( 1.0001 ).to_be_within_pct( -0.01 ).of_(1); + expect_success; + + ut3_develop.ut.expect( 1 ).to_( ut3_develop.be_within_pct( -0.01 ).of_(1.0001) ); + expect_success; + + ut3_develop.ut.expect( 1.00000001 ).not_to_be_within_pct( 0 ).of_(1); + expect_success; + + ut3_develop.ut.expect( 0 ).not_to( ut3_develop.be_within_pct( 0.01 ).of_(0.000001) ); + expect_success; + + ut3_develop.ut.expect( 0 ).to_be_within_pct( 0 ).of_( 0 ); + expect_success; + + ut3_develop.ut.expect( 0 ).to_be_within_pct( 100 ).of_( 1 ); + expect_success; + + ut3_develop.ut.expect( -1 ).to_be_within_pct( 200 ).of_( 1 ); + expect_success; + end; + + procedure failed_tests is + begin + ut3_develop.ut.expect( 1 ).not_to_be_within_pct( 0.01 ).of_(1.0001); + expect_failure; + + ut3_develop.ut.expect( 1.0001 ).not_to( ut3_develop.be_within_pct( 0.01 ).of_(1) ); + expect_failure; + + ut3_develop.ut.expect( 1.0002 ).to_be_within_pct( 0.01 ).of_(1); + expect_failure; + + ut3_develop.ut.expect( 1 ).to_( ut3_develop.be_within_pct( 0.01 ).of_(1.0002) ); + expect_failure; + + ut3_develop.ut.expect( 1.0001 ).not_to_be_within_pct( -0.01 ).of_(1); + expect_failure; + + ut3_develop.ut.expect( 1 ).not_to( ut3_develop.be_within_pct( -0.01 ).of_(1.0001) ); + expect_failure; + + ut3_develop.ut.expect( 1.00000001 ).to_be_within_pct( 0 ).of_(1); + expect_failure; + + ut3_develop.ut.expect( 0 ).to_( ut3_develop.be_within_pct( 0.01 ).of_(0.000001) ); + expect_failure; + + ut3_develop.ut.expect( 0 ).not_to_be_within_pct( 0 ).of_( 0 ); + expect_failure; + + ut3_develop.ut.expect( 0 ).not_to_be_within_pct( 100 ).of_( 1 ); + expect_failure; + + ut3_develop.ut.expect( -1 ).not_to_be_within_pct( 200 ).of_( 1 ); + expect_failure; + end; + + procedure fail_for_number_not_within is + begin + test_to_be_within_fail( + 'to_be_within_pct','number', '4', 'number','7', + '1','number', + q'[Actual: 4 (number) was expected to be within 1 % of 7 (number)]' + ); + end; + + procedure fail_at_invalid_argument_types is + begin + test_to_be_within_error( + 'to_be_within_pct','date', 'sysdate', 'date','sysdate', + '''0 0:00:11.333''','interval day to second', + 'wrong number or types of arguments in call to ''TO_BE_WITHIN_PCT''' + ); + test_to_be_within_error( + 'to_be_within_pct','number','1', 'date', 'sysdate', + '1','number', + ' wrong number or types of arguments in call to ''OF_''' + ); + test_to_be_within_error( + 'to_be_within_pct','number','1','number','1', + 'sysdate', 'date', + ' wrong number or types of arguments in call to ''TO_BE_WITHIN_PCT''' + ); + test_to_be_within_fail( + 'to_be_within_pct','date', 'sysdate', 'number','1', + '1','number', + 'Matcher ''be within pct'' cannot be used to compare Actual (date) with Expected (number) using distance (number).' + ); + end; + +end; +/ diff --git a/test/ut3_user/expectations/binary/test_to_be_within_pct.pks b/test/ut3_user/expectations/binary/test_to_be_within_pct.pks new file mode 100644 index 000000000..4b8f0cb4c --- /dev/null +++ b/test/ut3_user/expectations/binary/test_to_be_within_pct.pks @@ -0,0 +1,22 @@ +create or replace package test_to_be_within_pct is + + --%suite((not)to_be_within_pct) + --%suitepath(utplsql.test_user.expectations.binary) + + --%aftereach + procedure cleanup_expectations; + + --%test(gives success for values within a distance) + procedure success_tests; + + --%test(gives failure when number is not within distance) + procedure failed_tests; + + --%test(returns well formatted failure message when expectation fails) + procedure fail_for_number_not_within; + + --%test(fails at compile or run time for unsupported data-types ) + procedure fail_at_invalid_argument_types; + +end; +/ diff --git a/test/ut3_user/expectations/test_expectation_anydata.pkb b/test/ut3_user/expectations/test_expectation_anydata.pkb index f94b0efc0..5f76e6715 100644 --- a/test/ut3_user/expectations/test_expectation_anydata.pkb +++ b/test/ut3_user/expectations/test_expectation_anydata.pkb @@ -23,7 +23,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( cast(null as ut3_tester_helper.test_dummy_object) ); g_test_actual := anydata.convertObject( cast(null as ut3_tester_helper.other_dummy_object) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual (ut3_tester_helper.other_dummy_object) cannot be compared to Expected (ut3_tester_helper.test_dummy_object) using matcher 'equal'.]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -39,7 +39,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.other_dummy_object(1, 'A', '0') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual (ut3_tester_helper.other_dummy_object) cannot be compared to Expected (ut3_tester_helper.test_dummy_object) using matcher 'equal'.]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -53,7 +53,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, null, '0') ); --Act - ut3.ut.expect( g_test_actual ).not_to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).not_to_equal( g_test_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -66,7 +66,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); g_test_actual := anydata.convertObject( cast(null as ut3_tester_helper.test_dummy_object) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object was expected to equal: ut3_tester_helper.test_dummy_object %Diff: @@ -86,7 +86,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual (ut3_tester_helper.test_dummy_object_list) cannot be compared to Expected (ut3_tester_helper.test_dummy_object) using matcher 'equal'.]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -103,7 +103,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list() ); g_test_actual := anydata.convertCollection( l_null_list ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ null ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 0 ]]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -121,7 +121,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); g_test_actual := anydata.convertCollection( l_null_list ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ null ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 1 ] %Diff: @@ -140,7 +140,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list() ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 0 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 1 ] %Diff: @@ -161,7 +161,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_obj) ); g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_obj, l_obj) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 1 ] %Diff: @@ -178,7 +178,7 @@ create or replace package body test_expectation_anydata is l_null_anydata anydata; begin --Act - ut3.ut.expect( l_null_anydata ).to_equal( l_null_anydata ); + ut3_develop.ut.expect( l_null_anydata ).to_equal( l_null_anydata ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -189,7 +189,7 @@ create or replace package body test_expectation_anydata is l_anydata anydata := anydata.convertObject(l_null_object); begin --Act - ut3.ut.expect( l_anydata ).to_equal( l_anydata ); + ut3_develop.ut.expect( l_anydata ).to_equal( l_anydata ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -200,7 +200,7 @@ create or replace package body test_expectation_anydata is l_anydata anydata := anydata.convertCollection(l_null_collection); begin --Act - ut3.ut.expect( l_anydata ).to_equal( l_anydata ); + ut3_develop.ut.expect( l_anydata ).to_equal( l_anydata ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -211,7 +211,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -226,7 +226,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_first_obj, l_second_obj) ); g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_second_obj, l_first_obj) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -237,20 +237,20 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure exclude_attributes_as_list is - l_list ut3.ut_varchar2_list; + l_list ut3_develop.ut_varchar2_list; begin --Arrange - l_list := ut3.ut_varchar2_list('Value','/ID'); + l_list := ut3_develop.ut_varchar2_list('Value','/ID'); g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>3, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -263,7 +263,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>2, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -276,7 +276,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>2, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_xpath ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_xpath ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -289,20 +289,20 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_exclude ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_exclude ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_attributes_as_list is - l_list ut3.ut_varchar2_list; + l_list ut3_develop.ut_varchar2_list; begin --Arrange - l_list := ut3.ut_varchar2_list('Value','ID'); + l_list := ut3_develop.ut_varchar2_list('Value','ID'); g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'b',"Value"=>'0') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_list ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_list ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -315,7 +315,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -328,7 +328,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -341,7 +341,7 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_include ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_include ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -356,24 +356,24 @@ create or replace package body test_expectation_anydata is g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_exclude_attrib_list is - l_exclude ut3.ut_varchar2_list; - l_include ut3.ut_varchar2_list; + l_exclude ut3_develop.ut_varchar2_list; + l_include ut3_develop.ut_varchar2_list; l_expected varchar2(32767); l_actual varchar2(32767); begin --Arrange - l_include := ut3.ut_varchar2_list('key','ID','Value'); - l_exclude := ut3.ut_varchar2_list('key','Value'); + l_include := ut3_develop.ut_varchar2_list('key','ID','Value'); + l_exclude := ut3_develop.ut_varchar2_list('key','Value'); g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -391,7 +391,7 @@ Rows: [ 1 differences ] Row No. 1 - Actual: Row No. 1 - Expected: A]'; --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_actual := ut3_tester_helper.main_helper.get_failed_expectations(1); ut.expect(l_actual).to_be_like(l_expected); @@ -411,7 +411,7 @@ Diff: Rows: [ 1 differences ] Row No. 2 - Extra: 1A0]'; --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); --Assert l_actual := ut3_tester_helper.main_helper.get_failed_expectations(1); ut.expect(l_actual).to_be_like(l_expected); @@ -425,7 +425,7 @@ Rows: [ 1 differences ] procedure deprec_to_equal_excl_varch is begin --Act - ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); + ut3_develop.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -434,7 +434,7 @@ Rows: [ 1 differences ] procedure deprec_to_equal_excl_list is begin --Act - ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); + ut3_develop.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -443,7 +443,7 @@ Rows: [ 1 differences ] procedure deprec_not_to_equal_excl_varch is begin --Act - ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); + ut3_develop.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -452,7 +452,7 @@ Rows: [ 1 differences ] procedure deprec_not_to_equal_excl_list is begin --Act - ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); + ut3_develop.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -461,7 +461,7 @@ Rows: [ 1 differences ] procedure deprec_equal_excl_varch is begin --Act - ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col')); + ut3_develop.ut.expect(get_anydata()).to_(ut3_develop.equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col')); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -470,7 +470,7 @@ Rows: [ 1 differences ] procedure deprec_equal_excl_list is begin --Act - ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'))); + ut3_develop.ut.expect(get_anydata()).to_(ut3_develop.equal(get_anydata(), a_exclude => ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col'))); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -491,7 +491,7 @@ Rows: [ 1 differences ] from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); l_expected_message := q'[Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 2 ] Diff: @@ -521,7 +521,7 @@ Rows: [ 2 differences ] bulk collect into l_expected from dual connect by level <=110; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); l_expected_message := q'[Actual: ut3_tester_helper.test_dummy_object_list [ count = 100 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 110 ] Diff: @@ -543,9 +543,9 @@ Rows: [ 60 differences, showing first 20 ] procedure collection_include_list is l_actual ut3_tester_helper.test_dummy_object_list; l_expected ut3_tester_helper.test_dummy_object_list; - l_list ut3.ut_varchar2_list; + l_list ut3_develop.ut_varchar2_list; begin - l_list := ut3.ut_varchar2_list('Value','ID'); + l_list := ut3_develop.ut_varchar2_list('Value','ID'); --Arrange select ut3_tester_helper.test_dummy_object( rownum, 'SomethingsDifferent '||rownum, rownum) bulk collect into l_actual @@ -554,7 +554,7 @@ Rows: [ 60 differences, showing first 20 ] bulk collect into l_expected from dual connect by level <=2; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -562,9 +562,9 @@ Rows: [ 60 differences, showing first 20 ] procedure collection_exclude_list is l_actual ut3_tester_helper.test_dummy_object_list; l_expected ut3_tester_helper.test_dummy_object_list; - l_list ut3.ut_varchar2_list; + l_list ut3_develop.ut_varchar2_list; begin - l_list := ut3.ut_varchar2_list('Value','ID'); + l_list := ut3_develop.ut_varchar2_list('Value','ID'); --Arrange select ut3_tester_helper.test_dummy_object( rownum*2, 'Something '||rownum, rownum*2) bulk collect into l_actual @@ -573,7 +573,7 @@ Rows: [ 60 differences, showing first 20 ] bulk collect into l_expected from dual connect by level <=2; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).exclude( l_list ); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).exclude( l_list ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -581,11 +581,11 @@ Rows: [ 60 differences, showing first 20 ] procedure collection_include_list_fail is l_actual ut3_tester_helper.test_dummy_object_list; l_expected ut3_tester_helper.test_dummy_object_list; - l_list ut3.ut_varchar2_list; + l_list ut3_develop.ut_varchar2_list; l_actual_message varchar2(32767); l_expected_message varchar2(32767); begin - l_list := ut3.ut_varchar2_list('name'); + l_list := ut3_develop.ut_varchar2_list('name'); --Arrange select ut3_tester_helper.test_dummy_object( rownum, 'SomethingsDifferent '||rownum, rownum) bulk collect into l_actual @@ -594,7 +594,7 @@ Rows: [ 60 differences, showing first 20 ] bulk collect into l_expected from dual connect by level <=2; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 2 ] %Diff: @@ -614,7 +614,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -626,7 +626,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('B') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); l_expected_message := q'[%Actual: ut3_tester_helper.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester_helper.t_tab_varchar [ count = 1 ] %Diff: %Rows: [ 1 differences ] @@ -640,7 +640,7 @@ Rows: [ 60 differences, showing first 20 ] procedure array_is_null is l_is_null ut3_tester_helper.t_tab_varchar ; begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; + ut3_develop.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -648,7 +648,7 @@ Rows: [ 60 differences, showing first 20 ] l_is_null ut3_tester_helper.t_tab_varchar ; l_is_null_bis ut3_tester_helper.t_tab_varchar ; begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); + ut3_develop.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -661,7 +661,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( l_is_null ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); l_expected_message := q'[%Actual: ut3_tester_helper.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester_helper.t_tab_varchar [ null ] %Diff: %Rows: [ 1 differences ] @@ -673,7 +673,7 @@ Rows: [ 60 differences, showing first 20 ] procedure empty_array_have_zero_elem is begin - ut3.ut.expect( anydata.convertCollection(ut3_tester_helper.t_tab_varchar())).to_have_count(0); + ut3_develop.ut.expect( anydata.convertCollection(ut3_tester_helper.t_tab_varchar())).to_have_count(0); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -683,7 +683,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection(ut3_tester_helper.t_tab_varchar()); g_test_actual := anydata.convertCollection(ut3_tester_helper.t_tab_varchar()); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -696,7 +696,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( ut3_tester_helper.t_tab_varchar() ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); l_expected_message := q'[%Actual: ut3_tester_helper.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester_helper.t_tab_varchar [ count = 0 ] %Diff: %Rows: [ 1 differences ] @@ -712,7 +712,7 @@ Rows: [ 60 differences, showing first 20 ] --Arrange g_test_actual := anydata.convertCollection( l_null_list ); --Act - ut3.ut.expect( g_test_actual ).to_be_null; + ut3_develop.ut.expect( g_test_actual ).to_be_null; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -722,7 +722,7 @@ Rows: [ 60 differences, showing first 20 ] --Arrange g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list() ); --Act - ut3.ut.expect( g_test_actual ).to_have_count(0); + ut3_develop.ut.expect( g_test_actual ).to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -734,7 +734,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -746,7 +746,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(2) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); l_expected_message := q'[%Actual: ut3_tester_helper.t_varray [ count = 1 ] was expected to equal: ut3_tester_helper.t_varray [ count = 1 ] %Diff: %Rows: [ 1 differences ] @@ -760,7 +760,7 @@ Rows: [ 60 differences, showing first 20 ] procedure varray_is_null is l_is_null ut3_tester_helper.t_varray ; begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; + ut3_develop.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -768,7 +768,7 @@ Rows: [ 60 differences, showing first 20 ] l_is_null ut3_tester_helper.t_varray ; l_is_null_bis ut3_tester_helper.t_varray ; begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); + ut3_develop.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -781,7 +781,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( l_is_null ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); l_expected_message := q'[%Actual: ut3_tester_helper.t_varray [ count = 1 ] was expected to equal: ut3_tester_helper.t_varray [ null ] %Diff: %Rows: [ 1 differences ] @@ -793,7 +793,7 @@ Rows: [ 60 differences, showing first 20 ] procedure empty_varray_have_zero_elem is begin - ut3.ut.expect( anydata.convertCollection(ut3_tester_helper.t_varray())).to_have_count(0); + ut3_develop.ut.expect( anydata.convertCollection(ut3_tester_helper.t_varray())).to_have_count(0); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -803,7 +803,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection(ut3_tester_helper.t_varray()); g_test_actual := anydata.convertCollection(ut3_tester_helper.t_varray()); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -816,7 +816,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_expected := anydata.convertCollection( ut3_tester_helper.t_varray() ); g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); l_expected_message := q'[%Actual: ut3_tester_helper.t_varray [ count = 1 ] was expected to equal: ut3_tester_helper.t_varray [ count = 0 ] %Diff: %Rows: [ 1 differences ] @@ -841,7 +841,7 @@ Rows: [ 60 differences, showing first 20 ] from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('ID'); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('ID'); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -860,14 +860,12 @@ Rows: [ 60 differences, showing first 20 ] from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('ID'); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('ID'); l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 2 ] %Diff: %Rows: [ 3 differences ] -%PK 2 - Actual: Something 2 -%PK 2 - Actual: 2 -%PK 2 - Expected: Something 1 -%PK 2 - Expected: 1 +%PK 2 - Actual: Something 22 +%PK 2 - Expected: Something 11 %PK 1 - Extra: 1Something 11 %PK 4 - Missing: 4Something 22]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -888,7 +886,7 @@ Rows: [ 60 differences, showing first 20 ] from dual connect by level <=3 order by rownum desc; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -915,7 +913,7 @@ Rows: [ 60 differences, showing first 20 ] %Missing: 4Something 22 %Missing: 2Something 11]'; - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -928,7 +926,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); --Act - ut3.ut.expect(g_test_actual).to_equal(g_test_expected).join_by('ID'); + ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected).join_by('ID'); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -938,7 +936,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); --Act - ut3.ut.expect(g_test_actual).to_equal(g_test_expected).unordered; + ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected).unordered; ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -955,10 +953,27 @@ Rows: [ 60 differences, showing first 20 ] from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_contain(anydata.convertCollection(l_expected)); + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).to_contain(anydata.convertCollection(l_expected)); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; + procedure collection_not_to_contain is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'Something2 '||rownum, rownum+100) + bulk collect into l_actual + from dual connect by level <=4; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + --Act + ut3_develop.ut.expect(anydata.convertCollection(l_actual)).not_to_contain(anydata.convertCollection(l_expected)); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + procedure object_to_contain is begin --Arrange @@ -966,10 +981,10 @@ Rows: [ 60 differences, showing first 20 ] g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); --Act - ut3.ut.expect(g_test_actual).to_contain(g_test_expected); + ut3_develop.ut.expect(g_test_actual).to_contain(g_test_expected); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; - + procedure arr_empty_eq_arr_empty_unord is begin --Arrange @@ -977,7 +992,7 @@ Rows: [ 60 differences, showing first 20 ] g_test_actual := anydata.convertCollection(ut3_tester_helper.t_tab_varchar(null)); --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).unordered(); + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ).unordered(); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -989,10 +1004,254 @@ Rows: [ 60 differences, showing first 20 ] g_test_actual := anydata.convertCollection(ut3_tester_helper.t_tab_varchar(' ')); --Act - ut3.ut.expect( g_test_actual ).not_to_equal( g_test_expected ).unordered(); + ut3_develop.ut.expect( g_test_actual ).not_to_equal( g_test_expected ).unordered(); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; + + procedure failure_nesting_objects is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') )); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'C', '0') )); + --Act + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_nested_object was expected to equal: ut3_tester_helper.test_dummy_nested_object +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Actual: 1C0 +%Row No. 1 - Expected: 1B0]'; + ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected); + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + procedure failure_double_nested_objects is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ),'Test')); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'C', '0') ),'Test')); + --Act + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_double_nested_obj was expected to equal: ut3_tester_helper.test_dummy_double_nested_obj +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Actual: 1A01C0 +%Row No. 1 - Expected: 1A01B0]'; + ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected); + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure success_nesting_objects is + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') )); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') )); + --Act + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure success_double_nested_objects is + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ),'Test')); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ),'Test')); + --Act + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure failure_nested_object_list is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum + 1, 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2 + order by rownum desc; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_actual,'Test')); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_expected,'Test')); + --Act + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_nested_object_list was expected to equal: ut3_tester_helper.test_dummy_nested_object_list +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Actual: 2Something 221Something 11 +%Row No. 1 - Expected: 3Something 222Something 11]'; + ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected); + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure success_nested_object_list is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum , 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2 + order by rownum desc; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_actual,'Test')); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_expected,'Test')); + --Act + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure nested_varray_same_data is + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(1)) ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(1)) ); + --Act + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure nested_varray_diff_data is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(1)) ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(2)) ); + --Act + ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); + l_expected_message := q'[%Actual: ut3_tester_helper.test_nested_tab_varray was expected to equal: ut3_tester_helper.test_nested_tab_varray +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Actual: 2 +%Row No. 1 - Expected: 1]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure user_def_type_null_issue_1098 is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_actual ut3_tester_helper.test_dummy_dble_nest_lst_obj; + l_expected ut3_tester_helper.test_dummy_dble_nest_lst_obj; + begin + l_actual:= ut3_tester_helper.test_dummy_dble_nest_lst_obj( + 1, 'North America', + ut3_tester_helper.test_dummy_double_nested_list ( + ut3_tester_helper.test_dummy_nested_object_list( + ut3_tester_helper.test_dummy_object_list( + ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), + ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) + ),'USA' + ), + ut3_tester_helper.test_dummy_nested_object_list( + ut3_tester_helper.test_dummy_object_list(),'USA' + ) + ) + ); + + l_expected := ut3_tester_helper.test_dummy_dble_nest_lst_obj( + 1, + 'North America', + ut3_tester_helper.test_dummy_double_nested_list(ut3_tester_helper.test_dummy_nested_object_list(ut3_tester_helper.test_dummy_object_list( + ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), + ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) + ), 'USA')) + ); + ut3_develop.ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)).unordered; + + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_dble_nest_lst_obj was expected to equal: ut3_tester_helper.test_dummy_dble_nest_lst_obj +%Diff: +%Rows: [ 2 differences ] +%Extra: 1North America1100 Broadway24742200 Indian School Rd85016USAUSA +%Missing: 1North America1100 Broadway24742200 Indian School Rd85016USA]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure complex_nested_object_success is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_actual ut3_tester_helper.test_dummy_dble_nest_lst_obj; + l_expected ut3_tester_helper.test_dummy_dble_nest_lst_obj; + begin + l_actual:= ut3_tester_helper.test_dummy_dble_nest_lst_obj( + 1, 'North America', + ut3_tester_helper.test_dummy_double_nested_list ( + ut3_tester_helper.test_dummy_nested_object_list( + ut3_tester_helper.test_dummy_object_list( + ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), + ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) + ),'USA' + ), + ut3_tester_helper.test_dummy_nested_object_list( + ut3_tester_helper.test_dummy_object_list(),'USA' + ) + ) + ); + + l_expected := ut3_tester_helper.test_dummy_dble_nest_lst_obj( + 1, 'North America', + ut3_tester_helper.test_dummy_double_nested_list ( + ut3_tester_helper.test_dummy_nested_object_list( + ut3_tester_helper.test_dummy_object_list( + ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), + ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) + ),'USA' + ), + ut3_tester_helper.test_dummy_nested_object_list( + ut3_tester_helper.test_dummy_object_list(),'USA' + ) + ) + ); + ut3_develop.ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)).unordered; + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure long_names_object_types is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace type + very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it + is object ( + code number(18) + )]'; + execute immediate q'[ + begin + ut3_develop.ut.expect(anydata.convertObject( + very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it(1) + )).to_equal(anydata.convertObject( + very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it(1) + )); + end;]'; + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + execute immediate 'drop type very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it'; + exception + when others then + execute immediate 'drop type very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it'; + raise; + end; + end; / \ No newline at end of file diff --git a/test/ut3_user/expectations/test_expectation_anydata.pks b/test/ut3_user/expectations/test_expectation_anydata.pks index a6eeb25fb..557eb58db 100644 --- a/test/ut3_user/expectations/test_expectation_anydata.pks +++ b/test/ut3_user/expectations/test_expectation_anydata.pks @@ -195,6 +195,9 @@ create or replace package test_expectation_anydata is --%test( Success when anydata collection contains data from another anydata collection) procedure collection_to_contain; + --%test( Success when anydata collection not contains data from another anydata collection) + procedure collection_not_to_contain; + --%test( Success when anydata object contains data from another anydata) procedure object_to_contain; @@ -203,5 +206,39 @@ create or replace package test_expectation_anydata is --%test ( Empty Array not equal array with space ) procedure arr_empty_nqua_arr_e_unord; + + --%test ( Reports diff between not equal nested objects ) + procedure failure_nesting_objects; + + --%test ( Reports diff between not equal double nested objects ) + procedure failure_double_nested_objects; + + --%test (Reports success when comparing identical nested object ) + procedure success_nesting_objects; + + --%test ( Reports success when comparing identical double nested object ) + procedure success_double_nested_objects; + + --%test ( Reports diff between two not equal nested object list ) + procedure failure_nested_object_list; + + --%test ( Reports success when comparing identical nested object list ) + procedure success_nested_object_list; + + --%test ( Reports success when comparing identical nested VARRAYS ) + procedure nested_varray_same_data; + + --%test ( Reports diff between two not equal nested VARRAYS ) + procedure nested_varray_diff_data; + + --%test ( Comparision won't fail on user_defined type that is null as per issue 1098 ) + procedure user_def_type_null_issue_1098; + + --%test ( Reports success when comparing complex nested objects ) + procedure complex_nested_object_success; + + --%test ( Compares object types with long names - Issue #1235 ) + procedure long_names_object_types; + end; / diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb index dc439e7e0..aa5375500 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -48,7 +48,7 @@ create or replace package body test_expectations_cursor is select 'Other test entry' as value from dual; open l_actual for 'select * from gtt_test_table'; --Act - execute the expectation on cursor opened on GTT - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); --Cleanup @@ -62,7 +62,7 @@ create or replace package body test_expectations_cursor is l_actual sys_refcursor; begin -- Arrange - ut3.ut.set_nls; + ut3_develop.ut.set_nls; open l_expected for select 1 as my_num, 'This is my test string' as my_string, @@ -76,10 +76,10 @@ create or replace package body test_expectations_cursor is to_date('1984-09-05', 'YYYY-MM-DD') as my_date from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - ut3.ut.reset_nls; + ut3_develop.ut.reset_nls; end; procedure success_on_same_data_float @@ -88,7 +88,7 @@ create or replace package body test_expectations_cursor is l_actual sys_refcursor; begin -- Arrange - ut3.ut.set_nls; + ut3_develop.ut.set_nls; open l_expected for select cast(3.14 as binary_double) as pi_double, cast(3.14 as binary_float) as pi_float @@ -98,10 +98,10 @@ create or replace package body test_expectations_cursor is cast(3.14 as binary_float) as pi_float from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - ut3.ut.reset_nls; + ut3_develop.ut.reset_nls; end; procedure success_on_empty @@ -113,7 +113,7 @@ create or replace package body test_expectations_cursor is open l_expected for select * from dual where 1=0; open l_actual for select * from dual where 1=0; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -124,7 +124,7 @@ create or replace package body test_expectations_cursor is l_actual sys_refcursor; begin --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -134,7 +134,7 @@ create or replace package body test_expectations_cursor is l_actual sys_refcursor; begin --Act - ut3.ut.expect( l_actual ).to_be_null(); + ut3_develop.ut.expect( l_actual ).to_be_null(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -144,7 +144,7 @@ create or replace package body test_expectations_cursor is l_actual sys_refcursor; begin --Act - ut3.ut.expect( l_actual ).not_to_be_not_null(); + ut3_develop.ut.expect( l_actual ).not_to_be_not_null(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -156,7 +156,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_actual for select * from dual; --Act - ut3.ut.expect( l_actual ).to_be_not_null(); + ut3_develop.ut.expect( l_actual ).to_be_not_null(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -168,7 +168,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_actual for select * from dual; --Act - ut3.ut.expect( l_actual ).to_be_not_null(); + ut3_develop.ut.expect( l_actual ).to_be_not_null(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -180,7 +180,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_actual for select * from dual where 0=1; --Act - ut3.ut.expect( l_actual ).to_be_empty(); + ut3_develop.ut.expect( l_actual ).to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -192,7 +192,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_actual for select * from dual; --Act - ut3.ut.expect( l_actual ).not_to_be_empty(); + ut3_develop.ut.expect( l_actual ).not_to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -204,7 +204,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_actual for select * from dual; --Act - ut3.ut.expect( l_actual ).to_be_null(); + ut3_develop.ut.expect( l_actual ).to_be_null(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -214,7 +214,7 @@ create or replace package body test_expectations_cursor is l_actual sys_refcursor; begin --Act - ut3.ut.expect( l_actual ).not_to_be_null(); + ut3_develop.ut.expect( l_actual ).not_to_be_null(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -226,7 +226,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_actual for select * from dual; --Act - ut3.ut.expect( l_actual ).to_be_empty(); + ut3_develop.ut.expect( l_actual ).to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -238,7 +238,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_actual for select * from dual where 0=1; --Act - ut3.ut.expect( l_actual ).not_to_be_empty(); + ut3_develop.ut.expect( l_actual ).not_to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -251,7 +251,7 @@ create or replace package body test_expectations_cursor is --Arrange open l_expected for select * from dual where 1=0; --Act - ut3.ut.expect( l_actual ).not_to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).not_to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -265,7 +265,7 @@ create or replace package body test_expectations_cursor is open l_expected for select to_clob('This is an even longer test clob') as my_clob from dual; open l_actual for select to_clob('Another totally different story') as my_clob from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -279,7 +279,7 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as my_num from dual; open l_actual for select 1 as my_num from dual union all select 1 as my_num from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -293,7 +293,7 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as my_num from dual union all select 1 as my_num from dual; open l_actual for select 1 as my_num from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -307,7 +307,7 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as col_1 from dual; open l_actual for select 1 as col_2 from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -322,7 +322,7 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as col_1, 2 as col_2 from dual; open l_actual for select 2 as col_2, 1 as col_1 from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -336,7 +336,7 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as col_1, 2 as col_2 from dual; open l_actual for select 2 as col_2, 1 as col_1 from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ).unordered_columns; + ut3_develop.ut.expect( l_actual ).to_( ut3_develop.equal( l_expected ).unordered_columns() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -350,7 +350,7 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as col_1, 2 as col_2 from dual; open l_actual for select 2 as col_2, 1 as col_1 from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ).uc; + ut3_develop.ut.expect( l_actual ).to_( ut3_develop.equal( l_expected ).uc() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -366,12 +366,12 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual; open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ).unordered_columns; + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).unordered_columns; --Assert l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] %Diff: %Rows: [ 1 differences ] -%Row No. 1 - Actual: 4030 +%Row No. 1 - Actual: 3040 %Row No. 1 - Expected: 34]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert @@ -389,12 +389,12 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual; open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ).uc; + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).uc; --Assert l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] %Diff: %Rows: [ 1 differences ] -%Row No. 1 - Actual: 4030 +%Row No. 1 - Actual: 3040 %Row No. 1 - Expected: 34]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert @@ -410,7 +410,7 @@ create or replace package body test_expectations_cursor is open l_expected for select 1 as my_num from dual union all select 2 as my_num from dual; open l_actual for select 2 as my_num from dual union all select 1 as my_num from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -419,18 +419,17 @@ create or replace package body test_expectations_cursor is as l_expected sys_refcursor; l_actual sys_refcursor; - l_date date := sysdate; - l_second number := 1/24/60/60; + c_second constant number := 1/24/60/60; begin --Arrange - ut3.ut.set_nls; - open l_actual for select l_date as some_date from dual; - open l_expected for select l_date-l_second some_date from dual; + ut3_develop.ut.set_nls; + open l_actual for select gc_date as some_date from dual; + open l_expected for select gc_date - c_second some_date from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - ut3.ut.reset_nls; + ut3_develop.ut.reset_nls; end; procedure uses_default_nls_for_date @@ -439,10 +438,10 @@ create or replace package body test_expectations_cursor is l_expected sys_refcursor; begin --Arrange - open l_actual for select sysdate as some_date from dual; - open l_expected for select to_date(to_char(sysdate)) as some_date from dual; + open l_actual for select gc_date as some_date from dual; + open l_expected for select to_date(to_char(gc_date)) as some_date from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -456,7 +455,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3.ut_varchar2_list('A_COLUMN','Some_Col')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -470,7 +469,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,Some_Col'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,Some_Col'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -483,7 +482,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3.ut_varchar2_list('A_COLUMN','/ROW/Some_Col')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3_develop.ut_varchar2_list('A_COLUMN','/ROW/Some_Col')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -496,7 +495,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,/ROW/Some_Col'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,/ROW/Some_Col'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -512,7 +511,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'/ROW/A_COLUMN,\\//Some_Col'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'/ROW/A_COLUMN,\\//Some_Col'); --Assert l_expected_message := q'[Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ] %Diff: @@ -537,7 +536,7 @@ create or replace package body test_expectations_cursor is open l_actual for select 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual; open l_expected for select 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'/ROW/A_COLUMN|/ROW/Some_Col'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'/ROW/A_COLUMN|/ROW/Some_Col'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -551,7 +550,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'c' as A_COLUMN from dual a connect by level < 4; open l_expected for select rownum as rn, 'd' as A_COLUMN from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3.ut_varchar2_list('A_COLUMN','non_existing_column')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3_develop.ut_varchar2_list('A_COLUMN','non_existing_column')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -565,7 +564,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -579,7 +578,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include('RN,//A_Column, SOME_COL'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include('RN,//A_Column, SOME_COL'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -593,7 +592,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include('/ROW/RN|//A_Column|//SOME_COL'); + ut3_develop.ut.expect(l_actual).to_( ut3_develop.equal(l_expected).include('/ROW/RN|//A_Column|//SOME_COL') ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -607,7 +606,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'c' as A_COLUMN from dual a connect by level < 4; open l_expected for select rownum as rn, 'd' as A_COLUMN from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list(' RN ',' non_existing_column ')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list(' RN ',' non_existing_column ')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -621,7 +620,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).exclude('Some_Col').include('/ROW/RN|//Some_Col'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude('Some_Col').include('/ROW/RN|//Some_Col'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -635,7 +634,7 @@ create or replace package body test_expectations_cursor is open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN')).include(ut3.ut_varchar2_list('RN','A_Column','A_COLUMN')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN')).include(ut3_develop.ut_varchar2_list('RN','A_Column','A_COLUMN')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -651,7 +650,7 @@ create or replace package body test_expectations_cursor is open l_actual for select 1 rn from dual union all select 6 rn from dual; open l_expected for select rownum rn from dual connect by level <=3; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ] Diff: @@ -674,7 +673,7 @@ Rows: [ 2 differences ] open l_actual for select cast('a' as char(1)) a_column, 1 as id from dual; open l_expected for select cast('a' as varchar2(10)) a_column from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] Diff: Columns: @@ -696,7 +695,7 @@ Rows: [ 1 differences ] open l_actual for select to_char(rownum) rn, rownum another_rn from dual connect by level <=2; open l_expected for select rownum rn, rownum another_rn from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] Diff: @@ -719,7 +718,7 @@ Rows: [ all different ] open l_actual for select rownum rn, rownum bad_column_name from dual connect by level <=2; open l_expected for select rownum rn, rownum expected_column_name from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] Diff: @@ -741,7 +740,7 @@ Columns:% open l_actual for select rownum+1 col_1, rownum+2 col_2, rownum+3 col_3, rownum+4 col_4 from dual connect by level <=2; open l_expected for select rownum+1 col_1, rownum+4 col_4, rownum+2 col_2, rownum+3 col_3 from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] Diff: @@ -766,7 +765,7 @@ Rows: [ all different ] open l_actual for select rownum+1 col_1, rownum+2 col_2, rownum+3 col_3, rownum+4 col_4 from dual connect by level <=2; open l_expected for select rownum+1 col_1, rownum+4 col_4, rownum+2 col_2, rownum+3 col_3 from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered_columns; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered_columns; ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -782,7 +781,7 @@ Rows: [ all different ] open l_actual for select rownum good_col, -rownum bad_col from dual connect by level <=2; open l_expected for select rownum good_col, rownum bad_col from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] Diff: @@ -810,7 +809,7 @@ Rows: [ 2 differences ] from dual connect by level <=100; open l_expected for select rownum bad_col, rownum good_col from dual connect by level <=110; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 100 ] was expected to equal: refcursor [ count = 110 ] Diff: @@ -850,7 +849,7 @@ Rows: [ 60 differences, showing first 20 ] select 'F' AS GENDER, 'JESSICA' as FIRST_NAME, 'JONES' AS LAST_NAME, 4 as ID, '2345' AS SALARY from dual union all select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 3 ] Diff: Columns: @@ -860,9 +859,9 @@ Columns: Rows: [ 4 differences ] Row No. 1 - Actual: 25000 Row No. 1 - Expected: 10000 - Row No. 2 - Actual: TONYSTARK3100000 + Row No. 2 - Actual: 3TONYSTARK100000 Row No. 2 - Expected: 2LUKESKYWALKER1000 - Row No. 3 - Actual: JESSICAJONES42345 + Row No. 3 - Actual: 4JESSICAJONES2345 Row No. 3 - Expected: 3TONYSTARK100000 Row No. 4 - Extra: MLUKESKYWALKER21000]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -887,7 +886,7 @@ Rows: [ 4 differences ] select 'F' AS GENDER, 'JESSICA' as FIRST_NAME, 'JONES' AS LAST_NAME, 4 as ID, '2345' AS SALARY from dual union all select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered_columns; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered_columns; l_expected_message := q'[Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 3 ] Diff: Columns: @@ -896,9 +895,9 @@ Columns: Rows: [ 4 differences ] Row No. 1 - Actual: 25000 Row No. 1 - Expected: 10000 - Row No. 2 - Actual: TONYSTARK3100000 + Row No. 2 - Actual: 3TONYSTARK100000 Row No. 2 - Expected: 2LUKESKYWALKER1000 - Row No. 3 - Actual: JESSICAJONES42345 + Row No. 3 - Actual: 4JESSICAJONES2345 Row No. 3 - Expected: 3TONYSTARK100000 Row No. 4 - Extra: MLUKESKYWALKER21000]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -957,7 +956,7 @@ Rows: [ 4 differences ] from dual; open l_actual for q'[select * from test_table_for_cursors]'; --Act - ut3.ut.expect(l_expected).to_equal(l_actual); + ut3_develop.ut.expect(l_expected).to_equal(l_actual); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -969,7 +968,7 @@ Rows: [ 4 differences ] --Arrange open l_actual for select 1 as value from dual; --Act - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); --Assert ut.expect(l_actual%isopen).to_be_false(); end; @@ -982,7 +981,7 @@ Rows: [ 4 differences ] open l_actual for select 1/0 as value from dual; --Act begin - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); exception when others then null; @@ -997,7 +996,7 @@ Rows: [ 4 differences ] begin --Act open l_actual for select 1/0 as error_column from dual connect by level < 10; - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); ut.fail('Expected exception on cursor fetch'); exception @@ -1015,7 +1014,7 @@ Rows: [ 4 differences ] open l_actual for select * from dual; close l_actual; --Act - ut3.ut.expect( l_actual ).not_to_be_null; + ut3_develop.ut.expect( l_actual ).not_to_be_null; exception when others then --Assert @@ -1031,7 +1030,7 @@ Rows: [ 4 differences ] open l_actual for select rownum object_name from dual connect by level <=1100; open l_expected for select rownum object_name from dual connect by level <=1100; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -1047,7 +1046,7 @@ Rows: [ 4 differences ] procedure deprec_to_equal_excl_varch is begin --Act - ut3.ut.expect(get_cursor()).to_equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col'); + ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col'); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -1056,7 +1055,7 @@ Rows: [ 4 differences ] procedure deprec_to_equal_excl_list is begin --Act - ut3.ut.expect(get_cursor()).to_equal(get_cursor(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); + ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor(), a_exclude => ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -1065,7 +1064,7 @@ Rows: [ 4 differences ] procedure deprec_not_to_equal_excl_varch is begin --Act - ut3.ut.expect(get_cursor()).not_to_equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col'); + ut3_develop.ut.expect(get_cursor()).not_to_equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col'); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -1074,7 +1073,7 @@ Rows: [ 4 differences ] procedure deprec_not_to_equal_excl_list is begin --Act - ut3.ut.expect(get_cursor()).not_to_equal(get_cursor(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); + ut3_develop.ut.expect(get_cursor()).not_to_equal(get_cursor(), a_exclude => ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -1083,7 +1082,7 @@ Rows: [ 4 differences ] procedure deprec_equal_excl_varch is begin --Act - ut3.ut.expect(get_cursor()).to_(ut3.equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col')); + ut3_develop.ut.expect(get_cursor()).to_(ut3_develop.equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col')); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -1092,7 +1091,7 @@ Rows: [ 4 differences ] procedure deprec_equal_excl_list is begin --Act - ut3.ut.expect(get_cursor()).to_(ut3.equal(get_cursor(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'))); + ut3_develop.ut.expect(get_cursor()).to_(ut3_develop.equal(get_cursor(), a_exclude => ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col'))); --Assert ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); @@ -1108,7 +1107,7 @@ Rows: [ 4 differences ] open l_actual for select '1' , '2' from dual connect by level <=2; open l_expected for select rownum , rownum expected_column_name from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] %Diff: @@ -1134,7 +1133,7 @@ Rows: [ 4 differences ] open l_actual for select '1' , rownum from dual connect by level <=2; open l_expected for select '1' , rownum from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1147,7 +1146,7 @@ Rows: [ 4 differences ] open l_actual for select username , user_id from all_users order by username asc; open l_expected for select username , user_id from all_users order by username desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1160,7 +1159,7 @@ Rows: [ 4 differences ] open l_actual for select user_id, username from all_users order by username asc; open l_expected for select username , user_id from all_users order by username desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered().uc(); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered().uc(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1182,7 +1181,7 @@ Rows: [ 4 differences ] select 'test' username,-667 user_id from dual order by 1 desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 2 differences ]% @@ -1202,7 +1201,7 @@ Rows: [ 4 differences ] open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID').uc(); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID').uc(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1216,7 +1215,7 @@ Rows: [ 4 differences ] open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1232,15 +1231,13 @@ Rows: [ 4 differences ] open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual; open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ).join_by('COL_1').unordered_columns; + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).join_by('COL_1').unordered_columns; --Assert l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] %Diff: %Rows: [ 1 differences ] -%PK 1 - Actual: 30 -%PK 1 - Expected: 3 -%PK 1 - Actual: 40 -%PK 1 - Expected: 4]'; +%PK 1 - Actual: 3040 +%PK 1 - Expected: 34]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1255,7 +1252,7 @@ Rows: [ 4 differences ] open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('OBJECT_ID,OBJECT_NAME')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('OBJECT_ID,OBJECT_NAME')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1271,7 +1268,7 @@ Rows: [ 4 differences ] open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% @@ -1294,7 +1291,7 @@ Diff:% open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('OWNER,USER_ID')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('OWNER,USER_ID')); --Assert l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% @@ -1319,7 +1316,7 @@ Diff:% open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('SOME_COL').exclude('SOME_COL'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('SOME_COL').exclude('SOME_COL'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% @@ -1342,7 +1339,7 @@ Diff:% open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('RN,SOME_COL')).exclude('RN'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('RN,SOME_COL')).exclude('RN'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% @@ -1365,7 +1362,7 @@ Diff:% open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% @@ -1387,7 +1384,7 @@ Diff:% open l_expected for select rownum as rni, 'x' SOME_COL from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% @@ -1406,7 +1403,7 @@ Diff:% open l_actual for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; open l_expected for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1419,7 +1416,7 @@ Diff:% open l_actual for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; open l_expected for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1438,7 +1435,7 @@ Diff:% select 'TEST' username, -610 user_id from dual order by 1 asc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('USERNAME'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('USERNAME'); --Assert l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% @@ -1464,7 +1461,7 @@ Diff:% select 'TEST' username, -610 user_id from dual order by 1 asc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('USERNAME,USER_ID')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('USERNAME,USER_ID')); --Assert l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% @@ -1490,7 +1487,7 @@ Diff:% select 'TEST' username, -610 user_id,'Y' is_valid from dual order by 1 asc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('USERNAME,IS_VALID')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('USERNAME,IS_VALID')); --Assert l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% @@ -1511,7 +1508,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).unordered; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).unordered; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1525,7 +1522,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1539,7 +1536,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1553,7 +1550,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN|//Some_Col')).unordered; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN|//Some_Col')).unordered; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1567,7 +1564,7 @@ Diff:% open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1581,7 +1578,7 @@ Diff:% open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1595,7 +1592,7 @@ Diff:% open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN')).exclude(ut3.ut_varchar2_list('A_COLUMN')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN')).exclude(ut3_develop.ut_varchar2_list('A_COLUMN')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1612,7 +1609,7 @@ Diff:% from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1629,7 +1626,7 @@ Diff:% from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1648,7 +1645,7 @@ Diff:% from dual connect by level <=3 order by rownum desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]% Diff:% Rows: [ 5 differences% @@ -1674,7 +1671,7 @@ Rows: [ 5 differences% from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -1691,7 +1688,7 @@ Rows: [ 5 differences% from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('RN,COLVAL/ID')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('RN,COLVAL/ID')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1710,7 +1707,7 @@ Rows: [ 5 differences% from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/IDS'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/IDS'); l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% Diff:% @@ -1725,16 +1722,16 @@ Diff:% procedure compare_nest_tab_col_jb is l_actual sys_refcursor; l_expected sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_actual_tab from dual connect by level <=2; - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_expected_tab from dual connect by level <=2; @@ -1746,7 +1743,7 @@ Diff:% from table(l_expected_tab) order by 1 desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -1755,16 +1752,16 @@ Diff:% procedure compare_nest_tab_col_jb_fail is l_actual sys_refcursor; l_expected sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_actual_tab from dual connect by level <=2; - select ut3.ut_key_value_pair(rownum,'Somethings '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Somethings '||rownum) bulk collect into l_expected_tab from dual connect by level <=2; @@ -1776,7 +1773,7 @@ Diff:% from table(l_expected_tab) order by 1 desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 2 differences ]% @@ -1792,16 +1789,16 @@ Diff:% procedure compare_nest_tab_cols_jb is l_actual sys_refcursor; l_expected sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_actual_tab from dual connect by level <=2; - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_expected_tab from dual connect by level <=2; @@ -1813,7 +1810,7 @@ Diff:% from table(l_expected_tab) order by 1 desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('KEY,VALUE')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('KEY,VALUE')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -1822,16 +1819,16 @@ Diff:% procedure compare_nest_tab_cols_jb_fail is l_actual sys_refcursor; l_expected sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_actual_tab from dual connect by level <=2; - select ut3.ut_key_value_pair(rownum,'Somethings '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Somethings '||rownum) bulk collect into l_expected_tab from dual connect by level <=2; @@ -1843,7 +1840,7 @@ Diff:% from table(l_expected_tab) order by 1 desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('KEY,VALUE')); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('KEY,VALUE')); l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 4 differences ]% @@ -1859,16 +1856,16 @@ Diff:% procedure compare_tabtype_as_cols_jb is l_actual sys_refcursor; l_expected sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_actual_tab from dual connect by level <=2; - select ut3.ut_key_value_pair(rownum,'Somethings '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Somethings '||rownum) bulk collect into l_expected_tab from dual connect by level <=2; @@ -1880,7 +1877,7 @@ Diff:% from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% @@ -1899,16 +1896,16 @@ Diff:% procedure compare_tabtype_as_cols is l_actual sys_refcursor; l_expected sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_actual_tab from dual connect by level <=2 order by rownum asc; - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_expected_tab from dual connect by level <=2 order by rownum asc; @@ -1920,7 +1917,7 @@ Diff:% from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -1929,16 +1926,16 @@ Diff:% procedure compare_tabtype_as_cols_coll is l_actual sys_refcursor; l_expected sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Apples '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Apples '||rownum) bulk collect into l_actual_tab from dual connect by level <=2; - select ut3.ut_key_value_pair(rownum,'Peaches '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Peaches '||rownum) bulk collect into l_expected_tab from dual connect by level <=2; @@ -1950,7 +1947,7 @@ Diff:% from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/UT_KEY_VALUE_PAIRS'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/UT_KEY_VALUE_PAIRS'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] @@ -1972,10 +1969,10 @@ Diff:% l_actual_tab some_object; l_expected_tab some_object; begin - select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_actual_tab from dual; - select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_expected_tab from dual; --Arrange @@ -1984,7 +1981,7 @@ Diff:% open l_expected for select l_expected_tab as nested_table from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -1996,10 +1993,10 @@ Diff:% l_actual_tab some_object; l_expected_tab some_object; begin - select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_actual_tab from dual; - select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_expected_tab from dual; --Arrange @@ -2008,7 +2005,7 @@ Diff:% open l_expected for select l_expected_tab as nested_table from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -2020,10 +2017,10 @@ Diff:% l_actual_tab some_object; l_expected_tab some_object; begin - select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_actual_tab from dual; - select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_expected_tab from dual; --Arrange @@ -2032,7 +2029,7 @@ Diff:% open l_expected for select l_expected_tab as nested_table from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -2045,12 +2042,11 @@ Diff:% l_expected_tab some_object; l_expected_message varchar2(32767); l_actual_message varchar2(32767); - l_date date := sysdate; begin - select some_object( 'TEST','TEST', l_date, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) + select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) into l_actual_tab from dual; - select some_object( 'TEST','TEST', l_date, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) + select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) into l_expected_tab from dual; --Arrange @@ -2061,7 +2057,7 @@ Diff:% from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] @@ -2082,10 +2078,10 @@ Diff:% l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select some_object( 'TEST','TEST', sysdate, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) + select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) into l_actual_tab from dual; - select some_object( 'TEST','TEST', sysdate, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) + select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) into l_expected_tab from dual; --Arrange @@ -2094,7 +2090,7 @@ Diff:% open l_expected for select l_expected_tab as nested_table from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS/ID'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS/ID'); --Assert l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]% @@ -2128,7 +2124,7 @@ Diff:% select 'Table' as name from dual; --Assert - ut3.ut.expect( l_actual ).to_equal( l_expected ).unordered(); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).unordered(); --Assert l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ] @@ -2152,7 +2148,7 @@ Diff:% and rownum < 20; --Act - ut3.ut.expect(l_actual).to_contain(l_expected); + ut3_develop.ut.expect(l_actual).to_contain(l_expected); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2168,7 +2164,7 @@ Diff:% and rownum < 20; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).uc(); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).uc(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2185,7 +2181,7 @@ Diff:% select rownum owner, rownum||'name' object_name,'PACKAGE' object_type from dual connect by level < 10; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).unordered(); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).unordered(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2201,7 +2197,7 @@ Diff:% open l_expected for select rownum owner,rownum object_name, 'PACKAGE' object_type from dual connect by level < 10; --Act - ut3.ut.expect(l_actual).to_contain(l_expected); + ut3_develop.ut.expect(l_actual).to_contain(l_expected); --Assert l_expected_message := q'[%Actual: refcursor [ count = 4 ] was expected to contain: refcursor [ count = 9 ] %Diff: @@ -2225,7 +2221,7 @@ Diff:% open l_expected for select username ,user_id from all_users where rownum < 5; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME'); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2247,7 +2243,7 @@ Diff:% order by 1 asc; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME'); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME'); --Assert l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to contain: refcursor [ count = % ] %Diff: @@ -2269,7 +2265,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 6; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2283,7 +2279,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2297,7 +2293,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2311,7 +2307,7 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_contain(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN|//Some_Col')); + ut3_develop.ut.expect(l_actual).to_contain(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN|//Some_Col')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2328,11 +2324,28 @@ Diff:% select 'TEST1' username, -601 user_id from dual; --Act - ut3.ut.expect(l_actual).not_to_contain(l_expected); + ut3_develop.ut.expect(l_actual).not_to_contain(l_expected); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; + procedure cursor_not_to_contain2 + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_expected for select 'TEST' username, -600 user_id from dual; + + open l_actual for select username, user_id from all_users + union all + select 'TEST1' username, -601 user_id from dual; + + --Act + ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected)); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + procedure cursor_not_to_contain_fail is l_actual sys_refcursor; l_expected sys_refcursor; @@ -2347,7 +2360,38 @@ Diff:% select 'TEST' username, -600 user_id from dual; --Act - ut3.ut.expect(l_actual).not_to_contain(l_expected); + ut3_develop.ut.expect(l_actual).not_to_contain(l_expected); + --Assert + l_expected_message := q'[%Actual: (refcursor [ count = % ])% +%Data-types:% +%VARCHAR2NUMBER% +%Data:% +%was expected not to contain:(refcursor [ count = 1 ])% +%Data-types:% +%CHARNUMBER% +%Data:% +%TEST-600%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + + procedure cursor_not_to_contain_fail2 is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Arrange + open l_expected for select 'TEST' username, -600 user_id from dual; + + open l_actual for select username, user_id from all_users + union all + select 'TEST' username, -600 user_id from dual; + + --Act + ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected)); --Assert l_expected_message := q'[%Actual: (refcursor [ count = % ])% %Data-types:% @@ -2372,11 +2416,25 @@ Diff:% open l_expected for select username||to_char(rownum) username ,rownum user_id from all_users where rownum < 5; --Act - ut3.ut.expect(l_actual).not_to_contain(l_expected).join_by('USER_ID'); + ut3_develop.ut.expect(l_actual).not_to_contain(l_expected).join_by('USER_ID'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; - + + procedure cursor_not_to_contain_joinby2 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select username,rownum * 10 user_id from all_users where rownum < 5; + open l_expected for select username||to_char(rownum) username ,rownum user_id from all_users where rownum < 5; + + --Act + ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected).join_by('USER_ID')); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + procedure not_cont_join_incl_cols_as_lst is l_actual sys_refcursor; l_expected sys_refcursor; @@ -2385,11 +2443,24 @@ Diff:% open l_actual for select rownum as rn, 'b' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; open l_expected for select rownum * 20 rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).not_to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); + ut3_develop.ut.expect(l_actual).not_to_contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; + procedure not_con_join_incl_cols_as_lst2 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'b' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; + open l_expected for select rownum * 20 rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; + --Act + ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN')); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + procedure not_cont_join_excl_cols_as_lst is l_actual sys_refcursor; l_expected sys_refcursor; @@ -2398,7 +2469,20 @@ Diff:% open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'y' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; open l_expected for select rownum * 20 as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).not_to_contain(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); + ut3_develop.ut.expect(l_actual).not_to_contain(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure not_con_join_excl_cols_as_lst2 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'y' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; + open l_expected for select rownum * 20 as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; + --Act + ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN')); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2414,7 +2498,7 @@ Diff:% open l_expected for select rownum as rn from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_contain(l_expected); + ut3_develop.ut.expect(l_actual).to_contain(l_expected); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2431,7 +2515,7 @@ Diff:% union all select rownum as rn from dual a connect by level < 4; --Act - ut3.ut.expect(l_actual).to_contain(l_expected); + ut3_develop.ut.expect(l_actual).to_contain(l_expected); --Assert l_expected_message := q'[%Actual: refcursor [ count = 9 ] was expected to contain: refcursor [ count = 6 ] %Diff: @@ -2444,14 +2528,24 @@ Diff:% ut.expect(l_actual_message).to_be_like(l_expected_message); end; + procedure to_not_contain_fails_1245 is + c1 sys_refcursor; + c2 sys_refcursor; + begin + open c1 for select 'a' as letter from dual union all select 'b' from dual; + open c2 for select 'c' as letter from dual; + ut3_develop.ut.expect(c1).not_to(ut3_develop.contain(c2)); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + procedure udt_messg_format_eq is l_actual sys_refcursor; l_expected sys_refcursor; - l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_expected_tab from dual connect by level <=2; @@ -2460,7 +2554,7 @@ Diff:% open l_expected for select value(x) as udt from table(l_expected_tab) x; --Act - ut3.ut.expect(l_actual).to_contain(l_expected); + ut3_develop.ut.expect(l_actual).to_contain(l_expected); --Assert l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to contain: refcursor [ count = 2 ] %Diff: @@ -2478,11 +2572,11 @@ Diff:% procedure udt_messg_format_empt is l_actual sys_refcursor; - l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); l_actual_message varchar2(32767); l_expected_message varchar2(32767); begin - select ut3.ut_key_value_pair(rownum,'Something '||rownum) + select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) bulk collect into l_actual_tab from dual connect by level <=2; @@ -2490,7 +2584,7 @@ Diff:% open l_actual for select value(x) as udt from table(l_actual_tab) x; --Act - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); --Assert l_expected_message := q'[%Actual: (refcursor [ count = 2 ]) %Data-types: @@ -2511,7 +2605,7 @@ Diff:% begin l_exp_message :='ORA-20218: SQL exception thrown when fetching data from cursor: ORA-01476: divisor is equal to zero -at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2522 ut3.ut.expect(l_actual).to_equal(l_expected);% +at "UT3_USER.TEST_EXPECTATIONS_CURSOR%", line % ut3_develop.ut.expect(l_actual).to_equal(l_expected);% Check the query and data for errors.'; open l_actual for @@ -2519,7 +2613,7 @@ Check the query and data for errors.'; open l_expected for select 1/0 as test from dual; - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); --Line that error relates to in expected messag ut.fail('Expected exception on cursor fetch'); @@ -2536,7 +2630,7 @@ Check the query and data for errors.'; l_exp_message :='ORA-20218: SQL exception thrown when fetching data from cursor: ORA-01476: divisor is equal to zero -at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2547 ut3.ut.expect(l_actual).to_equal(l_expected);% +at "UT3_USER.TEST_EXPECTATIONS_CURSOR%", line % ut3_develop.ut.expect(l_actual).to_equal(l_expected);% Check the query and data for errors.'; open l_expected for @@ -2544,7 +2638,7 @@ Check the query and data for errors.'; open l_actual for select 1 as test from dual; - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); ut.fail('Expected exception on cursor fetch'); exception @@ -2556,7 +2650,7 @@ Check the query and data for errors.'; l_actual sys_refcursor; l_expected sys_refcursor; begin - ut3.ut.set_nls; + ut3_develop.ut.set_nls; open l_expected for select cast(3.14 as binary_double) as pi_double, cast(3.14 as binary_float) as pi_float, @@ -2573,10 +2667,10 @@ Check the query and data for errors.'; numtoyminterval(1.1, 'year') row_ym_interval from dual; --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - ut3.ut.reset_nls; + ut3_develop.ut.reset_nls; end; @@ -2601,7 +2695,7 @@ Check the query and data for errors.'; OPEN l_exp_cur FOR SELECT l_exp.key, l_exp.value FROM dual; - ut3.ut.expect(l_act_cur).to_equal(l_exp_cur); + ut3_develop.ut.expect(l_act_cur).to_equal(l_exp_cur); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2617,7 +2711,7 @@ Check the query and data for errors.'; OPEN l_exp_cur FOR SELECT 1 as "$Test", 2 as "&Test" FROM dual; - ut3.ut.expect(l_act_cur).to_equal(l_exp_cur); + ut3_develop.ut.expect(l_act_cur).to_equal(l_exp_cur); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2633,13 +2727,13 @@ Check the query and data for errors.'; OPEN l_exp_cur FOR SELECT 1 as "", 2 as "_Test", 3 as ".Test>" FROM dual; - ut3.ut.expect(l_act_cur).to_equal(l_exp_cur); + ut3_develop.ut.expect(l_act_cur).to_equal(l_exp_cur); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; - procedure insginificant_whitespace1 is + procedure space_only_vs_empty is l_actual sys_refcursor; l_expected sys_refcursor; begin @@ -2649,80 +2743,66 @@ Check the query and data for errors.'; open l_actual for select column_value t1 from table(ut_varchar2_list(' ')); --Assert - ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; - procedure insginificant_whitespace2 is + procedure tab_only_vs_empty is l_actual sys_refcursor; l_expected sys_refcursor; begin open l_expected for - select ' t ' t1 from dual; - - open l_actual for - select 't' t1 from dual; - --Assert - ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure insginificant_whitespace3 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_expected for - select 't ' t1 from dual; - + select column_value t1 from table(ut_varchar2_list('')); + open l_actual for - select 't' t1 from dual; + select column_value t1 from table(ut_varchar2_list(chr(9))); --Assert - ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; - - procedure insginificant_whitespace4 is + + procedure insignificant_start_end_space is l_actual sys_refcursor; l_expected sys_refcursor; begin open l_expected for - select ' t' t1 from dual; + select ' t ' t1 from dual; open l_actual for select 't' t1 from dual; --Assert - ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; - procedure insginificant_whitespace5 is + procedure double_vs_single_start_end_ws is l_actual sys_refcursor; l_expected sys_refcursor; begin open l_expected for - select ' ' t1 from dual; + select ' t ' t1 from dual; open l_actual for - select '' t1 from dual; + select ' t ' t1 from dual; --Assert - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; + end; - procedure nulltowhitespace is + procedure leading_tab_vs_space is l_actual sys_refcursor; l_expected sys_refcursor; begin open l_expected for - select cast(null as varchar2(2)) t1 from dual; + select ' t' t1 from dual; open l_actual for - select ' ' t1 from dual; + select chr(9)||'t' t1 from dual; --Assert - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - + end; + procedure number_from_dual is l_actual sys_refcursor; l_expected sys_refcursor; @@ -2746,7 +2826,7 @@ Check the query and data for errors.'; 7456123.9 as n6, 7456123.89 as n7 from dual; - ut3.ut.expect(l_actual).to_equal(l_expected); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2763,8 +2843,6 @@ Check the query and data for errors.'; l_expected_data(1).col4 := 2016; l_expected_data(1).col5 := -1; - --Select on package level nested table types supported only since Oracle 12 - $if dbms_db_version.version >= 12 $then open l_expected for select * from table (l_expected_data); @@ -2778,7 +2856,7 @@ Check the query and data for errors.'; ,-1 as col5 from dual; - ut3.ut.expect(l_actual).to_equal(a_expected => l_expected); + ut3_develop.ut.expect(l_actual).to_equal(a_expected => l_expected); l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] %Diff: @@ -2789,7 +2867,6 @@ Check the query and data for errors.'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); ut.expect(l_actual_message).to_be_like(l_expected_message); - $end end; procedure uc_columns_exclude is @@ -2801,7 +2878,7 @@ Check the query and data for errors.'; open v_actual for select 'ok' name, to_number(null) id from dual; - ut3.ut.expect(v_actual).to_equal(v_expected).exclude('ID'); + ut3_develop.ut.expect(v_actual).to_equal(v_expected).exclude('ID'); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2810,19 +2887,144 @@ Check the query and data for errors.'; l_expected sys_refcursor; begin -- populate actual - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - open l_actual for - select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; + open l_actual for + select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; - open l_expected for - select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; + open l_expected for + select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; - ut3.ut.expect(l_actual).to_equal(l_expected).include('ID,SOME_COLUMN_WITH_A_PRETTY_LONG_ENOUGH_NAME').join_by('ID'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - $else - null; - $end + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include('ID,SOME_COLUMN_WITH_A_PRETTY_LONG_ENOUGH_NAME').join_by('ID'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure compare_column_names_over_max_identifier is + l_actual sys_refcursor; + l_expected sys_refcursor; + --An unaliased literal gets a column name longer than an identifier can be + l_sql varchar2(4000) := 'select '''||rpad('a',ora_max_name_len_supported + 10,'a')||''' from dual'; + begin + --Act + open l_actual for l_sql; + open l_expected for l_sql; + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + --Act + open l_actual for l_sql; + open l_expected for l_sql||' connect by level <= 2'; + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); + end; + + procedure compare_varchar2_described_over_4000 is + l_actual sys_refcursor; + l_expected sys_refcursor; + --A dynamic bind longer than 4000 chars is described as a varchar2 longer than 4000, even with max_string_size=standard + c_sql constant varchar2(100) := 'select :some_text as some_text from dual'; + begin + --Act + open l_actual for c_sql using rpad('x',4001,'x'); + open l_expected for c_sql using rpad('x',4001,'x'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + --Act + open l_actual for c_sql using rpad('x',4001,'x'); + open l_expected for c_sql using rpad('y',4001,'y'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); + end; + + procedure compare_specific_column_names is + function get_cursor return sys_refcursor is + l_result sys_refcursor; + begin + open l_result for + select 'a' as item_data, rownum as data_id, rownum as item_no, rownum as dup_no, rownum as position from dual; + return l_result; + end; + begin + ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor()); + ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor()).unordered(); + ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor()).join_by('ITEM_DATA,DATA_ID,ITEM_NO,DUP_NO'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure multiple_cursor_expectations is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_actual for select rownum rn from dual connect by level < 5; + open l_expected for select rownum rn from dual connect by level = 1; + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + open l_actual for select rownum rn from dual connect by level < 3; + open l_expected for select * from (select rownum rn from dual connect by level < 3) order by 1 desc; + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations(1)).to_equal( +'Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 1 ] +Diff: +Rows: [ 3 differences ] + Row No. 2 - Extra: 2 + Row No. 3 - Extra: 3 + Row No. 4 - Extra: 4' + ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations(2)).to_equal( +'Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] +Diff: +Rows: [ 2 differences ] + Row No. 1 - Actual: 1 + Row No. 1 - Expected: 2 + Row No. 2 - Actual: 2 + Row No. 2 - Expected: 1' + ); + end; + + procedure cr_joinby_compare_issue_1293 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_expected for + select 'FOO' username, 12 from dual union all + select 'TEST' username, -600 user_id from dual + order by 1 desc; + open l_actual for + select 'FOO' username, 12 from dual union all + select 'TEST' username, -600 user_id from dual union all + -- DUPLICATE!!! + select 'TEST' username, -600 user_id from dual + order by 1 asc; + --Act + ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('USERNAME'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure cr_not_joinby_comp_issue_1293 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_expected for + select 'FOO' username, 12 from dual union all + select 'TEST' username, -600 user_id from dual + order by 1 desc; + open l_actual for + select 'FOO' username, 12 from dual union all + select 'TEST' username, -600 user_id from dual union all + -- DUPLICATE!!! + select 'TEST' username, -600 user_id from dual + order by 1 asc; + --Act + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; diff --git a/test/ut3_user/expectations/test_expectations_cursor.pks b/test/ut3_user/expectations/test_expectations_cursor.pks index 82fc47f3c..d7ff823de 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pks +++ b/test/ut3_user/expectations/test_expectations_cursor.pks @@ -376,24 +376,42 @@ create or replace package test_expectations_cursor is --%test( Cursor not to contains data from another cursor) procedure cursor_not_to_contain; + --%test( Cursor not_to[contain] data from another cursor) + procedure cursor_not_to_contain2; + --%test( Cursor fail not to contains data from another cursor) procedure cursor_not_to_contain_fail; - + + --%test( Cursor fail not_to[contain] data from another cursor) + procedure cursor_not_to_contain_fail2; + --%test( Cursor not contains data from another cursor with joinby clause) procedure cursor_not_to_contain_joinby; + --%test( Cursor not_to[contain] data from another cursor with joinby clause) + procedure cursor_not_to_contain_joinby2; + --%test(Cursor not contains data with of columns to include and join by value) procedure not_cont_join_incl_cols_as_lst; + --%test(Cursor not_to[contain] data with of columns to include and join by value) + procedure not_con_join_incl_cols_as_lst2; + --%test(Cursor not contains data with of columns to exclude and join by value) procedure not_cont_join_excl_cols_as_lst; + --%test(Cursor not_to[contain] data with of columns to exclude and join by value) + procedure not_con_join_excl_cols_as_lst2; + --%test(Cursor to contain duplicates) procedure to_contain_duplicates; --%test(Cursor to contain duplicates fail) procedure to_contain_duplicates_fail; - + + --%test(Cursor using not_to[contain] fails #1245) + procedure to_not_contain_fails_1245; + --%test(Display a message with a uer defined type with only type name not structure on equal) procedure udt_messg_format_eq; @@ -417,31 +435,27 @@ create or replace package test_expectations_cursor is --%test(Check that column name accept non xml characters fix #902) procedure nonxmlchar_part_of_colname; - - - /*Oracle Bug not readin properly in xmltable */ - --%test ( Compare insiginificant whitespaces scenario 1 ) + + + /*Oracle Bug not reading properly in XMLTable - See - Issue #880 */ + --%disabled + --%test ( Space-only string is not equal empty string ) + procedure space_only_vs_empty; + + /*Oracle Bug not reading properly in XMLTable - See - Issue #880 */ --%disabled - procedure insginificant_whitespace1; + --%test ( Tab-only string is not equal empty string ) + procedure tab_only_vs_empty; - --%test ( Compare insiginificant whitespaces scenario 2 ) - procedure insginificant_whitespace2; + --%test ( Insignificant start/end whitespaces are considered ) + procedure insignificant_start_end_space; - --%test ( Compare insiginificant whitespaces scenario 3 ) - procedure insginificant_whitespace3; + --%test ( Double and single leading/trailing space is distinguished ) + procedure double_vs_single_start_end_ws; - --%test ( Compare insiginificant whitespaces scenario 4 ) - procedure insginificant_whitespace4; + --%test ( Leading Tab vs. Space is distinguished ) + procedure leading_tab_vs_space; - /*Oracle Bug not readin properly in xmltable */ - --%test ( Compare insiginificant whitespaces scenario 5 ) - --%disabled - procedure insginificant_whitespace5; - - /*Oracle Bug not readin properly in xmltable */ - --%test ( Compare null to whitespace ) - --%disabled - procedure nulltowhitespace; --%test(Check precision of number from dual #907) procedure number_from_dual; @@ -462,8 +476,26 @@ create or replace package test_expectations_cursor is --%test( Mixed column order exclusion ) procedure uc_columns_exclude; - --%test(Compares cursors with long column names - Issue #952 ) + --%test( Compares cursors with long column names - Issue #952 ) procedure compare_long_column_names; + --%test( Compares cursors with column names longer than the maximum identifier length ) + procedure compare_column_names_over_max_identifier; + + --%test( Compares cursors with varchar2 columns described as longer than 4000 ) + procedure compare_varchar2_described_over_4000; + + --%test( Compares cursors with specific column names - Issue #997 ) + procedure compare_specific_column_names; + + --%test( Multiple failures reported correctly - Issue #998 ) + procedure multiple_cursor_expectations; + + --%test( Compares cursors with duplicate rows using join by - Issue #1293 ) + procedure cr_joinby_compare_issue_1293; + + --%test( Compares cursors with duplicate rows - Issue #1293 ) + procedure cr_not_joinby_comp_issue_1293; + end; / diff --git a/test/ut3_user/expectations/test_expectations_json.pkb b/test/ut3_user/expectations/test_expectations_json.pkb index 6214d2237..2c501d71f 100644 --- a/test/ut3_user/expectations/test_expectations_json.pkb +++ b/test/ut3_user/expectations/test_expectations_json.pkb @@ -49,7 +49,7 @@ create or replace package body test_expectations_json is }'); --Act - ut3.ut.expect( l_actual ).to_equal( l_actual ); + ut3_develop.ut.expect( l_actual ).to_( ut3_develop.equal( l_actual ) ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -62,15 +62,13 @@ create or replace package body test_expectations_json is l_actual_message varchar2(32767); begin -- Arrange - l_expected := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); - l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thron\"es","The Wire"],"string": "some string","int": 2,"aboolean": true, "boolean": true,"object": {"foo": "bar","object1": {"new prop1": "new prop value"},"object2": {"new prop1": "new prop value"},"object3": {"new prop1": "new prop value"},"object4": {"new prop1": "new prop value"}}},"Amy Ryan": {"one": "In Treatment","two": "The Wire"},"Annie Fitzgerald": ["Big Love","True Blood"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsgard": ["Generation Kill","True Blood"], "Clarke Peters": null}'); + l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + l_expected := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thron\"es","The Wire"],"string": "some string","int": 2,"aboolean": true, "boolean": true,"object": {"foo": "bar","object1": {"new prop1": "new prop value"},"object2": {"new prop1": "new prop value"},"object3": {"new prop1": "new prop value"},"object4": {"new prop1": "new prop value"}}},"Amy Ryan": {"one": "In Treatment","two": "The Wire"},"Annie Fitzgerald": ["Big Love","True Blood"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsgard": ["Generation Kill","True Blood"], "Clarke Peters": null}'); --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert - l_expected_message := q'[%Diff: 20 differences found -%3 incorrect types, 4 unequal values, 13 missing properties -%Missing property: "Alexander Skarsg?rd" on path: $ + l_expected_message := q'[%Missing property: "Alexander Skarsg?rd" on path: $ %Extra property: "Alexander Skarsgard" on path: $ %Missing property: "Alice Farmer" on path: $ %Extra property: "Clarke Peters" on path: $ @@ -93,6 +91,10 @@ create or replace package body test_expectations_json is l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); + ut.expect(l_actual_message).to_be_like('%Diff: 20 differences found%'); + ut.expect(l_actual_message).to_be_like('%13 missing properties%'); + ut.expect(l_actual_message).to_be_like('%4 unequal values%'); + ut.expect(l_actual_message).to_be_like('%3 incorrect types%'); end; procedure null_json_variable @@ -103,7 +105,7 @@ create or replace package body test_expectations_json is l_expected := cast (null as json_object_t ); --Act - ut3.ut.expect( l_expected ).to_be_null; + ut3_develop.ut.expect( l_expected ).to_be_null; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -116,7 +118,7 @@ create or replace package body test_expectations_json is l_expected := json_object_t(); --Act - ut3.ut.expect( l_expected ).not_to_be_null; + ut3_develop.ut.expect( l_expected ).not_to_be_null; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -131,7 +133,7 @@ create or replace package body test_expectations_json is l_expected := json_object_t('{ "t" : "1" }'); --Act - ut3.ut.expect( l_expected ).to_be_null; + ut3_develop.ut.expect( l_expected ).to_be_null; --Assert l_expected_message := q'[%Actual: (json) %'{"t":"1"}' @@ -151,7 +153,7 @@ create or replace package body test_expectations_json is l_expected := cast (null as json_object_t ); --Act - ut3.ut.expect( l_expected ).not_to_be_null; + ut3_develop.ut.expect( l_expected ).not_to_be_null; --Assert l_expected_message := q'[%Actual: NULL (json) was expected not to be null%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -167,7 +169,7 @@ create or replace package body test_expectations_json is l_expected := json_object_t(); --Act - ut3.ut.expect( l_expected ).to_be_empty; + ut3_develop.ut.expect( l_expected ).to_be_empty; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -180,7 +182,7 @@ create or replace package body test_expectations_json is l_expected := json_object_t.parse('{ "name" : "test" }'); --Act - ut3.ut.expect( l_expected ).not_to_be_empty; + ut3_develop.ut.expect( l_expected ).not_to_be_empty; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -195,7 +197,7 @@ create or replace package body test_expectations_json is l_expected := json_object_t.parse('{ "name" : "test" }'); --Act - ut3.ut.expect( l_expected ).to_be_empty; + ut3_develop.ut.expect( l_expected ).to_be_empty; --Assert l_expected_message := q'[%Actual: (json) %'{"name":"test"}' @@ -215,7 +217,7 @@ create or replace package body test_expectations_json is l_expected := json_object_t(); --Act - ut3.ut.expect( l_expected ).not_to_be_empty; + ut3_develop.ut.expect( l_expected ).not_to_be_empty; --Assert l_expected_message := q'[%Actual: (json) %'{}' @@ -234,7 +236,7 @@ create or replace package body test_expectations_json is l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); --Act - ut3.ut.expect( l_actual ).to_have_count( 6 ); + ut3_develop.ut.expect( l_actual ).to_have_count( 6 ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -251,7 +253,7 @@ create or replace package body test_expectations_json is l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); --Act - ut3.ut.expect( l_actual ).to_have_count( 2 ); + ut3_develop.ut.expect( l_actual ).to_have_count( 2 ); --Assert l_expected_message := q'[%Actual: (json [ count = 6 ]) was expected to have [ count = 2 ]%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -270,7 +272,7 @@ create or replace package body test_expectations_json is l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); --Act - ut3.ut.expect( l_actual ).not_to_have_count( 7 ); + ut3_develop.ut.expect( l_actual ).not_to_have_count( 7 ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -285,7 +287,7 @@ create or replace package body test_expectations_json is l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); --Act - ut3.ut.expect( l_actual ).not_to_have_count( 6 ); + ut3_develop.ut.expect( l_actual ).not_to_have_count( 6 ); --Assert l_expected_message := q'[%Actual: json [ count = 6 ] was expected not to have [ count = 6 ]%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -303,7 +305,7 @@ create or replace package body test_expectations_json is l_actual := json_element_t.parse('["Game of Thrones","The Wire"]'); --Act - ut3.ut.expect( l_actual ).to_have_count( 2 ); + ut3_develop.ut.expect( l_actual ).to_have_count( 2 ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -371,7 +373,7 @@ create or replace package body test_expectations_json is --Act - ut3.ut.expect(json_array_t(json_query(l_actual.stringify,'$.Actors.children'))).to_equal(json_array_t(json_query(l_expected + ut3_develop.ut.expect(json_array_t(json_query(l_actual.stringify,'$.Actors.children'))).to_equal(json_array_t(json_query(l_expected .stringify,'$.Actors[1].children'))); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); @@ -385,7 +387,7 @@ create or replace package body test_expectations_json is l_actual_message varchar2(32767); begin -- Arrange - l_expected := json_object_t.parse(' { + l_actual := json_object_t.parse(' { "Actors": [ { "name": "Tom Cruise", @@ -422,7 +424,7 @@ create or replace package body test_expectations_json is ] }' ); - l_actual := json_object_t.parse(' { + l_expected := json_object_t.parse(' { "Actors": { "name": "Krzystof Jarzyna", @@ -442,8 +444,8 @@ create or replace package body test_expectations_json is --Act - ut3.ut.expect(json_array_t(json_query(l_actual.stringify,'$.Actors.children'))).to_equal(json_array_t(json_query(l_expected - .stringify,'$.Actors[1].children'))); + ut3_develop.ut.expect(json_array_t(json_query(l_actual.stringify,'$.Actors[1].children'))).to_equal(json_array_t(json_query(l_expected + .stringify,'$.Actors.children'))); --Assert l_expected_message := q'[%Actual: json was expected to equal: json %Diff: 1 differences found @@ -732,7 +734,7 @@ create or replace package body test_expectations_json is ]'); --Act - ut3.ut.expect( l_actual ).to_equal( l_actual ); + ut3_develop.ut.expect( l_actual ).to_equal( l_actual ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -759,7 +761,7 @@ create or replace package body test_expectations_json is }'); --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1041,7 +1043,7 @@ create or replace package body test_expectations_json is ]'); --Act - ut3.ut.expect( l_actual ).to_equal( l_actual ); + ut3_develop.ut.expect( l_actual ).to_equal( l_actual ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1053,7 +1055,7 @@ create or replace package body test_expectations_json is l_actual_message varchar2(32767); begin -- Arrange - l_expected := json_element_t.parse('[ + l_actual := json_element_t.parse('[ { "_id": "5ce6ec46cb9977b050f15d97", "index": 0, @@ -1280,7 +1282,7 @@ create or replace package body test_expectations_json is "favoriteFruit": "strawberry" } ]'); - l_actual := json_element_t.parse('[ + l_expected := json_element_t.parse('[ { "_id": "5ce6ec6660565269b16cf836", "index": 0, @@ -1554,11 +1556,9 @@ create or replace package body test_expectations_json is ]'); --Act - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); --Assert - l_expected_message := q'[%Diff: 133 differences found, showing first 20 -%132 unequal values, 1 missing properties -%Extra property: object on path: $[5] + l_expected_message := q'[%Extra property: object on path: $[5] %Actual value: "5ce6ec46cb9977b050f15d97" was expected to be: "5ce6ec6660565269b16cf836" on path: $[0]."_id" %Actual value: "5ce6ec469ba57bef5c421021" was expected to be: "5ce6ec66383ddbf3c400e3ed" on path: $[1]."_id" %Actual value: "5ce6ec4632328a654d592cb6" was expected to be: "5ce6ec6600fb7aaee2d1243e" on path: $[3]."_id" @@ -1582,6 +1582,9 @@ create or replace package body test_expectations_json is l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); + ut.expect(l_actual_message).to_be_like('%Diff: 133 differences found, showing first 20%'); + ut.expect(l_actual_message).to_be_like('%1 missing properties%'); + ut.expect(l_actual_message).to_be_like('%132 unequal values%'); end; procedure check_json_objects is @@ -1590,7 +1593,7 @@ create or replace package body test_expectations_json is begin l_expected := json_object_t('{ "name" : "Bond", "proffesion" : "spy", "drink" : "martini"}'); l_actual := json_object_t('{ "proffesion" : "spy","name" : "Bond", "drink" : "martini"}'); - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1600,10 +1603,205 @@ create or replace package body test_expectations_json is begin l_expected := json_array_t('[ {"name" : "Bond", "proffesion" : "spy", "drink" : "martini"} , {"name" : "Kloss", "proffesion" : "spy", "drink" : "beer"} ]'); l_actual := json_array_t('[ {"name" : "Bond", "proffesion" : "spy", "drink" : "martini"} , {"name" : "Kloss", "proffesion" : "spy", "drink" : "beer"} ]'); - ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + $if dbms_db_version.version >= 21 $then + + procedure success_on_same_data_njson + as + l_actual json; + begin + -- Arrange + l_actual := json(' { + "Actors": [ + { + "name": "Tom Cruise", + "age": 56, + "Born At": "Syracuse, NY", + "Birthdate": "July 3, 1962", + "photo": "https://jsonformatter.org/img/tom-cruise.jpg", + "wife": null, + "weight": 67.5, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Suri", + "Isabella Jane", + "Connor" + ] + }, + { + "name": "Robert Downey Jr.", + "age": 53, + "Born At": "New York City, NY", + "Birthdate": "April 4, 1965", + "photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg", + "wife": "Susan Downey", + "weight": 77.1, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + ] + }'); + + --Act + ut3_develop.ut.expect( l_actual ).to_equal( l_actual ); + --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; + + procedure fail_on_diff_data_njson + as + l_expected json; + l_actual json; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + l_expected := json('{"Aidan Gillen": {"array": ["Game of Thron\"es","The Wire"],"string": "some string","int": 2,"aboolean": true, "boolean": true,"object": {"foo": "bar","object1": {"new prop1": "new prop value"},"object2": {"new prop1": "new prop value"},"object3": {"new prop1": "new prop value"},"object4": {"new prop1": "new prop value"}}},"Amy Ryan": {"one": "In Treatment","two": "The Wire"},"Annie Fitzgerald": ["Big Love","True Blood"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsgard": ["Generation Kill","True Blood"], "Clarke Peters": null}'); + --Act + ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); + --Assert + l_expected_message := q'[%Missing property: "Alexander Skarsg?rd" on path: $ +%Extra property: "Alexander Skarsgard" on path: $ +%Missing property: "Alice Farmer" on path: $ +%Extra property: "Clarke Peters" on path: $ +%Extra property: "one" on path: $."Amy Ryan" +%Missing property: "The Sopranos" on path: $."Annie Fitzgerald"[2] +%Extra property: "two" on path: $."Amy Ryan" +%Missing property: "Oz" on path: $."Annie Fitzgerald"[3] +%Missing property: "otherint" on path: $."Aidan Gillen" +%Extra property: "object1" on path: $."Aidan Gillen"."object" +%Extra property: "object2" on path: $."Aidan Gillen"."object" +%Extra property: "object3" on path: $."Aidan Gillen"."object" +%Extra property: "object4" on path: $."Aidan Gillen"."object" +%Actual type: 'array' was expected to be: 'object' on path: $."Amy Ryan" +%Actual type: 'string' was expected to be: 'number' on path: $."Aidan Gillen"."int" +%Actual type: 'string' was expected to be: 'boolean' on path: $."Aidan Gillen"."aboolean" +%Actual value: "True Blood" was expected to be: "Big Love" on path: $."Annie Fitzgerald"[0] +%Actual value: "Big Love" was expected to be: "True Blood" on path: $."Annie Fitzgerald"[1] +%Actual value: FALSE was expected to be: TRUE on path: $."Aidan Gillen"."boolean" +%Actual value: "Game of Thrones" was expected to be: "Game of Thron\"es" on path: $."Aidan Gillen"."array"[0]%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + ut.expect(l_actual_message).to_be_like('%Diff: 20 differences found%'); + ut.expect(l_actual_message).to_be_like('%13 missing properties%'); + ut.expect(l_actual_message).to_be_like('%4 unequal values%'); + ut.expect(l_actual_message).to_be_like('%3 incorrect types%'); + end; + + --Please note that by the looks of things the call to json() results in null value being returned. + procedure null_json_variable_njson + as + l_expected json ; + begin + -- Arrange + l_expected := cast (null as json ); + + --Act + ut3_develop.ut.expect( l_expected ).to_be_null; + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure to_have_count_njson as + l_actual json; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3_develop.ut.expect( l_actual ).to_have_count( 6 ); + + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure fail_to_have_count_njson + as + l_actual json; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3_develop.ut.expect( l_actual ).to_have_count( 2 ); + --Assert + l_expected_message := q'[%Actual: (json [ count = 6 ]) was expected to have [ count = 2 ]%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure not_to_have_count_njson + as + l_actual json; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3_develop.ut.expect( l_actual ).not_to_have_count( 7 ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure fail_not_to_have_count_njson + as + l_actual json; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3_develop.ut.expect( l_actual ).not_to_have_count( 6 ); + --Assert + l_expected_message := q'[%Actual: json [ count = 6 ] was expected not to have [ count = 6 ]%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + $end + + procedure p_1113_reg_exp_chg_with_act is + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + ut3_develop.ut.expect(json_element_t.parse('{"a":"value a"}')).to_equal(json_element_t.parse('{"a":"value b"}')); + + --Assert + l_expected_message := q'[%Actual: json was expected to equal: json +%Diff: 1 differences found +%1 unequal values +%Actual value: "value a" was expected to be: "value b" on path: $."a"%]'; + + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + end; / diff --git a/test/ut3_user/expectations/test_expectations_json.pks b/test/ut3_user/expectations/test_expectations_json.pks index 64dff42e8..410c3050b 100644 --- a/test/ut3_user/expectations/test_expectations_json.pks +++ b/test/ut3_user/expectations/test_expectations_json.pks @@ -39,13 +39,13 @@ create or replace package test_expectations_json is --%test( Json object to have count ) procedure to_have_count; - --%test( Fail Json object to have count) + --%test( Fail Json object to have count) procedure fail_to_have_count; --%test( Json object not to have count) procedure not_to_have_count; - --%test( Fail Json object not to have count) + --%test( Fail Json object not to have count) procedure fail_not_to_have_count; --%test( Json object to have count on array) @@ -74,6 +74,34 @@ create or replace package test_expectations_json is --%test( Compare two json arrays ) procedure check_json_arrays; + + $if dbms_db_version.version >= 21 $then + + --%test(Gives success for identical data using native json for 21c and above) + procedure success_on_same_data_njson; + + --%test(Gives failure for different data using native json for 21c and above) + procedure fail_on_diff_data_njson; + + --%test( Json variable is null using native json for 21c and above) + procedure null_json_variable_njson; + + --%test( Json object to have count using native json for 21c and above) + procedure to_have_count_njson; + + --%test( Fail Json object to have count using native json for 21c and above) + procedure fail_to_have_count_njson; + + --%test( Json object not to have count using native json for 21c and above) + procedure not_to_have_count_njson; + + --%test( Fail Json object not to have count using native json for 21c and above) + procedure fail_not_to_have_count_njson; + + $end + --%test( Regression scenario tests for issue #1113 where the expected has been switched with actual) + procedure p_1113_reg_exp_chg_with_act; + end; / diff --git a/test/ut3_user/expectations/test_matchers.pkb b/test/ut3_user/expectations/test_matchers.pkb index 88e25e8b1..e1d87d4cb 100644 --- a/test/ut3_user/expectations/test_matchers.pkb +++ b/test/ut3_user/expectations/test_matchers.pkb @@ -13,7 +13,7 @@ create or replace package body test_matchers is l_actual '||a_type||' := '||a_actual_value||'; l_expected '||a_type||' := '||a_expected_value||'; begin - ut3.ut.expect( l_actual ).'||a_prefix||'to_'||a_matcher||'( l_expected ); + ut3_develop.ut.expect( l_actual ).'||a_prefix||'to_'||a_matcher||'( l_expected ); end;'; execute immediate l_statement; if a_result = ut3_tester_helper.main_helper.gc_success then @@ -33,7 +33,7 @@ create or replace package body test_matchers is l_lower '||a_type||' := '||a_expected1_value||'; l_higher '||a_type||' := '||a_expected2_value||'; begin - ut3.ut.expect(l_actual_value).to_be_between(l_lower, l_higher); + ut3_develop.ut.expect(l_actual_value).to_be_between(l_lower, l_higher); end;'; execute immediate l_statement; if a_result = ut3_tester_helper.main_helper.gc_success then @@ -53,7 +53,7 @@ create or replace package body test_matchers is l_value1 '||a_type||' := '||a_expected1_value||'; l_value2 '||a_type||' := '||a_expected2_value||'; begin - ut3.ut.expect(l_actual_value).'||a_not_prefix||'to_be_between(l_value1, l_value2); + ut3_develop.ut.expect(l_actual_value).'||a_not_prefix||'to_be_between(l_value1, l_value2); end;'; execute immediate l_statement; if a_result = ut3_tester_helper.main_helper.gc_success then @@ -73,7 +73,7 @@ create or replace package body test_matchers is l_escape_char varchar2(32767) := :a_escape; l_result integer; begin - ut3.ut.expect( l_actual ).' || a_prefix ||q'[to_be_like(l_pattern, l_escape_char); + ut3_develop.ut.expect( l_actual ).' || a_prefix ||q'[to_be_like(l_pattern, l_escape_char); end;]' using a_pattern, a_escape; if a_result = ut3_tester_helper.main_helper.gc_success then @@ -94,7 +94,7 @@ create or replace package body test_matchers is l_modifiers varchar2(32767) := :a_modifiers; l_result integer; begin - ut3.ut.expect( l_actual ).'||a_not_prefix||'to_match(l_pattern, l_modifiers); + ut3_develop.ut.expect( l_actual ).'||a_not_prefix||'to_match(l_pattern, l_modifiers); end;'; execute immediate l_statement using a_pattern, a_modifiers; if a_result = ut3_tester_helper.main_helper.gc_success then @@ -245,8 +245,8 @@ create or replace package body test_matchers is l_value_lower timestamp := to_timestamp('1997-01-31 09:26:50.11','YYYY-MM-DD HH24.MI.SS.FF'); l_value_upper timestamp := to_timestamp('1997-01-31 09:26:50.14','YYYY-MM-DD HH24.MI.SS.FF'); begin - ut3.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); - ut3.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); + ut3_develop.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); + ut3_develop.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); end; procedure test_timestamp_ltz_between is @@ -254,8 +254,8 @@ create or replace package body test_matchers is l_value_lower timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); l_value_upper timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); begin - ut3.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); - ut3.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); + ut3_develop.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); + ut3_develop.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); end; procedure test_timestamp_tz_between is @@ -263,8 +263,8 @@ create or replace package body test_matchers is l_value_lower timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); l_value_upper timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); begin - ut3.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); - ut3.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); + ut3_develop.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); + ut3_develop.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); end; end test_matchers; diff --git a/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb index 1447bd1f0..931e24d10 100644 --- a/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb +++ b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb @@ -10,7 +10,7 @@ create or replace package body test_expect_to_be_empty is --Arrange open l_cursor for select * from dual where 1 = 2; --Act - ut3.ut.expect(l_cursor).to_be_empty; + ut3_develop.ut.expect(l_cursor).to_be_empty; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -21,7 +21,7 @@ create or replace package body test_expect_to_be_empty is --Arrange open l_cursor for select * from dual; --Act - ut3.ut.expect(l_cursor).to_be_empty; + ut3_develop.ut.expect(l_cursor).to_be_empty; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -34,7 +34,7 @@ create or replace package body test_expect_to_be_empty is --Arrange open l_cursor for select * from dual; --Act - ut3.ut.expect(l_cursor).to_be_empty; + ut3_develop.ut.expect(l_cursor).to_be_empty; l_expected_message := q'[Actual: (refcursor [ count = 1 ])% X% @@ -51,7 +51,7 @@ create or replace package body test_expect_to_be_empty is --Arrange open l_cursor for select * from dual; --Act - ut3.ut.expect(l_cursor).not_to_be_empty; + ut3_develop.ut.expect(l_cursor).not_to_be_empty; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -62,7 +62,7 @@ create or replace package body test_expect_to_be_empty is --Arrange open l_cursor for select * from dual where 1 = 2; --Act - ut3.ut.expect(l_cursor).not_to_be_empty; + ut3_develop.ut.expect(l_cursor).not_to_be_empty; --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -73,7 +73,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); -- Act - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -84,7 +84,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); -- Act - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -95,7 +95,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); -- Act - ut3.ut.expect(l_actual).not_to_be_empty(); + ut3_develop.ut.expect(l_actual).not_to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -106,7 +106,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); -- Act - ut3.ut.expect(l_actual).not_to_be_empty(); + ut3_develop.ut.expect(l_actual).not_to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -118,7 +118,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertcollection(l_data); -- Act - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -130,7 +130,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertcollection(l_data); -- Act - ut3.ut.expect(l_actual).not_to_be_empty(); + ut3_develop.ut.expect(l_actual).not_to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -141,7 +141,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -153,7 +153,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertObject(l_data); -- Act - ut3.ut.expect(l_actual).to_be_empty(); + ut3_develop.ut.expect(l_actual).to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -161,7 +161,7 @@ create or replace package body test_expect_to_be_empty is procedure fail_be_empty_number is begin -- Act - ut3.ut.expect( 1 ).to_( ut3.be_empty() ); + ut3_develop.ut.expect( 1 ).to_( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -176,7 +176,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act - ut3.ut.expect(l_actual).not_to_be_empty(); + ut3_develop.ut.expect(l_actual).not_to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -188,7 +188,7 @@ create or replace package body test_expect_to_be_empty is --Arrange l_actual := anydata.convertObject(l_data); -- Act - ut3.ut.expect(l_actual).not_to_be_empty(); + ut3_develop.ut.expect(l_actual).not_to_be_empty(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -196,7 +196,7 @@ create or replace package body test_expect_to_be_empty is procedure fail_not_be_empty_number is begin -- Act - ut3.ut.expect( 1 ).not_to( ut3.be_empty() ); + ut3_develop.ut.expect( 1 ).not_to( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -204,7 +204,7 @@ create or replace package body test_expect_to_be_empty is procedure success_be_empty_clob is begin -- Act - ut3.ut.expect( empty_clob() ).to_( ut3.be_empty() ); + ut3_develop.ut.expect( empty_clob() ).to_( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -212,7 +212,7 @@ create or replace package body test_expect_to_be_empty is procedure fail_be_empty_clob is begin -- Act - ut3.ut.expect( to_clob(' ') ).to_( ut3.be_empty() ); + ut3_develop.ut.expect( to_clob(' ') ).to_( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -220,7 +220,7 @@ create or replace package body test_expect_to_be_empty is procedure success_be_empty_blob is begin -- Act - ut3.ut.expect( empty_blob() ).to_( ut3.be_empty() ); + ut3_develop.ut.expect( empty_blob() ).to_( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -228,7 +228,7 @@ create or replace package body test_expect_to_be_empty is procedure fail_be_empty_blob is begin -- Act - ut3.ut.expect( to_blob('AA') ).to_( ut3.be_empty() ); + ut3_develop.ut.expect( to_blob('AA') ).to_( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -237,7 +237,7 @@ create or replace package body test_expect_to_be_empty is procedure fail_not_be_empty_clob is begin -- Act - ut3.ut.expect( empty_clob() ).not_to( ut3.be_empty() ); + ut3_develop.ut.expect( empty_clob() ).not_to( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -245,7 +245,7 @@ create or replace package body test_expect_to_be_empty is procedure success_not_be_empty_clob is begin -- Act - ut3.ut.expect( to_clob(' ') ).not_to( ut3.be_empty() ); + ut3_develop.ut.expect( to_clob(' ') ).not_to( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -253,7 +253,7 @@ create or replace package body test_expect_to_be_empty is procedure fail_not_be_empty_blob is begin -- Act - ut3.ut.expect( empty_blob() ).not_to( ut3.be_empty() ); + ut3_develop.ut.expect( empty_blob() ).not_to( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -261,7 +261,7 @@ create or replace package body test_expect_to_be_empty is procedure success_not_be_empty_blob is begin -- Act - ut3.ut.expect( to_blob('AA') ).not_to( ut3.be_empty() ); + ut3_develop.ut.expect( to_blob('AA') ).not_to( ut3_develop.be_empty() ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; diff --git a/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb index 6a621c6b3..c1067044b 100644 --- a/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb +++ b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb @@ -9,7 +9,7 @@ is procedure to_be_true_null_boolean is begin --Act - ut3.ut.expect( 1=null ).to_be_true(); + ut3_develop.ut.expect( 1=null ).to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -17,7 +17,7 @@ is procedure to_be_true_success is begin --Act - ut3.ut.expect( 1=1 ).to_be_true(); + ut3_develop.ut.expect( 1=1 ).to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -25,7 +25,7 @@ is procedure to_be_true_failure is begin --Act - ut3.ut.expect( 1=2 ).to_be_true(); + ut3_develop.ut.expect( 1=2 ).to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -33,7 +33,7 @@ is procedure to_be_true_bad_type is begin --Act - ut3.ut.expect( 1 ).to_be_true(); + ut3_develop.ut.expect( 1 ).to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -41,7 +41,7 @@ is procedure not_to_be_true_null_boolean is begin --Act - ut3.ut.expect( 1=null ).not_to_be_true(); + ut3_develop.ut.expect( 1=null ).not_to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -49,7 +49,7 @@ is procedure not_to_be_true_success is begin --Act - ut3.ut.expect( 1=2 ).not_to_be_true(); + ut3_develop.ut.expect( 1=2 ).not_to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -57,7 +57,7 @@ is procedure not_to_be_true_failure is begin --Act - ut3.ut.expect( 1=1 ).not_to_be_true(); + ut3_develop.ut.expect( 1=1 ).not_to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -66,7 +66,7 @@ is procedure not_to_be_true_bad_type is begin --Act - ut3.ut.expect( 1 ).not_to_be_true(); + ut3_develop.ut.expect( 1 ).not_to_be_true(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -74,7 +74,7 @@ is procedure to_be_false_null_boolean is begin --Act - ut3.ut.expect( 1=null ).to_be_false(); + ut3_develop.ut.expect( 1=null ).to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -82,7 +82,7 @@ is procedure to_be_false_success is begin --Act - ut3.ut.expect( 1=2 ).to_be_false(); + ut3_develop.ut.expect( 1=2 ).to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -90,7 +90,7 @@ is procedure to_be_false_failure is begin --Act - ut3.ut.expect( 1=1 ).to_be_false(); + ut3_develop.ut.expect( 1=1 ).to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -98,7 +98,7 @@ is procedure to_be_false_bad_type is begin --Act - ut3.ut.expect( 1 ).to_be_false(); + ut3_develop.ut.expect( 1 ).to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -106,7 +106,7 @@ is procedure not_to_be_false_null_boolean is begin --Act - ut3.ut.expect( 1=null ).not_to_be_false(); + ut3_develop.ut.expect( 1=null ).not_to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -114,7 +114,7 @@ is procedure not_to_be_false_success is begin --Act - ut3.ut.expect( 1=1 ).not_to_be_false(); + ut3_develop.ut.expect( 1=1 ).not_to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -122,7 +122,7 @@ is procedure not_to_be_false_failure is begin --Act - ut3.ut.expect( 1=2 ).not_to_be_false(); + ut3_develop.ut.expect( 1=2 ).not_to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -130,7 +130,7 @@ is procedure not_to_be_false_bad_type is begin --Act - ut3.ut.expect( 1 ).not_to_be_false(); + ut3_develop.ut.expect( 1 ).not_to_be_false(); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; diff --git a/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb b/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb index 327ced120..2167c44ef 100644 --- a/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb +++ b/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb @@ -11,7 +11,7 @@ create or replace package body test_expect_to_have_count is --Arrange open l_cursor for select * from dual connect by level <= 11; --Act - ut3.ut.expect(l_cursor).to_have_count(11); + ut3_develop.ut.expect(l_cursor).to_have_count(11); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -22,7 +22,7 @@ create or replace package body test_expect_to_have_count is --Arrange open l_cursor for select * from dual where 0=1; --Act - ut3.ut.expect(l_cursor).to_have_count(1); + ut3_develop.ut.expect(l_cursor).to_have_count(1); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -35,7 +35,7 @@ create or replace package body test_expect_to_have_count is --Arrange open l_cursor for select * from dual; --Act - ut3.ut.expect(l_cursor).to_have_count(2); + ut3_develop.ut.expect(l_cursor).to_have_count(2); l_expected_message := q'[Actual: (refcursor [ count = 1 ]) was expected to have [ count = 2 ]%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -50,7 +50,7 @@ create or replace package body test_expect_to_have_count is --Arrange open l_cursor for select * from dual; --Act - ut3.ut.expect(l_cursor).not_to_have_count(2); + ut3_develop.ut.expect(l_cursor).not_to_have_count(2); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -61,7 +61,7 @@ create or replace package body test_expect_to_have_count is --Arrange open l_cursor for select * from dual where 1 = 2; --Act - ut3.ut.expect(l_cursor).not_to_have_count(0); + ut3_develop.ut.expect(l_cursor).not_to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -72,7 +72,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); -- Act - ut3.ut.expect(l_actual).to_have_count(0); + ut3_develop.ut.expect(l_actual).to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -83,7 +83,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); -- Act - ut3.ut.expect(l_actual).to_have_count(0); + ut3_develop.ut.expect(l_actual).to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -94,7 +94,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); -- Act - ut3.ut.expect(l_actual).not_to_have_count(2); + ut3_develop.ut.expect(l_actual).not_to_have_count(2); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -105,7 +105,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); -- Act - ut3.ut.expect(l_actual).not_to_have_count(0); + ut3_develop.ut.expect(l_actual).not_to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -117,7 +117,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertcollection(l_data); -- Act - ut3.ut.expect(l_actual).to_have_count(0); + ut3_develop.ut.expect(l_actual).to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -129,7 +129,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertcollection(l_data); -- Act - ut3.ut.expect(l_actual).not_to_have_count(0); + ut3_develop.ut.expect(l_actual).not_to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -140,7 +140,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act - ut3.ut.expect(l_actual).to_have_count(0); + ut3_develop.ut.expect(l_actual).to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -152,7 +152,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertObject(l_data); -- Act - ut3.ut.expect(l_actual).to_have_count(0); + ut3_develop.ut.expect(l_actual).to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -162,7 +162,7 @@ create or replace package body test_expect_to_have_count is l_actual_message varchar2(32767); begin -- Act - ut3.ut.expect( 1 ).to_( ut3.have_count(0) ); + ut3_develop.ut.expect( 1 ).to_( ut3_develop.have_count(0) ); --Assert l_expected_message := q'[%The matcher 'have count' cannot be used with data type (number).%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -178,7 +178,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act - ut3.ut.expect(l_actual).not_to_have_count(0); + ut3_develop.ut.expect(l_actual).not_to_have_count(0); --Assert l_expected_message := q'[%The matcher 'have count' cannot be used with data type (ut3_tester_helper.test_dummy_number).%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); @@ -193,7 +193,7 @@ create or replace package body test_expect_to_have_count is --Arrange l_actual := anydata.convertObject(l_data); -- Act - ut3.ut.expect(l_actual).not_to_have_count(0); + ut3_develop.ut.expect(l_actual).not_to_have_count(0); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -201,7 +201,7 @@ create or replace package body test_expect_to_have_count is procedure fail_not_have_count_number is begin -- Act - ut3.ut.expect( 1 ).not_to( ut3.have_count(0) ); + ut3_develop.ut.expect( 1 ).not_to( ut3_develop.have_count(0) ); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; diff --git a/test/ut3_user/reporters.pkb b/test/ut3_user/reporters.pkb index 6d6d573aa..031683615 100644 --- a/test/ut3_user/reporters.pkb +++ b/test/ut3_user/reporters.pkb @@ -14,8 +14,8 @@ as --%beforeeach procedure beforeeach; - --%context(some_context) - --%displayname(A description of some context) + --%context(A description of some context) + --%name(some_context) --%test --%beforetest(beforetest) @@ -35,9 +35,13 @@ as procedure erroring_test; --%test(a disabled test) - --%disabled + --%disabled(Disabled for testing purpose) procedure disabled_test; + --%test(a disabled test with no reason) + --%disabled + procedure disabled_test_no_reason; + --%aftereach procedure aftereach; @@ -74,30 +78,36 @@ as is begin dbms_output.put_line(''); - ut3.ut.expect(1,'Test 1 Should Pass').to_equal(1); + ut3_develop.ut.expect(1,'Test 1 Should Pass').to_equal(1); end; procedure failing_test is begin dbms_output.put_line(''); - ut3.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] '); + ut3_develop.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] '); end; procedure erroring_test is - l_variable integer; + l_integer_variable integer; begin dbms_output.put_line(''); - l_variable := 'a string'; - ut3.ut.expect(l_variable).to_equal(1); + l_integer_variable := 'a string'; end; procedure disabled_test is begin dbms_output.put_line(''); - ut3.ut.expect(1,'this should not execute').to_equal(1); + ut3_develop.ut.expect(1,'this should not execute').to_equal(1); + end; + + procedure disabled_test_no_reason + is + begin + dbms_output.put_line(''); + ut3_develop.ut.expect(1,'this should not execute').to_equal(1); end; procedure beforeall is @@ -124,7 +134,7 @@ end;]'; execute immediate q'[create or replace package body check_fail_escape is procedure fail_miserably is begin - ut3.ut.expect('test').to_equal(''); + ut3_develop.ut.expect('test').to_equal(''); end; end;]'; @@ -148,36 +158,36 @@ end;]'; end; procedure check_xml_encoding_included( - a_reporter ut3.ut_reporter_base, + a_reporter ut3_develop.ut_reporter_base, a_client_character_set varchar2 ) is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin --Act select * bulk collect into l_results - from table(ut3.ut.run('test_reporters', a_reporter, a_client_character_set => a_client_character_set)); + from table(ut3_develop.ut.run('test_reporters', a_reporter, a_client_character_set => a_client_character_set)); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%'); end; procedure check_xml_failure_escaped( - a_reporter ut3.ut_reporter_base + a_reporter ut3_develop.ut_reporter_base ) is - l_results ut3.ut_varchar2_list; + l_results ut3_develop.ut_varchar2_list; l_actual clob; begin --Act select * bulk collect into l_results - from table( ut3.ut.run( 'check_fail_escape', a_reporter ) ); + from table( ut3_develop.ut.run( 'check_fail_escape', a_reporter ) ); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%' (varchar2)%]' - ||q'[at "UT3$USER#.CHECK_FAIL_ESCAPE%", line % ut3.ut.expect('test').to_equal('');]' + ||q'[at "UT3_USER.CHECK_FAIL_ESCAPE%", line % ut3_develop.ut.expect('test').to_equal('');]' ||'%]]>%' ); end; diff --git a/test/ut3_user/reporters.pks b/test/ut3_user/reporters.pks index d1ed8635f..412091984 100644 --- a/test/ut3_user/reporters.pks +++ b/test/ut3_user/reporters.pks @@ -1,5 +1,7 @@ create or replace package reporters is + gc_support_line constant varchar2(200) := 'Using utPLSQL at work? Get support and help keep it maintained: https://utplsql.org/support'; + --%suite --%suitepath(utplsql.test_user) @@ -10,12 +12,12 @@ create or replace package reporters is procedure reporters_cleanup; procedure check_xml_encoding_included( - a_reporter ut3.ut_reporter_base, + a_reporter ut3_develop.ut_reporter_base, a_client_character_set varchar2 ); procedure check_xml_failure_escaped( - a_reporter ut3.ut_reporter_base + a_reporter ut3_develop.ut_reporter_base ); end reporters; diff --git a/test/ut3_user/reporters/test_coverage.pkb b/test/ut3_user/reporters/test_coverage.pkb deleted file mode 100644 index 738ce67e4..000000000 --- a/test/ut3_user/reporters/test_coverage.pkb +++ /dev/null @@ -1,19 +0,0 @@ -create or replace package body test_coverage is - - procedure create_dummy_coverage_pkg is - begin - ut3_tester_helper.coverage_helper.create_dummy_coverage_package(); - ut3_tester_helper.coverage_helper.create_dummy_coverage_test(); - ut3_tester_helper.coverage_helper.grant_exec_on_cov(); - end; - - procedure setup_dummy_coverage is - pragma autonomous_transaction; - begin - ut3_tester_helper.coverage_helper.setup_mock_coverage_id(); - ut3_tester_helper.coverage_helper.mock_coverage_data(user); - commit; - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage.pks b/test/ut3_user/reporters/test_coverage.pks index 4c19e125a..11bc6d480 100644 --- a/test/ut3_user/reporters/test_coverage.pks +++ b/test/ut3_user/reporters/test_coverage.pks @@ -3,15 +3,12 @@ create or replace package test_coverage is --%suite --%suitepath(utplsql.test_user.reporters) - --%beforeall - procedure create_dummy_coverage_pkg; - --%beforeall - procedure setup_dummy_coverage; + --%beforeall(ut3_tester_helper.coverage_helper.create_test_results_table) + --%beforeall(ut3_tester_helper.coverage_helper.create_dummy_coverage) - --%afterall(ut3_tester_helper.coverage_helper.drop_dummy_coverage_pkg) - - --%afterall(ut3_tester_helper.coverage_helper.cleanup_dummy_coverage) + --%afterall(ut3_tester_helper.coverage_helper.drop_dummy_coverage) + --%afterall(ut3_tester_helper.coverage_helper.drop_test_results_table) end; / diff --git a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb index 183492eb7..49e0410ba 100644 --- a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb @@ -1,100 +1,52 @@ create or replace package body test_cov_cobertura_reporter is procedure report_on_file is - l_results ut3.ut_varchar2_list; l_expected clob; l_actual clob; + l_block_cov clob; + l_name varchar2(250); + l_file_path varchar2(250); begin - --Arrange - l_expected := - q'[ - - - -test/ut3.dummy_coverage.pkb - - - - - - - - - - - - -]'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_cobertura_reporter( ), - a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ), - a_test_files => ut3.ut_varchar2_list( ) - ) - ); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - procedure report_zero_coverage is - l_results ut3.ut_varchar2_list; - l_expected clob; - l_actual clob; - begin + --Arrange + l_name := ut3_tester_helper.coverage_helper.covered_package_name; + l_file_path := 'test/ut3_develop.'||ut3_tester_helper.coverage_helper.covered_package_name||'.pkb'; + l_block_cov := ''; l_expected := q'[ - + -ut3.dummy_coverage +]'||l_file_path||q'[ - - + + + - - - - - +]'||l_block_cov||q'[ - - - - - - - - - + ]'; - - ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(); --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_cobertura_reporter( ), - a_include_objects => ut3.ut_varchar2_list('UT3.DUMMY_COVERAGE') - ) - ); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter => ut3_develop.ut_coverage_cobertura_reporter( ), + a_source_files => ut3_develop.ut_varchar2_list( ']'||l_file_path||q'[' ), + a_test_files => ut3_develop.ut_varchar2_list( ) + ) + ]' + ); --Assert ut.expect(l_actual).to_be_like(l_expected); - --Cleanup - test_coverage.setup_dummy_coverage; end; end; diff --git a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks index 0016641d5..365815964 100644 --- a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks +++ b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks @@ -6,8 +6,5 @@ create or replace package test_cov_cobertura_reporter is --%test(reports on a project file mapped to database object) procedure report_on_file; - --%test(reports zero coverage on each line of non-executed database object - Issue #917) - procedure report_zero_coverage; - end test_cov_cobertura_reporter; / diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb index 5cd53a093..9f2409637 100644 --- a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb @@ -1,38 +1,38 @@ create or replace package body test_coverage_sonar_reporter is procedure report_on_file is - l_results ut3.ut_varchar2_list; l_expected clob; l_actual clob; + l_block_cov clob; begin --Arrange + l_block_cov := ''; l_expected := ' - - - - + +'||l_block_cov||' + '; --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ), - a_test_files => ut3.ut_varchar2_list( ) - ) - ); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_source_files => ut3_develop.ut_varchar2_list( 'test/ut3_develop.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[.pkb' ), + a_test_files => ut3_develop.ut_varchar2_list( ) + ) + ]' + ); --Assert ut.expect(l_actual).to_equal(l_expected); end; procedure check_encoding_included is begin - reporters.check_xml_encoding_included(ut3.ut_coverage_sonar_reporter(), 'UTF-8'); + reporters.check_xml_encoding_included(ut3_develop.ut_coverage_sonar_reporter(), 'UTF-8'); end; end; diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb new file mode 100644 index 000000000..adf7b51d1 --- /dev/null +++ b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb @@ -0,0 +1,97 @@ +create or replace package body test_coverage_standalone is + + function run_coverage_twice(a_overage_run_id raw, a_object_name varchar2, a_charset varchar2) return clob is + l_expected clob; + l_block_cov clob; + l_file_path varchar2(250); + begin + l_file_path := 'package body ut3_develop.'||a_object_name; + --Arrange + l_block_cov := ''; + l_expected := + q'[ + + + +]'||l_file_path||q'[ + + + + + + +]'||l_block_cov||q'[ + + + + + + +]'; + --Act + ut3_tester_helper.coverage_helper.run_coverage_job(a_overage_run_id, 1); + ut3_tester_helper.coverage_helper.run_coverage_job(a_overage_run_id, 3); + return l_expected; + end; + + procedure coverage_without_ut_run is + l_coverage_run_id raw(32) := sys_guid(); + l_actual ut3_develop.ut_varchar2_list; + l_expected clob; + l_name varchar2(250); + l_charset varchar2(100) := 'ISO-8859-1'; + begin + l_name := ut3_tester_helper.coverage_helper.covered_package_name; + + --Arrange and Act + l_expected := run_coverage_twice(l_coverage_run_id, l_name, l_charset); + + select * + bulk collect into l_actual + from + table ( + ut3_develop.ut_coverage_cobertura_reporter().get_report( + a_coverage_options => ut3_develop.ut_coverage_options( + coverage_run_id => l_coverage_run_id, + include_objects => ut3_develop.ut_varchar2_rows(l_name), + schema_names => ut3_develop.ut_varchar2_rows('UT3_DEVELOP') + ), + a_client_character_set => l_charset + ) + ); + + --Assert + ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_actual)).to_be_like( l_expected ); + end; + + procedure coverage_cursor_without_ut_run is + l_coverage_run_id raw(32) := sys_guid(); + l_coverage_cursor sys_refcursor; + l_actual ut3_develop.ut_varchar2_list; + l_expected clob; + l_name varchar2(250); + l_charset varchar2(100) := 'ISO-8859-1'; + begin + l_name := ut3_tester_helper.coverage_helper.covered_package_name; + + --Arrange and Act + l_expected := run_coverage_twice(l_coverage_run_id, l_name, l_charset); + + l_coverage_cursor := + ut3_develop.ut_coverage_cobertura_reporter( ).get_report_cursor( + a_coverage_options => ut3_develop.ut_coverage_options( + coverage_run_id => l_coverage_run_id, + include_objects => ut3_develop.ut_varchar2_rows(l_name), + schema_names => ut3_develop.ut_varchar2_rows('UT3_DEVELOP') + ), + a_client_character_set => l_charset + ); + fetch l_coverage_cursor bulk collect into l_actual; + close l_coverage_cursor; + + --Assert + ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_actual)).to_be_like( l_expected ); + end; + +end; +/ diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pks b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pks new file mode 100644 index 000000000..1d5bb9a2c --- /dev/null +++ b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pks @@ -0,0 +1,12 @@ +create or replace package test_coverage_standalone authid current_user is + + --%suite + --%suitepath(utplsql.test_user.reporters.test_coverage) + + --%test(Coverage can be invoked standalone in multiple sessions and a combined report can be produced at the end) + procedure coverage_without_ut_run; + + --%test(Coverage can be invoked standalone in multiple sessions and a combined report can be produced at the end as cursor) + procedure coverage_cursor_without_ut_run; +end; +/ diff --git a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb deleted file mode 100644 index 2d36d45cb..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb +++ /dev/null @@ -1,90 +0,0 @@ -create or replace package body test_coveralls_reporter is - - procedure report_on_file is - l_results ut3.ut_varchar2_list; - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := q'[{"source_files":[ -{ "name": "test/ut3.dummy_coverage.pkb", -"coverage": [ -null, -null, -null, -1, -0, -null, -1 -] -} -]} - ]'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coveralls_reporter( ), - a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ), - a_test_files => ut3.ut_varchar2_list( ) - ) - ); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure report_zero_coverage is - l_results ut3.ut_varchar2_list; - l_expected clob; - l_actual clob; - pragma autonomous_transaction; - begin - --Arrange - l_expected := q'[{"source_files":[ -{ "name": "ut3.dummy_coverage", -"coverage": [ -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0 -] -} -]} - ]'; - - ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(); - - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - 'ut3.test_dummy_coverage', - ut3.ut_coveralls_reporter(), - a_include_objects => ut3.ut_varchar2_list('UT3.DUMMY_COVERAGE') - ) - ); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_equal(l_expected); - - test_coverage.setup_dummy_coverage; - - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks deleted file mode 100644 index d958b8f12..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks +++ /dev/null @@ -1,13 +0,0 @@ -create or replace package test_coveralls_reporter is - - --%suite(ut_coveralls_reporter) - --%suitepath(utplsql.test_user.reporters.test_coverage) - - --%test(reports on a project file mapped to database object) - procedure report_on_file; - - --%test(reports zero coverage on each line of non-executed database object) - procedure report_zero_coverage; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb new file mode 100644 index 000000000..f6f76b62f --- /dev/null +++ b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb @@ -0,0 +1,311 @@ +create or replace package body test_extended_coverage is + + function get_block_coverage_line return clob is + begin + return '%'; + end; + procedure coverage_for_object is + l_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%' || + get_block_coverage_line|| + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[' ) + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_for_schema is + l_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%' || + get_block_coverage_line || + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_coverage_schemes => ut3_develop.ut_varchar2_list( 'ut3_develop' ) + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).to_be_like('%%%'); + end; + + procedure coverage_for_file is + l_expected clob; + l_actual clob; + l_file_path varchar2(250); + begin + --Arrange + l_file_path := 'test/ut3_develop.'||ut3_tester_helper.coverage_helper.covered_package_name||'.pkb'; + l_expected := '%' || + get_block_coverage_line || + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_source_files => ut3_develop.ut_varchar2_list( ']'||l_file_path||q'[' ), + a_test_files => ut3_develop.ut_varchar2_list( ) + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_with_dbms_stats is + l_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%' || + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_stats', + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_coverage_schemes => ut3_develop.ut_varchar2_list( 'ut3_develop' ), + a_include_objects => ut3_develop.ut_varchar2_list('stats') + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_regex_include_schema is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%' || + '%%'; + l_not_expected := '%' || + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_tester_helper.test_regex_dummy_cov'), + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_include_schema_expr => '^ut3_tester_hel.*', + a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) + ) + ]' + ); + + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + ut.expect(l_actual).not_to_be_like('%ut3_tester_helper.test_regex_dummy_cov%'); + end; + + procedure coverage_regex_include_object is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%' || + '%%'; + l_not_expected := '%' || + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_develop.test_regex123_dummy_cov'), + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_include_object_expr => 'regex123', + a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + end; + + procedure coverage_regex_exclude_schema is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%' || + '%%'; + l_not_expected := '%' || + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_tester_helper.test_regex_dummy_cov'), + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_exclude_schema_expr => '^ut3_tester', + a_exclude_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + end; + + procedure coverage_regex_exclude_object is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%' || + '%%'; + l_not_expected := '%' || + '%%'; + --Act + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_develop.test_regex123_dummy_cov'), + a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), + a_exclude_object_expr => 'regex123', + a_exclude_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + end; + + procedure cove_rgx_inc_schema_norun is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; + l_not_expected := '%UT3_TESTER_HELPER.REGEX123_DUMMY_COV%'; + --Act + l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( + q'[ut3_develop.ut_coverage_options( + coverage_run_id => l_coverage_run_id, + include_schema_expr => '^ut3_develop' + )]'); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + end; + + procedure cove_rgx_inc_object_norun is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%UT3_DEVELOP.REGEX123_DUMMY_COV%'; + l_not_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; + --Act + l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( + q'[ut3_develop.ut_coverage_options( + coverage_run_id => l_coverage_run_id, + include_object_expr => 'regex123' + )]'); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + end; + + procedure cove_rgx_exc_schema_norun is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; + l_not_expected := '%UT3_TESTER_HELPER.REGEX_DUMMY_COV%'; + --Act + l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( + q'[ut3_develop.ut_coverage_options( + coverage_run_id => l_coverage_run_id, + schema_names => ut3_develop.ut_varchar2_rows( 'UT3_DEVELOP','UT3_TESTER_HELPER' ), + exclude_schema_expr => '^ut3_tester', + exclude_objects => ut3_develop.ut_varchar2_rows( 'ut3_develop.regex_dummy_cov' ) + )]'); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + end; + + procedure cove_rgx_exc_object_norun is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; + l_not_expected := '%UT3_DEVELOP.REGEX123_DUMMY_COV%'; + --Act + l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( + q'[ut3_develop.ut_coverage_options( + coverage_run_id => l_coverage_run_id, + schema_names => ut3_develop.ut_varchar2_rows( 'UT3_DEVELOP' ), + exclude_object_expr => 'regex123', + exclude_objects => ut3_develop.ut_varchar2_rows( 'ut3_develop.regex_dummy_cov' ) + )]'); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).not_to_be_like(l_not_expected); + end; + + procedure cov_file_mapping_no_utrun is + l_expected clob; + l_not_expected clob; + l_actual clob; + begin + --Arrange + l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; + --Act + l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( + q'[ut3_develop.ut_coverage_options( + coverage_run_id => l_coverage_run_id, + file_mappings => ut3_develop.ut_file_mappings( ut3_develop.ut_file_mapping('C:\tests\helpers\core.pkb','UT3_DEVELOP','REGEX_DUMMY_COV','PACKAGE BODY')) + )]'); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + end; + +end; +/ diff --git a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pks b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pks new file mode 100644 index 000000000..82b19fbed --- /dev/null +++ b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pks @@ -0,0 +1,66 @@ +create or replace package test_extended_coverage is + + --%suite + --%suitepath(utplsql.test_user.reporters.test_coverage) + + --%test(Coverage is gathered for specified object - extended coverage type) + procedure coverage_for_object; + + --%test(Coverage is gathered for specified schema - extended coverage type) + procedure coverage_for_schema; + + --%test(Coverage is gathered for specified file - extended coverage type) + procedure coverage_for_file; + + --%beforetest(ut3_tester_helper.coverage_helper.create_cov_with_dbms_stats) + --%aftertest(ut3_tester_helper.coverage_helper.drop_cov_with_dbms_stats) + --%tags(#1097,#1094) + --%test(Extended coverage does not fail the test run then tested code calls DBMS_STATS) + procedure coverage_with_dbms_stats; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with schema regex include with ut_run) + procedure coverage_regex_include_schema; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with object regex include with ut_run) + procedure coverage_regex_include_object; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with schema regex exclude with ut_run) + procedure coverage_regex_exclude_schema; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with object regex exclude with ut_run) + procedure coverage_regex_exclude_object; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with schema regex include without ut_run) + procedure cove_rgx_inc_schema_norun; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with object regex include without ut_run) + procedure cove_rgx_inc_object_norun; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with schema regex exclude without ut_run) + procedure cove_rgx_exc_schema_norun; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for objects with object regex exclude without ut_run) + procedure cove_rgx_exc_object_norun; + + --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) + --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) + --%test(Collect coverage for file mapping without ut_run) + procedure cov_file_mapping_no_utrun; +end; +/ diff --git a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb new file mode 100644 index 000000000..883909eb5 --- /dev/null +++ b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb @@ -0,0 +1,119 @@ +create or replace package body test_html_coverage_reporter is + + procedure report_on_file is + l_expected varchar2(32767); + l_actual clob; + l_block_cov clob; + l_name varchar2(250); + l_charset varchar2(100) := 'ISO-8859-1'; + begin + --Arrange + l_name := ut3_tester_helper.coverage_helper.covered_package_name; + l_block_cov := '(including 1 lines partially covered ) '; + l_expected := '%%

    UT3_DEVELOP.'||upper(l_name)||'

    ' || + '%2 relevant lines. 1 lines covered ' || + l_block_cov || 'and 1 lines missed%'; + + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter=> ut3_develop.ut_coverage_html_reporter(), + a_source_files => ut3_develop.ut_varchar2_list( 'test/ut3_develop.]'||l_name||q'[.pkb' ), + a_test_files => ut3_develop.ut_varchar2_list( ), + a_client_character_set => ']'||l_charset||q'[' + ) + ]' + ); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure report_support_link is + l_actual clob; + begin + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter=> ut3_develop.ut_coverage_html_reporter() + ) + ]' + ); + + ut.expect(l_actual).to_be_like( + '%