openmainframeproject / cobol-check

A testing framework for Cobol applications
Apache License 2.0
78 stars 28 forks source link

Problem? #274

Closed sam94dion closed 1 year ago

sam94dion commented 1 year ago

Hi guys,

I was playing around with cobolcheck and I found this "bug" before fixing it I just wanted to know if this is intended.

Problem :

Description - Perform of paragraph isn't called in the generated cobol when TestCase only has perform and no expect. **

example -

PRG.cut

           TestSuite "General tests"

           TestCase "No Expect or Verify"
           PERFORM 000-START

           TestCase "Welcome section performs as intended"
           PERFORM 100-WELCOME
           Expect VALUE-1 to be "Hello"
           Expect VALUE-2 to be "Hi"

CC##99.cbl

       PROCEDURE DIVISION.                                                      
           PERFORM UT-INITIALIZE                                                
      *============= "General tests" =============*                             
           DISPLAY "TESTSUITE:"                                                 
           DISPLAY "General tests"                                              
           MOVE "General tests"                                                 
               TO UT-TEST-SUITE-NAME                                            
      *-------- "No Expect or Verify"                                           
           MOVE SPACES                                                          
               TO UT-TEST-CASE-NAME                                             
           PERFORM UT-BEFORE-EACH                                               
           MOVE "No Expect or Verify"                                           
               TO UT-TEST-CASE-NAME                                             
           PERFORM UT-INITIALIZE-MOCK-COUNT                                     
           MOVE SPACES                                                          
               TO UT-TEST-CASE-NAME                                             
           PERFORM UT-AFTER-EACH                                                
      *-------- "Welcome section performs as intended"                          
           MOVE SPACES                                                          
               TO UT-TEST-CASE-NAME                                             
           PERFORM UT-BEFORE-EACH                                               
           MOVE "Welcome section performs as intended"                          
               TO UT-TEST-CASE-NAME                                             
           PERFORM UT-INITIALIZE-MOCK-COUNT                                     
            PERFORM 100-WELCOME                                                 
           ADD 1 TO UT-TEST-CASE-COUNT                                          
           SET UT-NORMAL-COMPARE TO TRUE                                        
           SET UT-ALPHANUMERIC-COMPARE TO TRUE                                  
           MOVE VALUE-1 TO UT-ACTUAL                                            
           MOVE "Hello"                                                         
               TO UT-EXPECTED                                                   
           SET UT-RELATION-EQ TO TRUE                                           
           PERFORM UT-CHECK-EXPECTATION                                         
           ADD 1 TO UT-TEST-CASE-COUNT                                          
           SET UT-NORMAL-COMPARE TO TRUE                                        
           SET UT-ALPHANUMERIC-COMPARE TO TRUE                                  
           MOVE VALUE-2 TO UT-ACTUAL                                            
           MOVE "Hi"                                                            
               TO UT-EXPECTED                                                   
           SET UT-RELATION-EQ TO TRUE                                           
           PERFORM UT-CHECK-EXPECTATION                                         
           MOVE SPACES                                                          
               TO UT-TEST-CASE-NAME                                             
           PERFORM UT-AFTER-EACH
Rune-Christensen commented 1 year ago

Hi @sam94dion ,

This is working as intended. I see two solutions to the issue:

  1. Move the first perform into the second testcase, that should fix it.
  2. Implement the before-all and after-all functions. This is poorly described here https://github.com/openmainframeproject/cobol-check/issues/18 but would provide the functionality you are requesting.

Btw. would you like to be able to create branches in the project, instead of having to develop on your own fork?

Regards, Rune

sam94dion commented 1 year ago

Yes please @Rune-Christensen that would be easier for me. I'll close this then. Thank you.