Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The test initialization fails when mocking generated http clients #41891

Closed
menakaj opened this issue Dec 15, 2023 · 2 comments
Closed
Assignees
Labels
Area/TestFramework Reason/Other None of the other reasons. Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Bug

Comments

@menakaj
Copy link

menakaj commented Dec 15, 2023

Description

Scenario:

  • There is a set of clients which are generated by the bal open api tool. (there are resource functions for each http resource defined in the openapi definition)
  • Each client is initialized by a initializer function.
  • The initializer function is mocked in the test to created the mock client
  • There is a mock client implemented and it is being returned as the client when mocking.

With this setup, when running bal test, it's terminated with the following log. There are no any clue on what went wrong during the initialization phase.

Screenshot 2023-12-15 at 11 37 13

Steps to Reproduce

  • Generate few clients from open api definitions
  • initialize the clients as final in the source code and use initialization functions
  • Implement some dummy code to call the clients
  • In the test, mock each initialization function
  • implement the test method
  • Run bal test

Affected Version(s)

2202.7.1

OS, DB, other environment details and versions

N/A

Related area

-> Other Area

Related issue(s) (optional)

No response

Suggested label(s) (optional)

testFramework

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added the needTriage The issue has to be inspected and labeled manually label Dec 15, 2023
@MaryamZi MaryamZi added Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Area/TestFramework and removed needTriage The issue has to be inspected and labeled manually labels Dec 15, 2023
@Dilhasha Dilhasha self-assigned this Dec 15, 2023
@Dilhasha
Copy link
Contributor

This issue is fixed in 220.7.3 onwards. You can move to 2201.7.4 i.e. the latest 7.x patch ATM.

If you try with 2201.7.3, it will display the actual error which is an unnecessary function in the test double.

error: invalid function '$get$configs$groups' provided
	at ballerina.test.0:mock(mock.bal:309)

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@Dilhasha Dilhasha added the Reason/Other None of the other reasons. label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/TestFramework Reason/Other None of the other reasons. Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Bug
Projects
None yet
Development

No branches or pull requests

4 participants