Question
· May 31, 2017

Unit Testing Passed/Failed Status from the Terminal

Is there any methods/ways through which will get to know whether any of the Unit Test cases is/are failing in the Terminal with status as either 0 or False in case of Failure & 1 or Ture in case of Test Passes (we are getting an url of the csp page with the report which has the passed failed status) as we need to send this failure status to Jenkins for the Build to Fail (where in we have acheived this part in making the build failure/success based on  harcoded boolean)

Discussion (2)1
Log in or sign up to continue

I have not used UnitTests before but looks like, you can just analyze ^UnitTest.Result global, by latest index.

USER>set sc=##class(%UnitTest.Manager).DebugRunTestCase("", "MyPackage.Tests","","TestAdd")

===============================================================================
Directory: /opt/cache/dev/tutorials/UnitTestEx/
===============================================================================
  (root) begins ...
    MyPackage.Tests begins ...
      TestAdd() begins ...
        AssertEquals:Test Add(2,2)=4 (passed)
AssertNotEquals:Test Add(2,2)'=5 (failed)  <<==== **FAILED**
(root):MyPackage.Tests:TestAdd:
        LogMessage:Duration of execution: .000045 sec.
      TestAdd failed
    MyPackage.Tests failed
  Skipping deleting classes
  (root) failed

Use the following URL to view the result:
http://192.168.56.140:57774/csp/sys/%25UnitTest.Portal.Indices.cls?Index=5&$NAMESPACE=USER
Some tests FAILED in suites:

USER>zw ^UnitTest.Result(^UnitTest.Result)
^UnitTest.Result(5)=$lb("2017-05-31 12:08:01",.0013,"MacBook-Pro.local","CACHE","Cache for UNIX (Apple Mac OS X for x86-64) 2016.2 (Build 736U) Fri Sep 30 2016 11:56:58 EDT","USER","","")
^UnitTest.Result(5,"(root)")=$lb(0,.001218,"","There are failed TestCases")
^UnitTest.Result(5,"(root)","MyPackage.Tests")=$lb(0,.000554,"","There are failed TestMethods")
^UnitTest.Result(5,"(root)","MyPackage.Tests","TestAdd")=$lb(0,.000045,"","There are failed TestAsserts")
^UnitTest.Result(5,"(root)","MyPackage.Tests","TestAdd",1)=$lb(1,"AssertEquals","Test Add(2,2)=4")
^UnitTest.Result(5,"(root)","MyPackage.Tests","TestAdd",2)=$lb(0,"AssertNotEquals","Test Add(2,2)'=5")
^UnitTest.Result(5,"(root)","MyPackage.Tests","TestAdd",3)=$lb(1,"LogMessage","Duration of execution: .000045 sec.")

I think from this global, will be quite easy to extract needed information to any format.