Giter VIP home page Giter VIP logo

cclunit-framework's Introduction

cclunit-framework

The CCL Unit Framework is a collection of CCL programs for executing CCL Unit Tests and generating test results and code coverage data.

It must be installed into a Cerner Millennium environment before it can be used. Find step-by-step instructions here.

Current Version

3.4

Usage

See CCL Unit Tests for the structure of a CCL Unit test case, instructions for executing one, and a rudimentary example.

See CCL Unit Asserts for a list of all available asserts.

See CCL Unit Mocking for details about the mocking API and a basic example using it.

See CCL Unit Guidance for suggestions how to structure a program for testability and how to structure unit tests. Short examples are provided to illustrate the techniques.

Update Schedule

The update schedule is driven by requests for and contributions of enhancements and corrections.
See the change log for the contents of previous releases. Visit the issues list to log a new request.

Contribute

You are welcomed to contribute documentation improvements as well as code corrections and enhancements.
Please read our Contribution Guidelines.

Release

Committers:
Please read and follow the Release Guidelines when mergining a pull request.

License

Copyright 2017 Cerner Innovation, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this 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.

cclunit-framework's People

Contributors

feckertson avatar cernertrevor avatar

Stargazers

Ronald Ngatuni avatar Festus Abiola avatar Matt Duncan avatar Arpitha U avatar gaurav patel avatar  avatar Jenny Saqiurila avatar Cat Ireton avatar Ishak  avatar Daniel Murray avatar

Watchers

 avatar Micah Whitacre avatar James Cloos avatar Josh Murphy avatar  avatar Jeremy Field avatar Paresh Pandit avatar  avatar Niranjan Kumar avatar  avatar Bill Baar avatar

cclunit-framework's Issues

Enhancement: Capture errors from Mocking APIs

Currently, CCL resets the error stack whenever a child script is executed with the "execute" command. This could lead to errors being suppressed in a unit test if the error occurs before "execute" is invoked. An example of this would be if an error occurred while trying to create a mock table with cclutDefineMockTable and then the script-under-test is called using cclutExecuteProgramWithMocks.

Because the Mocking APIs provide an abstraction for "execute" now (cclutExecuteProgramWithMocks), the framework would be capable of checking for any errors in the error stack and documenting them, so that the test can fail even if all assertions pass (similar to what the cclutAssert* subroutines do). In fact, all of the Mocking APIs could support it to provide more information to the consumer about any errors in their unit test.

This issue is to implement this enhancement.

Bug: Indexes are not added if username length is greater than 7

Currently, when using cclutAddMockIndex, the index will fail to be added to the table if the username of the user executing the test is greater than 7 characters in length when cclutCreateMockTable is called. The failure does generate an error, but if no cclutAssert* calls are made after cclutCreateMockTable but before execute/cclutExecuteProgramWithMocks, then the error will be suppressed (see here: #20)

The issue is similar to (#12) where there is a hard limit of 30 characters on Oracle identifiers, and CCL prepends XIE_ on to the name of any index (which also uses the tablename). Based on how the framework constructs the tablename, that leaves 7 characters for the username before hitting the limit.

Solutions would be similar for the constraint issue:

  1. CCL could be enhanced to allow for specifying the index name when using "SELECT INTO table".
    or
  2. The CCL Unit mocking framework could append indexes after the table has been finalized through the use of rdb commands (and thus specifying the specific index name to be used).

Enhancement: Support Constraints On Mock Tables

Currently, CCL's "SELECT INTO table" command offers an option to include constraints. However, there is no way to specify the name of the constraint. It will always be created as "CON__". Oracle requires that constraint names be no longer than 30 characters, which can be painful for custom tables with even semi-long table names or column names (dividing it evenly would leave only 13 characters for a table name and 12 for a column name). See an example here: https://connect.ucern.com/thread/255048 (Note that a uCern account is required.)

The CCL Unit mocking framework creates fairly long table names to ensure uniqueness when working in real domains, making this functionality near unusable. To resolve this, one of two things would need to happen.

  1. CCL could be enhanced to allow for specifying the constraint name when using "SELECT INTO table".
    or
  2. The CCL Unit mocking framework could append constraints after the table has been finalized through the use of rdb commands (and thus specifying the specific constraint name to be used).

Originally, (before understanding the limitation of constraint names), an implementation was developed using the constraint functionality of "SELECT INTO table". Its implementation is provided here as an example for any future work done on this enhancement:
https://gist.github.com/cernertrevor/acda50b4f6f60a4c0e35335158133602

DvDev does not display the report generated by CCLUT if _memory_reply_string is populated.

Apparently the contents of _memory_reply_string trump generated report data in the vccl_run_program reply which is what DvDev displays.

A potential fix is to wipe out _memory_reply_string before generating the report, but there are pieces of the framework code that use _memory_reply_string to communicate error information back to DvDev. That communication mechanism would need adjusted to support this simple fix.

As a workaround one can add code to set _memory_reply_sting = " " in a teardownOnce routine.

Comments on Declare statements break site creation

When I try to create the target site, I am failing to create it because of some comments on the same line as a declare statement. When I remove the comments the problem is fixed.

Command run

mvn clean test site -Psoldev64aix

Line in question:

declare generatePortalInvites(dPatientPersonId = f8, dPmHistTrackingId = f8) = null ;569134 added dPmHistTrackingId

Error Message:

[INFO] --- maven-site-plugin:3.3:site (default-site) @ ccl-parent-pom ---
[INFO] configuring report plugin com.cerner.ccl.testing:cerreal-maven-plugin:2.1
[INFO] configuring report plugin com.cerner.ccl.whitenoise:whitenoise-maven-plugin:2.5
[INFO] configuring report plugin com.cerner.ccl.cdoc:cdoc-maven-plugin:1.2
[info] entering CDocReportMojo constructor
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:2.2
[INFO] configuring report plugin org.apache.maven.plugins:maven-site-plugin:3.3
[WARNING] No project URL defined - decoration links will not be relativized!
[INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 skin.
[INFO] Generating "CCL Coverage Report" report --- cerreal-maven-plugin:2.1
[INFO] Generating "Cerreal Report" report --- cerreal-maven-plugin:2.1
[INFO] Generating "Whitenoise" report --- whitenoise-maven-plugin:2.5
[INFO] validating compile ccl_xml_translator_1557776900683.out
[INFO] Generating "CDoc" report --- cdoc-maven-plugin:1.2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:03 min
[INFO] Finished at: 2019-05-13T14:48:24-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project ccl-parent-pom: Error during page generation: Error rendering Maven report: Failed to parse
include file pfmt_pm_person_portal_invite.inc: Unrecognized declaration: null ;569134 added dPmHistTrackingId; normalized to NULL ;569134 ADDED DPMHISTTRACKINGID -> [Help 1]

CCL Unit Framework Version

3.3

Target folder

target.zip

Should testing fail if there are not unit tests? Vote your opinion.

Builds were surviving for the wrong reason when cclut_find_unit_tests was failing to find any tests. That could not happen if testing were to fail for no tests. If there are no tests, why run the test command.

What if there are tests but no tests that match the specified test filters?

archive the project

Due to the inactivity of this project for over 1 year, this project is marked to be archived at end of January 2024. Previously release assets will be untouched, but support will cease for this project going forward. If anyone has any reasons this project should not be archived, please comment.

Bug: Dropping mock tables still doesn't work for group1 users

So originally, this was proposed to be fixed with:
#19

But I don't think it resolves it in a meaningful way for a group1 tester. The code does work (it drops the definition when a group1 user is executing it and it goes down the tdbexecute route), but the problem is that the definition (while removed from dic.dat) is still in memory for the life of the CCL session. This means that any further attempts to overwrite the table (such as with a second test) will fail. Example below.

Script-under-test:

drop program group1test:dba go
create program group1test:dba

select into "nl:"
from person p
where p.person_id = 1
with nocounter

end
go

Test file

subroutine (tearDown(null) = null)
	call cclutRemoveAllMocks(null)
end ;tearDown

subroutine test_first(null)
	call cclutDefineMockTable("person", "person_id", "f8")
	call cclutCreateMockTable("person")
	call cclutAddMockData("person", "1.0")

	call cclutExecuteProgramWithMocks("group1test")
	call cclutAssertf8Equal(CURREF, "test_first 001", TRUE, TRUE)  
end

subroutine test_second(null)
	call cclutDefineMockTable("person", "person_id", "f8")
	call cclutCreateMockTable("person")
	call cclutAddMockData("person", "1.0")

	call cclutExecuteProgramWithMocks("group1test")
	call cclutAssertf8Equal(CURREF, "test_second 001", TRUE, TRUE)  
end

test_second will fail since it can't create the mocked person table (due to using the same names for mocks on new tests).

Given that CCL will still maintain that definition for the life of the session when it's dropped from a server, I don't know that there's any way to "resync" from CCL those definitions.

One possible alternative is to maintain a running counter for the unique index used when defining tables. Currently, it starts at 1 and counts up, based on how many existing tables there are. In the example above, since the tables are reset after each test, the mock person table is being created with the same name (CUST_CCLUT_1timestampUserid). If the counter was a running counter for the entire suite (such that test_second would create CUST_CCLUT_2timestampUserid), that would sidestep the issue. The tdbexecute logic would still stay in place because the tables still need to be dropped; this just allows group1 users to write more than one test leveraging mock tables.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.