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 want to test them. The problem is it is hard to test the scripts.
I would like to hear if anyone has experience on testing bash scripts. Or should we quit using bash scripts and look for alternative solutions that are testable?
On Aug 27, 1:30 am, bitkidoku <b.ev...@gmail.com> wrote:
> Hi everyone,
> 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 want to test them. The problem is it > is hard to test the scripts.
> I would like to hear if anyone has experience on testing bash scripts. > Or should we quit using bash scripts and look for alternative > solutions that are testable?
> Thank you for your answers.
It's been a long time since I did any shell scripting, but IIRC it's possible to import (include, whatever) a procedure (function, whatever it's named) from an external file. That's the key to writing a testing script: you break up your script into independent procedures that can then be imported into both your running script and your testing script, and then you have your running script be as simple as possible.
On 27 Aug, 08:30, bitkidoku <b.ev...@gmail.com> wrote:
> Hi everyone,
> 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 want to test them. The problem is it > is hard to test the scripts.
> I would like to hear if anyone has experience on testing bash scripts. > Or should we quit using bash scripts and look for alternative > solutions that are testable?
> Thank you for your answers.
I have justed to get into this territory. The first thing that was said when I said "How do I test this shellscript then?" was "It is a shellscript so it is not portable and wont even execute properly on windoze". Our build has to work on unix (various flavours) and windoze. So we converted the scripts to python. This felt like quite a nuisance at the time but python does come with a unit testing framework similar to junit, cppunit etc etc. Writing such unit tests was useful during development but we have not yet managed to find a neat way of getting these unit tests run automatically during the continuous integration build.