1

I have an issue with the following bash script:

#Install and start application
./gradlew assemble
java -jar bignibou-server/build/libs/bignibou-server.jar&

#Run end2end tests
node_modules/.bin/protractor bignibou-client/protractor.conf.js

The first part of the script start a java application and the second part run end2end tests on that java application.

The trouble is that the end2end tests run before the java application has really started properly.

Can the bash help me here? Using the & is the cause of my problem. What is the correct way to end the java -jar command?

1
  • 1
    If you want to start the test ASAP, I'd just busy-wait/poll until the servers port is open and responsive, possibly with some smallish interval to keep the reasonably CPU cool if your sever takes some seconds to start.
    – PSkocik
    Nov 10, 2015 at 22:18

1 Answer 1

3

Your use of & to background the first process is correct here, as I presume that bignibou-server needs to be running during your tests?

By far the simplest method of introducing a delay before initiating your tests is to use the sleep command:

./gradlew assemble
java -jar bignibou-server/build/libs/bignibou-server.jar &

sleep 60

node_modules/.bin/protractor bignibou-client/protractor.conf.js

This would add a delay of 60 seconds before your tests begin. See man sleep for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.