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,
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 ?
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.
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
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.
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.
@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?
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.
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
Instead of that, I want it show to select 2 procedure (DATA-CHECK, MG-SET) of above PROGRAM-ID
How to make it show same as you ? 😞
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.
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 ! 😞
@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.