Hi! Squaretest is currently unable to accommodate these cases. For scenario 1: Squaretest does not provide information about the private methods within the source class (Foo) that a given method interacts with; it does not consider these to be dependency interactions. For scenario 2: Squaretest does not provide information about which static methods a source method interacts with; it does not consider these to be dependency interactions. For scenario 3: Squaretest can't mock local variables that are constructed in a given source method; the exception is: you can modify the templates to configure dependencies that a source method interacts with to return mock objects; e.g. if getAccountBalance() calls: this.accountManager.getAccount(accountNumber), you could modify the template to make accountManager return a mock Account object.
Thanks a lot for quick reply. Can you help me what modifications needs to be done for template to accommodate scenario 3. Also Currently All instance variables of type Object are not mocked. How to mock all Instance variables? I really appreciate if you can help !!
Sorry for the delay. The recent update should help with this use case. Squaretest 1.4 was released on 11/11/2019. This likely does what you want with regard to mocking (or providing values for) the dependency interaction return types. Squaretest 1.4 stores the return values for the dependency interactions in local variables in many cases. If the return types are DTO beans, Squaretest also invokes all of the setters on the local variables. If you want to use mocks for non-DTO beans that do not have a constructor, please replace the initializeDependencyInteractionMethodReturnType(...) macro with the macro on https://gist.github.com/nate-dev/604a3d6889368cb85f12d19e000b777f. You can adjust the following if statement values to determine when to mock the dependency interaction return types. --- #if($di.methodCallExpression.type.mockable && $di.method.returnType.canonicalName && $di.method.returnType.initExpression == 'null' && !$di.methodCallExpression.type.dtoBean && !$macro.shouldUseSpy && !$StringUtils.equalsAny($di.methodCal lExpression.type.canonicalName, 'java.util.List', 'java.util.Map')) #set($di.method.returnType.shouldBeMocked = true) #end ---