Bash unit testing

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

Bash unit testing

#1 Post by sc0ttman »

Bash-Test

A unit testing tool for Bash scripts.

There are many alternatives, but this one (IMHO) has the nicest, cleanest, most "bog standard shell" syntax of all the ones I have found

Homepage: https://github.com/campanda/bash-test

Unit testing lets you check your functions work as expected - you just give a function some input data, and make sure the output matches some expected value.

It's very important for large projects. As new features are added, you can make sure you don't break existing features.

For example, Pkg should have unit tests... But until I found bash-test, I hadn't found one I liked, and couldn't be bothered to write my own.

Note: The PPM will be next to impossible to unit test, as it is not written in "units" (functions will can be run on their own, programmatically, without interactive input from a user).

The PPM would need "integration tests" instead.. One way to achieve this would be to:

- boot to an actual desktop
- run the tests
- use xdotool in the tests to mimic a user clicking and typing


I personally think we should start writing unit tests for Woof-CE, so we can test a Puppy build, even without booting it.

Programs that can be tested easily require a good separation of CLI and GUI.. Else you need to boot the desktop, and use xdotool - this would be "integration" tests, rather than unit tests.

Ideally you are supposed to do both, not hamper yourself in bad design so you can only do the latter.

Having a good separation of CLI and GUI would allow us to write unit tests that can be run before an ISO is even put together, or the build has ever been booted.
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

Post Reply