Article
· Feb 9, 2023 3m read

Elevate your unit tests to the next level

Hey community! 

It's time to elevate your unit tests to the next level with iris-TripleSlash new solo feature!

We are bring to the game Setup and Tear down events!

Just add description on class, with special tags like:

  • beforeAll
  • beforeOne
  • afterAll
  • afterOne

The tripleSlash will turn it to:

  • OnBeforeAllTests
  • OnBeforeOneTest
  • OnAfterAllTests
  • OnAfterOneTest

And that's not all! The new double dot abbreviation feature allows you to effortlessly call methods and simplify your code, i.e.:

///<example>
/// Write ..TheAnswerForEverything()
/// 42
///</example>

TripleSlash will automatically generate a test for you, like this:

Method TestTheAnswerForEverything()
{
    Do $$$AssertEquals(##class(dc.sample.ObjectScript).TheAnswerForEverything(), 42)
}

Setup and tear down

/// can also be used to define methods for unit test setup a tear down.

Let's check out how to do this using our previous testing class:

/// A simple class for testing purpose.
/// 
/// <beforeAll>
/// Write "Executes once before any of the test methods in a test class execute. Can set up a test environment."
/// Return $$$OK
/// </beforeAll>
/// 
/// <afterAll>
/// Write "Executes once after all of the test methods in a test class execute. Can tear down a test environment."
/// Return $$$OK
/// </afterAll>
/// 
/// <beforeOne>
/// Write "Executes immediately before each test method in a test class executes."
/// Return $$$OK
/// </beforeOne>
/// 
/// <afterOne>
/// Write "Executes immediately after each test method in a text class executes."
/// Return $$$OK
/// </afterOne>
Class dc.sample.ObjectScript
{
    ...
}

After running ///, our unit test class had add the methods OnAfterAllTests()OnAfterOneTest()OnBeforeAllTests() and OnBeforeOneTest():

Class iris.tripleSlash.tst.ObjectScript Extends %UnitTest.TestCase [ Not ProcedureBlock ]
{
Method OnAfterAllTests() As %Status
{

    Write "Executes once after all of the test methods in a test class execute. Can tear down a test environment."
    Return $$$OK
}


Method OnAfterOneTest() As %Status
{

    Write "Executes immediately after each test method in a text class executes."
    Return $$$OK
}


Method OnBeforeAllTests() As %Status
{

    Write "Executes once before any of the test methods in a test class execute. Can set up a test environment."
    Return $$$OK
}


Method OnBeforeOneTest() As %Status
{

    Write "Executes immediately before each test method in a test class executes."
    Return $$$OK
}


...


}

Acknowledgment

We extend our sincerest gratitude to the community for their continuous support throughout the development of our applications. Your feedback and insights have been invaluable in helping us improve.

If you found our app useful and informative, we would greatly appreciate your vote for iris-tripleslash. Your support is crucial as we continue on this journey to create innovative solutions.

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

What does a nervous twitching guitarist has to do with this developer community? I thought, this is a community of professionals and not of script kiddies. It's sorry to say, but under such circumstances I do not want to participate here. Just to make it clear, I have nothing against a video which demonstrates a Cache or IRIS feature, or which is a recording of a webinar or something similar but it should have something in common with development, with the database or at least with the lanuages or tools we use.