2017 © Pedro Peláez
 

silverstripe-module ssautesting

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

image

silverstripe-australia/ssautesting

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  • Friday, June 30, 2017
  • by nyeholt
  • Repository
  • 2 Watchers
  • 4 Stars
  • 18,704 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 6 Forks
  • 5 Open issues
  • 28 Versions
  • 2 % Grown

The README.md

Symbiote Testing Extensions Module

Adds several helpers to the base SilverStripe testing framework to simplify hooking the testing process into CI servers such as Jenkins, by parameterising several configuration options., (*1)

Additionally, the module provides the SymbioteSeleniumTestCase which provides a simpler API for writing Selenium powered tests., (*2)

Command line parameters

To help with test execution, there's a few parameters that can be used to assist in speeding things up if you're repeatedly running tests., (*3)

  • build=0 - do not perform a dev/build during test initialisation
  • clean=0 - do not wipe out existing database state
  • flush=0 - do not perform a manifest flush during test initialisation

Selenium

To run just the selenium tests, a commandline such as, (*4)

php vendor/silverstripe/framework/cli-script.php dev/tests/module/test-assist \ 
  flush=1 build=1 selenium_host=127.0.0.1 browser=firefox \
  test_url=http://my.silverstripe.site/ test_type=SymbioteSeleniumTestCase SkipTests=symbioteseleniumtestcase \
  admin_user=admin admin_pass=admin

Note: The trailing slash in the URL is important!, (*5)

should get you going. Note that you will need to have selenium server running for this to work. A command such as the following will start selenium server in a virtual framebuffer, meaning the windows don't launch all over your screen!, (*6)

#!/bin/sh
/usr/bin/xvfb-run -e /var/log/selenium/xvfb-selenium.log -n 10 \
  -s "-screen 10 1024x768x8" \
  java -jar /home/path/to/programs/selenium-server-standalone-2.39.0.jar  \
  -port 4444 -log /var/log/selenium/server.log 

However it can be useful to run the selenium server directly from the commandline to debug why a test has failed., (*7)

Diagnostic tools

Swap from using MySQLDatabase to DevMySQLDatabase in your DB config, (*8)

---
Name: dev_filters
---
Injector:
  RequestProcessor:
    properties:
      filters: 
        - %$QueryDisplayFilter
        - %$RequestTimerFilter

Codeception

To hook codeception up for your project, you will need to create a codeception.yml config file at the top level of your project., (*9)

include:
  - mymodule/codeception
paths:
  log: path/to/logdir

codeception.yml defines the paths of modules to be included in the test runs., (*10)

Within your module, you can then create a namespaced project specific set of tests to be included in that top level path., (*11)

  • mkdir modulename/codeception
  • cd modulename/codeception
  • ../../vendor/bin/codecept bootstrap --namespace modulenamespace
  • mv codeception.yml codeception.dist.yml
  • touch .gitignore

Note that 'modulenamespace' can be anything, as long as it's a valid PHP namespace string, (*12)

Next, create a new codeception.yml file that contains just your local environment codeception configuration; this will typically be the local URL for developer testing, ie, (*13)

modules:
    config:
        WebDriver:
            url: http://project.clients.sslocal
            browser: chrome 

Update modulename/codeception/tests/functional.suite.xml and add a couple of modules, (*14)

class_name: FunctionalTester
modules:
    enabled:
        - \modulename\Helper\Functional
        - WebDriver # new
        - \Symbiote\TestAssist\SilverstripeFunctional # new

Update modulename/codeception/tests/_bootstrap.php to include the SilverstripFunctional helper, (*15)

<?php
// This is global bootstrap for autoloading
include_once 'test-assist/code/codeception/SilverstripeFunctional.php';

Update modulename/codeception/tests/unit/_bootstrap.php to set up the environment for unit testing:, (*16)

<?php
// Unit testing specific setup
include_once 'vendor/silverstripe/framework/tests/bootstrap.php';

Now, add the following to .gitignore, (*17)

codeception.yml
/tests/_output/

Include your module in the top level codeception.yml, (*18)

include:
  - modulename/codeception

And lastly, start writing tests! In modulename/codeception/tests/functional/FirstTestCept.php, (*19)

<?php

use \Codeception\Util\Locator;

$I = new \modulenamespace\FunctionalTester($scenario);

$I->wantTo("Test the homepage");
$I->amOnPage("/");
$I->see("Home");

In modulename/codeception/tests/unit/SmokeTest.php, (*20)

<?php

class PageTest extends SapphireTest {

    public function testMyMethod() {
        $this->assertEquals(2, Page::MyMethod());
    }
}

From the top level of the project, (*21)

$ ./vendor/bin/codecept run, (*22)

A note on better buttons

Some of the in-built helper methods won't work if better buttons is installed. If this the case, add, (*23)

\Symbiote\TestAssist\SilverstripeFunctional.use_better_buttons: true, (*24)

in codeception.dist.yml, (*25)

The Versions

30/06 2017

1.7.x-dev

1.7.9999999.9999999-dev

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

30/06 2017

1.7.1

1.7.1.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

30/06 2017

dev-master

9999999-dev

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

30/06 2017

2.0.2

2.0.2.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

29/06 2017

2.0.1

2.0.1.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

23/06 2017

2.0.0

2.0.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

18/05 2017

1.7.0

1.7.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

16/09 2016

1.6.0

1.6.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

15/06 2016

1.5.1

1.5.1.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

26/05 2016

1.5.0

1.5.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

11/05 2016

dev-legacy

dev-legacy

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

22/03 2016

1.4.1

1.4.1.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

31/07 2015

1.4.0

1.4.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

02/07 2015

1.3.0

1.3.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

26/06 2015

1.2.x-dev

1.2.9999999.9999999-dev

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

17/06 2015

1.2.1

1.2.1.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

17/06 2015

1.2.0

1.2.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

09/06 2015

1.1.x-dev

1.1.9999999.9999999-dev

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

09/06 2015

1.1.2

1.1.2.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

29/04 2015

1.0.x-dev

1.0.9999999.9999999-dev

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

The Requires

 

testing selenium silverstripe continuous integration

29/04 2015

1.0.5

1.0.5.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

The Requires

 

testing selenium silverstripe continuous integration

16/04 2015

1.1.1

1.1.1.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

16/04 2015

1.1.0

1.1.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

The Requires

 

testing selenium silverstripe continuous integration

15/04 2015

1.0.4

1.0.4.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

The Requires

 

testing selenium silverstripe continuous integration

15/04 2015

1.0.3

1.0.3.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

The Development Requires

testing selenium silverstripe continuous integration

21/03 2015

1.0.2

1.0.2.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

17/03 2015

1.0.1

1.0.1.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

testing selenium silverstripe continuous integration

12/02 2015

1.0.0

1.0.0.0

Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.

  Sources   Download

BSD-3-Clause

The Requires

 

testing selenium silverstripe continuous integration