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

Mock and expect #165

Open
fancsali opened this issue Feb 26, 2023 · 3 comments
Open

Mock and expect #165

fancsali opened this issue Feb 26, 2023 · 3 comments

Comments

@fancsali
Copy link

fancsali commented Feb 26, 2023

I was just wondering, what is the preferred way of doing something like the example below (which doesn't seem to work):

# my_command.test.sh

# Test my_command in fact does call my_other_command
. src/my_command.sh # Assuming my_command is a function

CALLS_COUNT=0

my_other_command {
  # do something
  CALLS_COUNT=$(( CALLS_COUNT + 1 ))
}

tesMyCommand() {
  my_command

  assertEquals 1 $CALLS_COUNT
}

NOTE: This is assumed to be called like this: shunit2 my_command.test.sh

@williamdes
Copy link
Collaborator

Hi
what is exactly not working, can you provide the output?

@fancsali
Copy link
Author

Something seems to be running in a sub-shell, and when I test the value it's always 0;

@williamdes
Copy link
Collaborator

Something seems to be running in a sub-shell, and when I test the value it's always 0;

Okay, would you mind posting the output of your test script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants