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

[Improvement]: Support mocking with withArguments() where some arguments are fixed and some are flexible. #42329

Open
Thevakumar-Luheerathan opened this issue Mar 15, 2024 · 0 comments
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Compilation

Comments

@Thevakumar-Luheerathan
Copy link
Member

Thevakumar-Luheerathan commented Mar 15, 2024

Description

With the current Mocking implementation, we should give all arguments if we are trying to mock a function or object. But, It is better if we can mock while keeping a few arguments fixed and letting other arguments flexible.
main.bal

Client cl = new();
public client class Client {
    remote function alp(string a, string b, string c) returns string {
        return "alp";
    }
}

tests/test.bal

@test:Config() 
function alpTest() {
  test:prepare(clientEndpoint).when("alp").withArguments(ANY, "love", "Sri Lanka").thenReturn("hi");  // Here ANY can be matched with anything
  string mal = cl->alp("I", "love", "Sri Lanka"); // It should match with previous mock
}

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

2 participants