Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ability to run expectations without test #963

Merged
merged 7 commits into from Jul 13, 2019

Conversation

@jgebal
Copy link
Member

commented Jul 2, 2019

Added ability to run expectations without tests

Expectation, when executed without test, reports results straight to dbms_output.

So it is now possible to execute:
exec ut.expect(1).to_equal(0);

And get result:

FAILURE
  Actual: 1 (number) was expected to equal: 0 (number)

Resolves #956

Improvements to application_info in v$session

utPLSQL is now cleaning up the application_info after run. The module_name, action, client_info` are restored to it's original values after test run. Resolves #951

The following attributes are set in v$session when test suite is running:

  • module_name - set to utPLSQL
  • action - name of currently executing test suite package
  • client_info name of test executable procedure (before.../after.../test) that is currently running

Setting session context during run

It is now possible to access some of utPLSQL info within the test procedures directly.
Resolves #781

The information is provided in sys_context( 'UT3_INFO', attribute ).

Following attributes are getting 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)

Call stack enchancements

utPLSQL will now provide full call stack within the context of the test, not only the stack line where expectation was called.
To minimize overhead on test execution, stack is provided only when expectation fails.

Resolves #967

Improved functionality of reporters

Reporters will now support inline calls for data-retrieval.
References #955

@jgebal jgebal added the enhancement label Jul 2, 2019

jgebal added 2 commits Jul 2, 2019
[WIP] Ability to run expectations without test
> TODO - documentation updates

Added ability to run expectations without tests.
Expectation, when executed without test is reporter straight to dbms_output.
So it is now possible to execute:

`exec ut.expect(1).to_equal(0);`

And get result:

```
FAILURE
  Actual: 1 (number) was expected to equal: 0 (number)
```

Resolves #956

Additionally:
- utPLSQL is now cleaning up the application_info after run.
- utPLSQL is setting session context during run, making it possible to access some of utPLSQL info within the test procedures directly.

Resolves #781

The information is provided in sys_context(`UT3_INFO`,...).

Following attributes are getting populated:
- Always:
    - RUN_PATHS
    - SUITE_DESCRIPTION
    - SUITE_PACKAGE
    - SUITE_PATH
    - SUITE_START_TIME
    - CURRENT_EXECUTABLE_NAME
    - CURRENT_EXECUTABLE_TYPE

- When running in suite context
    - CONTEXT_NAME
    - CONTEXT_PATH
    - CONTEXT_START_TIME
- After first executable in suite
    - TIME_IN_SUITE
- After first executable in suite context
    - TIME_IN_CONTEXT
- When running a test or before/after each/test
    - TEST_DESCRIPTION
    - TEST_NAME
    - TEST_START_TIME
- After first executable in test
    - TIME_IN_TEST
Removed `time_in_suite`, `time_in_context`, `time_in_test` as they ar…
…e of low value and could bing confusion.

@jgebal jgebal force-pushed the featrure/add_session_context branch from e172d40 to 99bae42 Jul 3, 2019

jgebal added 5 commits Jul 8, 2019
- Fixed minor typos, formatting and issues with expectation results.
- Changed how stack trace is reported on expectations to provide more information to the user.
- Fixed expectation messages for successful results
- moved `to_be_empty` / `not_to_be_empty` to base `ut_expectation` type as it's available for `clob`/`blob` types too.
- added-back grant on `ut_matcher` to allow for passing various matchers by users.
- fixed issue with misleading message: `All rows are different as the columns position is not matching` when comparing a null collection/cursor
{WIP] Updates to documentation for expectations.

@jgebal jgebal added this to the v3.1.8 milestone Jul 13, 2019

@jgebal jgebal changed the title [WIP] Ability to run expectations without test Ability to run expectations without test Jul 13, 2019

@jgebal jgebal requested review from lwasylow, pesse and PhilippSalvisberg Jul 13, 2019

@jgebal jgebal merged commit 2c70231 into develop Jul 13, 2019

4 checks passed

SonarCloud Code Analysis Quality Gate passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls First build on featrure/add_session_context at 95.035%
Details

@jgebal jgebal deleted the featrure/add_session_context branch Jul 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.