-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add end to end testing capabilities (#5)
* ✨ Add end to end testing capabilities * 💚 Fix Travis issue with `local` in bash script * 💚 Fix Travis issue with bash function syntax * 💚 Try switching shell to bash * 💚 Don’t try to ungzip tar * 💚Trying to fix TAR download issue * 💚 Try to fix Chorus interpreter download * 💚 Try switching environment to java and installing node manually * 💚 Add npm install * 💚 Install chromedriver * 💚 Fix CI * 💚 Fix CI * 💚 Fix CI * 📝 Update paths since renaming repo * 💚 Fix CI * Kill webpack process as well as npm parent (#3)
- Loading branch information
1 parent
efa6888
commit 0dc0638
Showing
11 changed files
with
246 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
.DS_Store | ||
*.log | ||
|
||
lib | ||
node_modules | ||
/chorus-interpreter | ||
/features/*.actual.* | ||
/lib | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
/chorus-interpreter | ||
/example | ||
/flow-typed | ||
/git-hooks | ||
.* | ||
*.log | ||
CONTRIBUTING.md | ||
e2e | ||
webpack.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/bin/bash | ||
|
||
CHORUS_INTERPRETER_DIR="./chorus-interpreter" | ||
FEATURES_DIR="./features" | ||
WEBPACK_DEV_SERVER_PORT=9000 | ||
|
||
|
||
info () { | ||
yellow=`tput setaf 3` | ||
reset=`tput sgr0` | ||
echo "${yellow}‣ $1${reset}" | ||
} | ||
|
||
success () { | ||
green=`tput setaf 2` | ||
reset=`tput sgr0` | ||
echo "${green}✓ $1${reset}" | ||
} | ||
|
||
error () { | ||
red=`tput setaf 1` | ||
reset=`tput sgr0` | ||
echo "${red}✗ $1${reset}" | ||
} | ||
|
||
show_error_and_exit () { | ||
error "$1" | ||
exit $2 | ||
} | ||
|
||
exit_if_non_zero () { | ||
if [ $1 -ne 0 ]; then | ||
show_error_and_exit "$2" $1 | ||
fi | ||
} | ||
|
||
kill_webpack_dev_server () { | ||
if [ ! -z "$WEBPACK_DEV_SERVER_PID" ]; then | ||
echo "Killing npm webpack-dev-server parent using pid $WEBPACK_DEV_SERVER_PID" | ||
kill -SIGINT $WEBPACK_DEV_SERVER_PID | ||
sleep 1 | ||
|
||
if [ $? -ne 0 ] ; then | ||
echo "Failed to kill webpack-dev-server" | ||
else | ||
echo "Killed webpack-dev-server" | ||
fi | ||
fi | ||
|
||
PID=$(lsof -ti :$WEBPACK_DEV_SERVER_PORT) | ||
if [ ! -z "$PID" ]; then | ||
echo "Killing npm webpack server using pid $PID" | ||
kill -SIGINT $PID | ||
fi | ||
return 0 | ||
} | ||
|
||
|
||
if [ ! -d "$CHORUS_INTERPRETER_DIR" ]; then | ||
info "Installing latest version of the Chorus interpreter..." | ||
|
||
# get HTML page content | ||
HTML=$(curl -L -s http://github.com/nickebbutt/Chorus/releases/latest) | ||
exit_if_non_zero $? "Could not find Chorus interpreter latest release HTML page!" | ||
|
||
# find the wanted <a> tag | ||
TAR_A_TAG=$(echo "$HTML" | grep -s -E 'href="(.*chorus.*\.tar)') | ||
exit_if_non_zero $? "Could not find Chorus interpreter release link tag!" | ||
|
||
# extract href value | ||
TAR_RELATIVE_LINK=$(awk -F\" '{print $2}' <<< $TAR_A_TAG) | ||
exit_if_non_zero $? "Could not extract Chorus interpreter TAR link!" | ||
|
||
# build absolute url for tar file | ||
TAR_URL="http://github.com$TAR_RELATIVE_LINK" | ||
|
||
# download and untar | ||
rm -rf "$CHORUS_INTERPRETER_DIR" | ||
mkdir "$CHORUS_INTERPRETER_DIR" | ||
curl -L $TAR_URL | tar -x -C "$CHORUS_INTERPRETER_DIR" --strip-components=1 | ||
exit_if_non_zero $? "Could not download latest version of the Chorus interpreter!" | ||
else | ||
info "Using already installed version of the Chorus interpreter..." | ||
fi | ||
|
||
CHROME_DRIVER_PATH=$(which chromedriver) | ||
exit_if_non_zero $? "Could not find chromedriver executable" | ||
echo "Using chromedriver at ${CHROME_DRIVER_PATH}" | ||
|
||
if [ "$TRAVIS" ]; then | ||
CHROME_PATH=$(which google-chrome) | ||
exit_if_non_zero $? "Could not find google-chrome executable" | ||
echo "Using google-chrome at ${CHROME_PATH}" | ||
fi | ||
|
||
info "Starting JS client..." | ||
npm start & | ||
WEBPACK_DEV_SERVER_PID=$! | ||
echo "webpack-dev-server pid is $WEBPACK_DEV_SERVER_PID" | ||
|
||
# Kill webpack-dev-server (was running because of `npm start`) | ||
trap kill_webpack_dev_server SIGINT SIGTERM EXIT | ||
|
||
info "Executing chorus tests..." | ||
for feature in $FEATURES_DIR/*.feature | ||
do | ||
info "Executing feature: $feature..." | ||
$CHORUS_INTERPRETER_DIR/chorus -f $feature > $feature.actual.txt | ||
|
||
info "Diffing output..." | ||
git diff --no-index --color-words -w $feature.expected.txt $feature.actual.txt | ||
DIFF_EXIT_CODE=$? | ||
|
||
if [ $DIFF_EXIT_CODE -eq 0 ]; then | ||
success "Chorus interpreter output has not changed. ($feature)" | ||
fi | ||
|
||
rm $feature.actual.txt | ||
|
||
exit_if_non_zero $DIFF_EXIT_CODE "Actual Chorus interpreter output was different from expected! ($feature)" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Uses: StepServer | ||
Uses: Selenium | ||
|
||
Feature: Basic steps | ||
|
||
#! StepServer start | ||
Feature-Start: | ||
Given I open Chrome | ||
|
||
Background: | ||
Given I navigate to http://localhost:9000 | ||
And StepServer client SimpleStepPublisher is connected | ||
|
||
Scenario: I can call steps with and without a result | ||
Check I can call a step with a result | ||
And I can call a step without a result | ||
|
||
Scenario: I can call steps which fail | ||
Check I can call a step with a result | ||
And I can call a step which fails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Feature: Basic steps | ||
Scenario: Feature-Start | ||
#! StepServer start PASSED | ||
Given I open Chrome PASSED | ||
Scenario: I can call steps with and without a result | ||
Given I navigate to http://localhost:9000 PASSED | ||
And StepServer client SimpleStepPublisher is connected PASSED | ||
Check I can call a step with a result PASSED hello! | ||
And I can call a step without a result PASSED | ||
Scenario: I can call steps which fail | ||
Given I navigate to http://localhost:9000 PASSED | ||
And StepServer client SimpleStepPublisher is connected PASSED | ||
Check I can call a step with a result PASSED hello! | ||
And I can call a step which fails FAILED (WebSocketClientStepInvoker:158)-StepFailedException | ||
|
||
|
||
Features (total:1) (passed:0) (failed:1) | ||
Scenarios (total:2) (passed:1) (failed:1) | ||
Steps (total:10) (passed:9) (failed:1) (undefined:0) (pending:0) (skipped:0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Uses: StepServer | ||
Uses: Selenium | ||
|
||
Feature: I can use the counter | ||
|
||
#! StepServer start | ||
Feature-Start: | ||
Given I open Chrome | ||
|
||
Background: | ||
Given I navigate to http://localhost:9000 | ||
And StepServer client SimpleStepPublisher is connected | ||
|
||
Scenario: I can read the counter | ||
Then the counter value is 0 | ||
|
||
Scenario: I can increment the counter | ||
Given the counter value is 0 | ||
When I click on the increment button | ||
Then the counter value is 1 | ||
|
||
Scenario: I can decrement the counter | ||
Given the counter value is 0 | ||
When I click on the decrement button | ||
Then the counter value is -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Feature: I can use the counter | ||
Scenario: Feature-Start | ||
#! StepServer start PASSED | ||
Given I open Chrome PASSED | ||
Scenario: I can read the counter | ||
Given I navigate to http://localhost:9000 PASSED | ||
And StepServer client SimpleStepPublisher is connected PASSED | ||
Then the counter value is 0 PASSED 0 | ||
Scenario: I can increment the counter | ||
Given I navigate to http://localhost:9000 PASSED | ||
And StepServer client SimpleStepPublisher is connected PASSED | ||
Given the counter value is 0 PASSED 0 | ||
When I click on the increment button PASSED | ||
Then the counter value is 1 PASSED 1 | ||
Scenario: I can decrement the counter | ||
Given I navigate to http://localhost:9000 PASSED | ||
And StepServer client SimpleStepPublisher is connected PASSED | ||
Given the counter value is 0 PASSED 0 | ||
When I click on the decrement button PASSED | ||
Then the counter value is -1 PASSED -1 | ||
|
||
|
||
Features (total:1) (passed:1) (failed:0) | ||
Scenarios (total:3) (passed:3) (failed:0) | ||
Steps (total:15) (passed:15) (failed:0) (undefined:0) (pending:0) (skipped:0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters