The tests would be very simple, here is an example:

Given a script as below:

#! /bin/bash
set -e

# start a locator
gfsh start locator --name=locator1 --mcast-port=0

# start 2 servers on a random available port
for N in {1..2}
do
 gfsh start server --locators=localhost[10334] --name=server$N
 --server-port=0 --mcast-port=0
done

------------------------------------

The bats script looks like this:

#!/usr/bin/env bats

@test "gfsh is available" {
    command -v gfsh
}
@test "starting geode locator and servers" {
  run ./startAll.sh
  [ $status -eq 0 ]
}

--------------------------------------
With the output:

 ./test.sh
 ✓ gfsh is available
 ✓ starting geode locator and servers

It can also generate a TAP-compliant [1] output and should be fairly easy
to integrate that into any build tool.  It can assert based on output or
status, etc...

I'll say that I have no problem on going the JUnit route with the only
drawback being dealing with system calls (ProcessBuilder or
getRuntime.exec)...  If that's the preferred approach, I'm ok with it.


[1] https://en.wikipedia.org/wiki/Test_Anything_Protocol








On Fri, Jun 3, 2016 at 3:03 PM, Dan Smith <[email protected]> wrote:

> Also, how easy would it be to integrate this into our existing gradle
> builds and jenkins output, etc?
>
> It seems like it might be easier to write a few lines of java code to just
> invoke a shell script and assert on the error code and output. Then you
> could just do this within junit tests - where maybe you want to make other
> assertions about the state of the system anyway?
>
> -Dan
>
> On Fri, Jun 3, 2016 at 2:23 PM, William Markito <[email protected]>
> wrote:
>
> > Guys,
> >
> > What do you think about using something like Bats [1] to test shell
> scripts
> > that will be available as part of the examples ?
> >
> > Not sure if we would have any conflicts or problems with their license
> [2]
> > but it doesn't seem the case...
> >
> > Thanks
> >
> > [1] https://github.com/sstephenson/bats
> > [2] https://github.com/sstephenson/bats/blob/master/LICENSE
> >
> > --
> >
> > ~/William
> >
>



-- 

~/William

Reply via email to