Hi ,
I want to stop the execution of tests if an error occurs in the first test in ABL Unit Testing. Is this possible ?
As far as i know, the only possibility is to use haltOnError option when running ABLUnit tests from ANT.
you could catch errors in your test, and in the CATCH block, call QUIT.
I am trying to run a test, catch the error and calling QUIT. QUIT is actually stopping the other tests to run, but the log file is not getting generated, It just says .cls failed. Will this error (the error from the first test ) be logged in a separate file ?
Is there a way wherein i stop the execution of the remaining tests if one test/condition fails - after logging the error using assert statement ?
@test.
METHOD PUBLIC VOID ValidateUser():
IF NOT ValidateUserCredentials(OUTPUT cError) THEN DO:
Assert:RaiseError(cError).
QUIT. //quit/return
END.
/* CATCH err AS appError : */
/* DO piLoop = 1 TO err:NumMessages: */
/* Assert:RaiseError(err:GetMessage(piLoop)'). */
/* LEAVE. */
/* END. */
/* GarbageCollectorHelper:DeleteObject(oContextDatasetFactory).*/
/* // QUIT . */
/* END CATCH. */
ValidUserCredentails is a method which will check for valid credentials and returns an error. If there is an error, i want to stop the other methods from running. I tried using assert:equals but no change. When i run the build.xml , i get the message " build.xml:14: com.progress.openedge.ant.ablunit.ABLUnitTaskException: CompanyUnitTest.cls failed" and i dont see the log in the results folder
I tried the same code uncommenting the catch block, now it does not quit, and continues with rest of the test cases .
Here is the code :
METHOD PUBLIC VOID ValidateUser():
IF NOT ValidateUserCredentials(OUTPUT cError) THEN DO:
Assert:RaiseError(cError).
QUIT.
END.
CATCH err AS appError :
DO piLoop = 1 TO err:NumMessages:
Assert:RaiseError(err:GetMessage(piLoop)).
LEAVE.
END.
GarbageCollectorHelper:DeleteObject(oContextDatasetFactory).
QUIT .
END CATCH.
END METHOD.
and the output after build is :
<?xml version="1.0" ?>
<testsuites errors="0" failures="12" name="ABLUnit" tests="22"><testsuite name="Base/Company/Companies/CompanyUnitTest.cls" tests="22" time=".336"><testcase name="ValidateUser" status="Failure" time=".013"><failure message="Unknown User/Company Parameters">RaiseError OpenEdge.Core.Assert at line 918 (OpenEdge/Core/Assert.r)
ValidateUser Base.Company.Companies.CompanyUnitTest at line 453
RunTests OpenEdge.ABLUnit.Runner.ABLRunner at line 150 (OpenEdge/ABLUnit/Runner/ABLRunner.r)
ABLUnitCore.p at line 72 (ABLUnitCore.r)</failure></testcase><testcase name="CreateInvalid" status="Success" time=".006"/><testcase name="InValidCompany" status="Failure" time=".064"><failure message="Record already exists with this identity (5)">RaiseError OpenEdge.Core.Assert at line 918 (OpenEdge/Core/Assert.r)
InValidCompany Base.Company.Companies.CompanyUnitTest at line 549
Not sure where i am going wrong !!!
Removed LEAVE , but still doesn't QUIT . Records the error message and continues with rest of the tests.