How to use OpenEdge.Core.Assertion.AssertError? - Forum - OpenEdge Development - Progress Community

How to use OpenEdge.Core.Assertion.AssertError?

 Forum

How to use OpenEdge.Core.Assertion.AssertError?

This question is answered

Hi guys,

I would like to use the HasErrorStatus() method of OpenEdge.Core.Assertion.AssertError library.

At this moment I haven't been able to figure out how to use it and the documentation doesn't really make things much clearer. https://documentation.progress.com/output/oehttpclient/oe117/index.html?OpenEdge.Core.Assertion.package.html

The way I have used it:

@Test.
METHOD PUBLIC VOID testtoString( ):
    // Test if an error is thrown if the lenght is smaller then the precision
    DecimalUtils:toString(10, 6, 5, FALSE, 2).
    AssertError:HasErrorStatus().

    RETURN.

    CATCH CommonError AS Progress.Lang.Error :

    END CATCH.

END METHOD.

What I would expect is that the assertion fails if there is no Error thrown, but that doesn't work. 

I hope someone can help me out here. 

Verified Answer
  • Hi,

    The API 'AssertError:HasErrorStatus().' can be used to check the presence of an error for lthe last stattement executed.

    Below is the sample procedure which tries to connect to a non-existing DB with NO-ERROR.

    When you try to run the test case it will result into success.

    @Test.

    PROCEDURE TestIt:

    /*------------------------------------------------------------------------------

    Purpose:

    Notes:

    ------------------------------------------------------------------------------*/

       CONNECT "not-existed" NO-ERROR.

       AssertError:HasErrorStatus().

    END PROCEDURE.

All Replies
  • Hi,

    The API 'AssertError:HasErrorStatus().' can be used to check the presence of an error for lthe last stattement executed.

    Below is the sample procedure which tries to connect to a non-existing DB with NO-ERROR.

    When you try to run the test case it will result into success.

    @Test.

    PROCEDURE TestIt:

    /*------------------------------------------------------------------------------

    Purpose:

    Notes:

    ------------------------------------------------------------------------------*/

       CONNECT "not-existed" NO-ERROR.

       AssertError:HasErrorStatus().

    END PROCEDURE.

  • I forgot all about the NO-ERROR statement.

    It works now.

    Thanks