Smoke Testing with Hookah

younginnovations/hookah

Hi, I'm Manish Gopal Singh.

Software Developer

@mgsingh3

What is hookah?

Hookah is a small smoke testing command line library for any web application.

Software testing

It is the process used to identify the correctness, completeness and quality of developed computer software.

Why Testing?

  • To identify errors (or bugs) in a software.
  • To make sure a software matching its requirements.
  • To gain the confidence that it works.
  • Effective performance of software application

Manual testing

Vs

Automated Testing

Manual Testing

Manual tests may find many bugs however it is a laborious and time consuming process. The effort required is the same each time

Coding Process with Manual Tests

  • Write code
  • Deploy the code to server
  • Running the code manually
  • Checking Logs, Database, Output on the screen etc
  • If it does not work, repeat

Pros:

  • Short-term cost is lower
  • Flexible
  • More likely to find real user issues

Cons:

  • Boring
  • Not reusable
  • Takes more Effort and Cost

Automated Testing

The use of automation improves quality and team morale. Automated Tests are part of the codebase

Coding Process with Automated Unit Tests

  • Write one or more test cases
  • Run the tests
  • If tests fail -> write code to pass the tests
  • Run the tests
  • If tests pass -> repeat for next method

Pros:

  • Save Time
  • Speed
  • Reusable
  • Quick and effective

Cons:

  • Takes time
  • Limitations

Types of testing

  • Unit
  • Functional
  • Acceptance
  • Integration
  • Regression
  • Smoke
  • Security
  • Load
  • Usability
  • and more ...

Smoke testing

A smoke test is basically just a sanity check to see if the software functions on the most basic level.

If your smoke test fails, it means there is no point in running your other functional tests.

Hookah Time

Prerequisites

PHPUnit and Goutte 2.x

Optional: Paratest

Install Hookah

Clone repo :

  1. git clone git@github.com:younginnovations/hookah.git
  2. cd hookah
  3. composer install --prefer-dist

Use as Composer package

composer require --dev yipl/hookah

or

Add "yipl/hookah": "~0.4" and composer install

Run Test

Run with phpunit

./vendor/bin/phpunit

Run tests faster

./vendor/bin/paratest -f --colors -m 2 -p 4 tests

Structure

  • tests\Smoke folder contains 2 folders
  • FrontEnd: to test application without logging in.
  • BackEnd: to test application with logging in.

Settings

You can set the base URL at BaseTestCase.php

/**
 * @var string
 */
protected $baseUrl = 'http://drupal-test.jelastic.elastx.net/';

/**
 * @var string
 */
protected $loginPath = 'user/login';


/**
 * @var string
 */
protected $usernameField = 'name';

/**
 * @var string
 */
protected $passwordField = 'pass';

/**
 * @var string
 */
protected $submitButtonText = 'Log in';

/**
 * @var array
 */
protected $users =  [
    ['role'=> 'admin', 'identifier' => 'admin', 
    'password' => '123admin'],
];


/**
 * @var string
 */
protected $loggedInLinkText = 'Log out';

/**
 * To be overridden by child class
 *
 * @var string
 */
protected  $userRole = 'none';
	
Frontend paths in dataProvider (PagesTest.php)

     return [
                [$this->baseUrl, 200],
                ['about', 200],
                ['not-existing', 404],
                ['.git', 403],
            ];
Backend paths (AdminUserTest.php)

 $adminPaths = [
        ['admin', 200],
        ['admin/config', 200],
        ['not-existing', 404]
    ];
 

Demo

References:
  • http://www.slideshare.net/directi/automated-testing-vs-manual-testing-391121?related=1
  • http://www.softwaretestinghelp.com/
  • http://selleo.com/blog/software-outsourcing/the-value-of-automated-testing/4/
Thank you
Questions?