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

Enable CLI tests without executing actual API functionality #333

Open
ckunki opened this issue May 25, 2023 · 1 comment
Open

Enable CLI tests without executing actual API functionality #333

ckunki opened this issue May 25, 2023 · 1 comment
Labels
refactoring Code improvement without behavior change

Comments

@ckunki
Copy link
Contributor

ckunki commented May 25, 2023

Currently each CLI test for ITDE calls ITDE's API and the test logic investigates the results and side effects of the API calls in order to detect whether the CLI parameters have been handed and processed correctly. This has the following disadvantages

  • CLI tests require complex implementation
  • CLI test execution requires huge amount of resources and takes long
  • CLI tests are not very robust

The current ticket requests to enable CLI tests without needing to execute actual functionality in the API.
This could simplify CLI test cases and reduce test execution duration.

Idea

  • define a global environment variable <VAR>
  • when <VAR> is set then API does not execute actual functionality
  • however the mocked API allows to inspect parameters passed from CLI
@ckunki ckunki added the refactoring Code improvement without behavior change label May 25, 2023
@ckunki ckunki changed the title Enable cli tests without functionality Enable CLI tests without executing actual API functionality May 25, 2023
@tkilias
Copy link
Contributor

tkilias commented May 25, 2023

Extended Idea

  • The environment variable points to a name of a python file/python function which contains the mock implementation of the API
  • This way, each test case can inject its own mock implementation
  • When we move the CLI tests from actually calling a binary to using click.testing.CliRunner, we can inject a function name via the environment variable
  • If we call a binary, we need to inject the name of a python file, because the function might not be available in the execution context.
  • For the starter-container based tests, we could use a default mock implementation which prints the parameters, because neither of the previous methods really work with it, except we include the mock implementation into the container itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code improvement without behavior change
Projects
None yet
Development

No branches or pull requests

2 participants