Skip to content

Commit

Permalink
DOC Update docs to reflect changes in CLI interaction (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Sep 26, 2024
1 parent 4c1654d commit 975ff8d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
36 changes: 18 additions & 18 deletions docs/circleci-tutorial.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#Setting up CircleCI and Behat
If you'd like to run SilverStripe Behat tests on CircleCI, this can be achieved (along with screenshot artifacts on
If you'd like to run SilverStripe Behat tests on CircleCI, this can be achieved (along with screenshot artifacts on
error) reasonably easily.
The below extract is a full `circle.yml` configuration file that gets the environment setup and running for Behat tests.

The below extract is a full `circle.yml` configuration file that gets the environment setup and running for Behat tests.
Please review it thoroughly as there are a few things you'll need to change for your individual project. Notably:

* If you already have a behat.yml, you should ensure your local requirements are reflected as the following script will
overwrite the behat.yml file in order to ensure screenshot failures are stored in a CircleCI-appropriate directory,
overwrite the behat.yml file in order to ensure screenshot failures are stored in a CircleCI-appropriate directory,
even if you don't store screenshots locally.
* There is one variable required below (`REPO-NAME`) that you need to fill out yourself depending on the name of your
* There is one variable required below (`REPO-NAME`) that you need to fill out yourself depending on the name of your
repository (CircleCI will check out your code into a sub-directory of the user's homedir based on the repository name).
* This assumes your Behat fixtures are located under the mysite/ directory. If not, check the `test.override` section
* This assumes your Behat fixtures are located under the mysite/ directory. If not, check the `test.override` section
below.

```
Expand All @@ -23,17 +23,17 @@ dependencies:
- ~/.composer/cache
pre:
# Enable xdebug - this is for code coverage and may not be necessary for you. Remove if you don't need it, it can
# Enable xdebug - this is for code coverage and may not be necessary for you. Remove if you don't need it, it can
# drastically slow down tests
- sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini
# We found that some machines have outdated composer versions, so we self-update before running install just in case
# We found that some machines have outdated composer versions, so we self-update before running install just in case
- sudo composer self-update
- composer install --prefer-source --no-interaction
# Behat and SilverStripe often require a reasonably large amount of memory, tune to your specific needs
- echo "memory_limit = 512M" > ~/.phpenv/versions/$(phpenv global)/etc/conf.d/memory.ini
# Setup the _ss_environment.php file per https://docs.silverstripe.org/en/3.4/getting_started/environment_management
- |
cat << 'EOF' > _ss_environment.php
Expand All @@ -43,7 +43,7 @@ dependencies:
define('SS_DATABASE_USERNAME', 'ubuntu');
define('SS_DATABASE_PASSWORD', '');
define('SS_ENVIRONMENT_TYPE', 'dev');
global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING['/home/ubuntu/REPO-NAME'] = 'http://localhost:8080/';
EOF
Expand All @@ -69,7 +69,7 @@ dependencies:
- a2enmod rewrite
- sudo service apache2 restart
# Get Selenium setup - we currently do this everytime but ideally we could store in the cache_directories and only
# Get Selenium setup - we currently do this everytime but ideally we could store in the cache_directories and only
# grab if it doesn't exist to save time - an exercise left to the reader!
- wget http://selenium-release.storage.googleapis.com/2.52/selenium-server-standalone-2.52.0.jar
- 'java -jar selenium-server-standalone-2.52.0.jar > /dev/null 2>&1':
Expand All @@ -85,7 +85,7 @@ dependencies:
# Create assets directory and add group perms
- if [ ! -d assets ]; then mkdir assets && chmod 777 assets; fi
# Setup behat.yml - you will need to merge your current behat.yml into this configuration
- |
cat > behat.yml <<EOF
Expand All @@ -110,14 +110,14 @@ dependencies:
browser: firefox
EOF
# Create database via dev/build
- framework/sake dev/build flush=1
# Create database and flush cache
- sake db:build --flush
test:
override:
# We override the CircleCI defaults to run both PHPUnit and Behat tests
- vendor/bin/phpunit
# You may need to change the @mysite below to the name of your Behat test base
- vendor/bin/behat --verbose --out=null,$CIRCLE_ARTIFACTS/_behat_results/framework.html,$CIRCLE_ARTIFACTS/_behat_results --format=pretty,html,junit @mysite --tags="~@todo"
```
```
16 changes: 8 additions & 8 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and ensure it runs on your environment. Detailed installation instructions
can be found in the [README](../README.md) of this module.
Once you've got the SilverStripe project running, make sure you've
started ChromeDriver. With all configuration in place, initialise Behat
for
for

vendor/bin/behat --init @mysite

Expand All @@ -36,7 +36,7 @@ file since it reuses the one in the root folder.
One major goal for "testing by example" through Behat is bringing
the tests closer to the whole team, by making them part of the agile
process and ideally have the customer write some tests in his own
language (read more about this concept at
language (read more about this concept at
[dannorth.net](http://dannorth.net/whats-in-a-story/)).

In this spirit, we'll start "from the outside in", and
Expand All @@ -58,7 +58,7 @@ Feature: Report Abuse
Then I should see "Thanks for your submission"
```

The "syntax" conventions used here are called the
The "syntax" conventions used here are called the
["Gherkin" language](https://github.com/cucumber/cucumber/wiki/Gherkin).
It is fairly free-form, with only few rules about indentation and
keywords such as `Feature:`, `Scenario:` or `Given`.
Expand Down Expand Up @@ -181,16 +181,16 @@ by placing it at the bottom of `themes/simple/templates/Layout/Page.ss`:
```

You can try out this feature in your browser without Behat.
Don't forget to rebuild the database (`dev/build`) and flush the
template cache (`?flush=all`) first though. If its all looking good,
Don't forget to rebuild the database and flush the
template cache (`sake db:build --flush`) first though. If its all looking good,
kick off another Behat run - it should pass now.

vendor/bin/behat @mysite

## Custom Step Definitions

Can you see the flaw in our test? We haven't actually checked that a report record
has been written, just that the user received a nice message after the form
has been written, just that the user received a nice message after the form
submission. In order to check this, we'll need to write some custom step
definitions. This is where the SilverStripe extension to Behat comes in
handy, since you're already connected to the same test database in Behat
Expand Down Expand Up @@ -220,8 +220,8 @@ public function thereShouldBeAnAbuseReportForWithReason($arg1, $arg2)
```

This code can be placed in a "context" class which was created during our
module initialization. Its located in
`mysite/tests/behat/features/bootstrap/Context/FeatureContext.php`.
module initialization. Its located in
`mysite/tests/behat/features/bootstrap/Context/FeatureContext.php`.
The actual step implementation can vary quite a bit, and usually involves
triggering a browser action like clicking a button, or inspecting the
current browser state, e.g. check that a button is visible.
Expand Down
4 changes: 2 additions & 2 deletions src/Context/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ public function stepGoToNamedRecord($type, $id)
}

/**
* Adds an extension and runs dev/build?flush
* Adds an extension and visits /dev/build?flush
*
* @param $extension
* @param $class
Expand All @@ -704,7 +704,7 @@ public function iAddAnExtensionToTheClass($extension, $class)
}

/**
* Adds an extension, but doesn't run dev/build afterwards. Will still run ?flush
* Adds an extension, but doesn't visit /dev/build afterwards. Will still run ?flush
*
* @param $extension
* @param $class
Expand Down

0 comments on commit 975ff8d

Please sign in to comment.