Code Monkey home page Code Monkey logo

shellmock's Introduction

shellmock

This is the shellmock project, a mocking framework for shell scripts. It works well with the bats-core testing framework. You can find our documentation below. Inspiration for shellmock was taken from testing frameworks such as pytest and golang/mock.

Installation

To get started, just head over to the releases and download the latest release. Then, you can write your bats-core-based tests. Just make sure to use load shellmock in your setup function. See below for shellmock's documentation.

Dependencies

The following tools are needed to use shellmock:

  • base32
  • bash (at least version 4.4)
  • cat
  • chmod
  • mkdir
  • mktemp
  • rm

On Debian-based systems, they can be installed via:

sudo apt install -yqq bash coreutils

You also need the bats-core testing framework that can be installed via npm following its docs. We recommend an installation via npm instead of an installation via apt. The reason is that many system packages provide comparatively old versions while the version installable via npm is up to date.

To run the commands command, you also need a Golang toolchain. For optimal performance, install flock, which is contained within the util-linux package on Debian-based systems.

Documentation Overview

  • Usage documentation:
    • Quickstart guide: Read this page if this is your first time using shellmock and you want to get started.
    • How to: Read this page if you want to know how to go about creating your tests with shellmock in general.
    • Detailed example: Read this page if you want to see how shellmock can be used to create extensive tests of a script of medium complexity.
    • Command reference: Read this page if you want to know about all of shellmock's features or have questions about a specific command.
    • shellmock's own tests: Read this code if you want see how shellmock itself is being tested using bats-core. Those tests also showcase shellmock's features. This is a non-exhaustive list of examples you can find in the tests:
      • Mock an executable
      • Mock a function
      • Mock with non-zero exit code
      • Match positional arguments, both with fixed and flexible positions
      • Create a mock that is writing a fixed string to stdout
      • Fail a test by killing the parent process when there is an unexpected call
  • Technical documentation:
    • Building shellmock: Read this page if you want to know how to generate the release artefacts.

Feedback

Like what we did? Great, we’d love to hear that. Don’t like it? Not so great! But we are eager to hear your feedback on how we could improve!

About

Maintainers

'Torsten Long'

License

Shellmock is open-sourced under the Apache-2.0 license. See the LICENSE file for details.

Copyright (c) 2022 - for information on the respective copyright owner see the NOTICE file or the repository https://github.com/boschresearch/shellmock

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

shellmock's People

Contributors

razziel89 avatar

Stargazers

 avatar Hana Boukricha avatar Colin Marquardt avatar

Watchers

 avatar  avatar Harald Mackamul avatar

Forkers

razziel89

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.