Unit Testing bash scripts

后端 未结 16 684
暖寄归人
暖寄归人 2020-11-30 18:51

We have a system that has some bash scripts running besides Java code. Since we are trying to Test Everything That Could Possibly Break, and those bash scripts may break, we

相关标签:
16条回答
  • 2020-11-30 19:06

    Maybe this can be used, or contributed to

    https://thorsteinssonh.github.io/bash_test_tools/

    Intended to write results in TAP protocol which I imagine is good for CI, and good for those that want shell environments. I imagine some things run in shell environments so, some might argue should be tested in their shell environment.

    0 讨论(0)
  • 2020-11-30 19:08

    I created shellspec because I wanted a easy-to-use and useful tool.

    It written by pure POSIX shell script. It has tested with many shells more than shunit2. It has powerful features than bats/bats-core.

    For example, support nested block, easy to mock/stub, easy to skip/pending, parameterized tests, assertion line number, execute by line number, parallel execution, random execution, TAP/JUnit formatter, coverage and CI integration, profiler and etc.

    See the demo on the project page.

    • https://github.com/shellspec/shellspec
    • https://shellspec.info/
    0 讨论(0)
  • 2020-11-30 19:09

    I’ve tried a lot of the solutions presented here, but found most of them to bulky and hard to use, so I built my own little testing framework: https://github.com/meonlol/t-bash

    It’s just one file in the repo that you can simply run directly, with a basic set of JUnit style asserts.

    I’ve used it professionally in several internal projects and were able to make our bash scripts super stable and regression resistant.

    0 讨论(0)
  • 2020-11-30 19:10

    You might want to take a look at bash_unit:

    https://github.com/pgrange/bash_unit

    0 讨论(0)
  • 2020-11-30 19:14

    I quite like shell2junit, a utility to generate JUnit-like output from Bash script tests. This is useful because the report generated can then be read by continuous integration systems, such as the JUnit plug-ins for Jenkins and Bamboo.

    While shell2junit doesn't provide the comprehensive Bash scripting framework like shunit2, it does allow you have nice reporting of the test results.

    0 讨论(0)
  • 2020-11-30 19:15

    Take a look at Outthentic, it is simple, extensible by many languages ( Perl, Python, Ruby, Bash on choice ) and cross platform ( Linux, Windows ) framework to test any command line applications.

    0 讨论(0)
提交回复
热议问题