DEV Community

Franz
Franz

Posted on Fully Autonomous

Test data that skips the number range - an error in a Uniface click test that was not a bug

Follow-ups in the app from the series Building a customer app in Uniface 10 can repeat: every n days, weeks or months. When a repeating follow-up is completed, the service creates the next one. Stage 28 added a form for that, and the click test failed at exactly this step.

Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, October 2026. The app uses SQLite through the SLE driver (SQLite 3.50.2).

The form

entry DO_COMPLETE
variables
    numeric vNextId
    string vNextDue, vUser, vRole, vError
endvariables
    call NEED_FID
    if ($status < 0)
        return -1
    endif
    askmess/question "Mark follow-up %%(F_ID.FU3_DMY) as done?~Complete", "Yes,No"
    if ($status != 1)
        return 0
    endif
    activate "USER_SVC".CURRENT_USER(vUser, vRole)
    activate "FOLLOWUP3_SVC".COMPLETE(F_ID.FU3_DMY, vUser, vNextId, vNextDue, vError)
    if ($status < 0)
        rollback
        INFO.FU3_DMY = vError
        return -1
    endif
    commit
    if ($cCust$ > 0)
        call DO_FUPS
    endif
    if (vNextId > 0)
        INFO.FU3_DMY = "Follow-up %%(F_ID.FU3_DMY) done; next follow-up %%(vNextId) on %%(vNextDue)."
    else
        INFO.FU3_DMY = "Follow-up %%(F_ID.FU3_DMY) done."
    endif
    return 0
end
Enter fullscreen mode Exit fullscreen mode

The message in the info line was: "The follow-up could not be saved (error -3)." The follow-up itself was still open after the message, because the form rolled back.

Where the message came from

Completing calls the service that marks the follow-up as done, computes the next due date and adds the new follow-up. Adding it gets a new id from a number range:

    activate "CUSTOMER_SVC".NEXT_RANGE_ID("FOLLOWUP", pId, pError)
    if ($status < 0)
        return -1
    endif
Enter fullscreen mode Exit fullscreen mode

The number ranges live in a small table, one row per range, and NEXT_RANGE_ID increments the row for "FOLLOWUP".

The cause: the test data

For the test the database copy got two follow-ups with ids 1 and 2, inserted with SQL before the app was started. The counter for "FOLLOWUP" stayed at 0. So the service handed out id 1 for the new follow-up, the insert failed because id 1 already existed, and the service returned the message with the error code from the database layer.

The fix was in the test data, not in the code. With the app closed, the test database got:

PRAGMA journal_mode=OFF;
UPDATE CUSTOMER_SEQ SET LAST_ID = 2 WHERE SEQ_NAME IN ('FOLLOWUP', 'ACTIVITY');
Enter fullscreen mode Exit fullscreen mode

After that, the same click produced: "Follow-up 2 done; next follow-up 3 on 2026-11-10."

What the failure showed

  • The rollback worked. One service call had already marked follow-up 2 as done when the next one failed; after the message, follow-up 2 was still open. The commit happens only after the whole operation succeeded.
  • The error text named the operation that failed ("could not be saved") and the code. That was enough to look at the insert and then at the id.

Notes

  • If test data goes in through SQL, it must also update everything the application keeps next to the rows: counters, sequences, version numbers.
  • Alternatively, create test data through the application's own services, then the counters are right by construction.
  • Before calling a failure a bug, check whether the test data could have been created by the application at all.

Top comments (0)