Skip to content

Implement fake function #43

@khru

Description

@khru

fake function

fake <command> [replacement code] 

Fakes command and replaces it with replacement code (if code is specified) for the rest of the execution of your test. If no replacement code is specified, then it replaces command by one that echoes stdin of fake. This may be useful if you need to simulate an environment for you code under test.

Example

https://github.com/pgrange/bash_unit
For instance examples:

fake ps echo hello world ps 

will output:

hello world 

We can do the same using stdin of fake:

fake ps << EOF hello world EOF ps 
hello world 

It has been asked whether using fake results in creating actual fakes or stubs or mocks? or may be spies? or may be they are dummies? The first answer to this question is: it depends. The second is: read this great and detailed literature on this subject.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions