Unofficial Content

This feature allows you to pre-set some replacements for invocations to internal objects in order to not depend on them, just testing the code you need to test and nothing more.

The mechanism is through the usage of an external object inside the GXtest module. This external object called MockManager will provide 2 basic functions: Skip, and SetMock.

SetMock(in:&objectName, in:&mockObject)

Receives two varchar values, the name of the object to be mocked and the name of the object to execute instead. This will cause that when running the test, instead of calling the objectName, the mock object will be executed.

The mock object must have the same number and type of parameters as the object being replaced (they must be interchangeable). It is required that in the usage of this function, the parameterization of MockObject is done using the syntax ObjectName.Type, otherwise ObjectName will not be generated and execution will fail.

&MockManager.SetMock(ObjectX.Type, ObjectXMock.Type)


If you want a call to an object to be avoided, then you don't necessarily need to create an object to replace it. Using this function you can skip the execution and output parameters (if any) will be set with default values for each type.


  • The usage of MockManager external object is local to the test where it is declared, it does not affect the invocation of other objects calling the mocked objects from other contexts

  • Mockeable objects must be enabled through an environment-level property and require rebuilding the objects. The property name is Generate Mockable Objects.

  • It is planned to provide a global mock selector where this can be done at scale for a KB.

  • Any code can be mocked by placing it inside a Procedure object, this is very useful when you have a call to an external service that you don’t want to depend on


Let’s say you have a procedure called ProcA that calls to ProcB. You are interested in testing ProcA’s code only. The first step is to define a variable of type MockManager.

So in the test code, you can do the following:

 &Mock.Skip(ProcB.Type) // or &Mock.SetMock(ProcB.Type, ProcBMock.Type)



This code will cause the object ProcB is not executed in the context of the execution of the current test.

Creating a mock

The easiest way to create a mock is by using the contextual menu option Create Mock, which creates a copy of the selected procedure except for the Source part. The source includes comments with the Parm rule of the procedure and sample code.

Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant