Highlighted
Regular Contributor.
Regular Contributor.
943 views

How to automatic create Unit Test case for all of procedures in Cobol program

I using Visual Cobol IDE to generate Cobol Unit Test case for each cobol program in my project, base on guide : https://www.microfocus.com/documentation/visual-cobol/VC40/EclUNIX/GUID-D5F12D24-BB4D-4CC4-920B-0A4DE99E1F29.html

But, I see that it only generate one case for each program

Ex : with 'XXX.cbl' file which has 2 procedures are PROCEDURE1, PROCEDURE2,..., it only generate in XXXTest.cbl (test case file) such as :

call "XXX" using by reference LINK-AREA-IO-01,

Instead of, 

call "PROCEDURE1" using by reference LINK-AREA-IO-01,

.....

call "PROCEDURE2" using by reference LINK-AREA-IO-02,

 

Visual Cobol IDE can support to generate same that or I have to self write by hand ?

 

0 Likes
11 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Unit tests for multiple entry points within a program can be generated by the Unit Test Wizard. There is an Add New button on the botton that allows you to select additional entry points from a drop-down list.

ut.JPG

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Dear Mr.Chris Glazier,

Thank you for answering me but in MF Visual Cobol IDE (trial 30 days) in my PC, there is not dialog which same as you showed. In my PC, only show dialog as below

Untitled.png

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Which version of Visual COBOL are you using? It appears like it might be 3.0 which is not the latest release.

The support for multiple entry point selection for a COBOL Unit Test was added to the 4.0 product release.

If I right-click in a program containing multiple entry points and select Create Unit Test I will get the Dialog that I showed previously.

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Dear Mr.Chris Glazier,

I using Micro Focus Visual COBOL 4.0 for Eclipse (Windows)

Version: 4.0.243.v201805162240

But can not show dialog create Unit Test as you said.Untitled1.png

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

I am sorry that I didnt realize you were using the Eclipse IDE. I was testing with Visual Studio and that already has the support for multiple entry points for Unit Tests.

The Eclipse IDE will have that capability in the next major product release which will be V5.0 due to be available sometime in June. You will then be able to accompish what you wish.

Thanks

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

@Chris Glazier , I'm using VC 4.0 Eclipse for Windows and, if the program that I want to test has multiple entry points, I can create a unit test specific to each (see attached).  Can you please describe what VC 5.0 might add for Eclipse?

Highlighted
Micro Focus Expert
Micro Focus Expert

I am sorry, you are correct. This feature is part of V4.0. I accidently selected a test that only had one entry point when I tried it.

The original problem reported is because the option "create unit test from template" appears to be selected which will only create a generic unit test code and then has to manually be entered in.

You must select the option "create unit test for program" must be selected and then after selecting the desired program all of the entry points will appear in the list.

 

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Dear Mr. StompinBob,

"AIRCODE" and "TEST" in your image are procedures in a Cobol file ?
In my IDE, it show only one entry point (is D5211311) which is PROGRAM-ID (Cobol file name too), aren't procedures

Untitled1111.png

Instead of that, I want it show to select 2 procedure (DATA-CHECK, MG-SET) of above PROGRAM-ID

Untitled33333.png

How to make it show same as you ? 😞

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

The "Procedure Division Using" statement is the default entry point for a COBOL program.  However,  you can add additional entry points to your program with the "Entry" statement.  For my example, I just added a second entry point called "Test" to the one of the sample programs that ship with the product.  Sadly, unless you're using OO COBOL, I think you're stuck with creating unit tests that map to entry points, with the "Procedure Division Using" being the likely entry point you will use. 

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Dear StompinBob,

Yes, That's right. I'm stuck with creating unit tests that map to entry points, with the "Procedure Division" being the likely entry point which I will use.
Base on your answer, I understand that VS Cobol IDE has not support automatic create test case for each entry point which are prodecure in "Procedure Division", incase cobol version is not OO Cobol (such as Visual Cobol II, IBM Cobol, Net Cobol, ...), Is that right ?

If right, why is that ? Is there no way ?

I really want to unit test each procedure in "Procedure Division"   to compare the input/output values of them with the input/output values of each corresponding method in JAVA source after converted ! 😞

 

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

@hungncv , I think you may be confusing COBOL paragraphs or sections with entry points.   In your screen shot above, I would think that DATA-CHK and MG-SET are paragraphs in COBOL program in D5211311.  They are not procedures or entry points.  The entry point to D5211311 is likely the "Procedure Division Using" statement.  You *might* try adding more entry statements to D5211311 in order to unit test specific chunks of the COBOL code, but typically, these paragraphs aren't standalone code like would be an object.method you might unit test in Java or .Net., so wrapping them with entry points is not likely to give you the desired result.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.