Pinscher Testing

“How can I best get up the mountain?” – Just climb upwards, and don’t think about it! Friedrich Nietzsche

Month: November 2015 (Page 1 of 6)

Keep It Functional, an iOS Functional Testing Framework

KIF, Keep It Functional, is an iOS integration test environment. It allows easy automation of iOS applications, taking advantage of the attributes of accessibility that the operating system provides to people with visual impairments.
KIF builds and tests using XCTest, a standard test target. The testing is conducted synchronously in the main thread allowing for greater complexity and logic of composition.

context(@"in saved AdPage", ^{
   it(@"remove saved ad by action button in row", ^{
      tap(@"Search") _then
      wait_default_time _then
      tap_item_in_collection_view(SBTResultsCollectionView, 2) _then
      wait_view(adTitle_app) _then
      tap(SBTSaveAdButton) _then
      tap(@"Favourites") _then
      wait_default_time _then
      tap(@"Modify") _then
      wait_default_time _then
      tap(SBTSavedAdCellRemoveAdButton) _then
      wait_default_time _then
      wait_absence_of_view(adTitle_app) _end

…where tap, wait, tap_item_in_collection_view, wait_absence_of_view are described here:

Kiwi, a Behavior Driven Development library for iOS development

Kiwi is a Behavior Driven Development library for iOS development.
The idea behind Kiwi is to have unit tests readable and simple to implement.
The tests are written in Objective-C and run in Xcode to provide a test environment that is as unobtrusive and simple as possible in terms of test execution and error reporting.

#import "Kiwi.h"
#import "ChangeSearchParameterViewController.h"
#import "ChangeSearchParameterViewController+SBTPrivate.h"


describe(@"Change search parameter controller", ^{
   context(@"when created", ^{
       NSManagedObjectContext *moc = [Model setupCoreDataStackWithInMemoryStoreAndLoadConfiguration];
       Search *search = [Search baseObjectInContext:moc];
       id fakeDelegate = [KWMock mockForProtocol:@protocol(ChangeSearchParameterViewControllerDelegate)];
       ChangeSearchParameterViewController *changeSearchParameterViewController = [[ChangeSearchParameterViewController alloc] initWithSearch:search];
       changeSearchParameterViewController.delegate = fakeDelegate;
       it(@"should not be nil", ^{
           [[changeSearchParameterViewController should] beNonNil];
       it(@"should has delegate equal to fakeDelegate", ^{
           [[fakeDelegate should] equal:changeSearchParameterViewController.delegate];
       context(@"when dismissed", ^{
           it(@"should call delegate", ^{
               [[fakeDelegate should] respondToSelector:@selector(changeSearchParameterDidFinish:modifiedSearch:changedParameters:)];
               [[fakeDelegate should] receive:@selector(changeSearchParameterDidFinish:modifiedSearch:changedParameters:)];
               [changeSearchParameterViewController notifyDelegateAndDismiss];


Kiwi site

Acceptance Criteria and Acceptance Test

The first step which underpins the entire testing process is the definition of Acceptance Criteria (AC) that establish the correct operation and completion of the product.
More specifically, the AC is a set of instructions, which specify the functional requirements and not the product, defining the concept of quality of the same. The AC constitute our “Definition of Done” relative to an Epic, Feature and Story.
The definition of the AC allows the team to figure out when it’s done and not to forget important borderline.
AC are produced through collaboration between developers, testers and product owner and are created before the development, during the planning phase.
AC are expressed at high levels (conceptual, not detailed) and then in the form that works best for the team (keep it minimal).

During the Kick off QA and developer in a session of 10-15 minutes should achieve the Acceptance Test (AT) in order to define the behavior of the system and ensure the realization of the product as expected.
QA and developers agree, also, the tests to implement, sometimes also including the product owner and the other stackeholder.
The implementation of the test takes place during development (ideally test-first).

It is considered appropriate to build a Map of Acceptance Test automatic and / or manual to improve the process of testing and development. They will be designed at the level of Unit Testing, Integration Testing, End to End Test, UI Test and Boundary Test.
A basic rule during the writing test, especially when we talk about Unit Test, often difficult to understand, is to assign a meaningful name so that the QA and the developer can then maintain them. So once defined the test or set of tests anyone can test the story, feature or epic.

What is System Testing?

The System Testing verify the correct execution of the entire application, including interfaces with other applications.
As a rule, system testing takes, as its input, all of the “integrated” software components that have passed integration testing.

It provides several specific tests:

  • Functional Test: check that all functions are properly completed in a scenario similar to that of the end users.
  • Usability Testing: check the ease of use and understandability of the application from the end users.
  • Performance Test: check the performance of the product such as response time and resource usage (memory, transmission lines, databases, other components).
  • Reliability Test: check the reliability of the product when it is explicitly requested. The reliability is defined as the ability of the product to operate for an entire period of time (8 working hours, or H24/7×7) without being detected any defect that disrupts the operation.
  • Stress/Load Test: check the product’s ability to sustain a given workload.
  • Security Test: check of the level of security provided by the system.

What is Integration Testing?

Integration testing (IT) is the phase in software testing in which individual software modules are combined and tested as a group. It occurs after unit testing.
The modules of the component have been tested, in an integrated manner, in the test environment prepared, isolated and controlled.

The integration can be done in three different ways:

  • Integration Top-down: requires that simulated the components of lowest level.
  • Integration Bottom-up: requires that simulated the components of higher level.
  • Integrating mixed (both previous techniques).

The simulations with other subsystems not yet ready are programs simulated using “ghost” called scaffolding (drivers, stubs).

What is Unit Testing?

Unit Testing (UT) is the first dynamic test of the executable code, both in its initial and any subsequent changes.
Executed directly by the developer in its development environment, it checks the adherence to specific programming from the logical point of view the program; valid then its internal logic.

The advantages of the unitary test are:

  • find problems early in the development cycle
  • facilitates the modification of the code of the module at a later date (refactoring)
  • simplifies the integration of different modules
  • provides a sort of living documentation of the system.

CSS testing with PhantomCSS

CSS3 is the ignition and responsive design will become the driving force of developments in visual and CSS testing. PhantomCSS is one of many new tools to support this paradigm shift in UI testing.

PhantomCSS takes screenshots captured by CasperJS and compares them to baseline images using Resemble.js to test for rgb pixel differences. PhantomCSS then generates image diffs to help you find the cause.

I have tested PhantomCSS directly in and I have achived good results.

After the download of PhantomCSS, I have created my giuseppecilia.js in demo folder:

var phantomcss = require('./../phantomcss.js');

casper.start( '' );
casper.viewport(1024, 768);

casper.then( function(){
  //takes images of first period of first article
  phantomcss.screenshot('.entry-content>p:first-child', 'first period of first article');

casper.then( function now_check_the_screenshots(){
  phantomcss.compareAll(); //compare screenshots

casper.then( function end_it(){
  console.log('\nTHE END.');

From the command line/terminal run:
casperjs demo/giuseppecilia.js (on Windows)
casperjs test demo/giuseppecilia.js (on Mac OSX)

…in PhantomCSS>casperjs demo\giuseppecilia.js
Test file: demo\giuseppecilia.js

Must be your first time?
Some screenshots have been generated in the directory .\screenshots
This is your ‘baseline’, check the images manually. If they’re wrong, delete the images.
The next time you run these tests, new screenshots will be taken.
These screens hots will be compared to the original.
If they are different, PhantomCSS will report a failure.
WARN Looks like you didn’t run any test.

first period of first article_0.diff

SECOND LAUNCH without modify/bug
casperjs demo\giuseppecilia.js
Test file: demo\giuseppecilia.js

PASS No changes found for screenshot .\screenshots\first period of first article_0.png

PhantomCSS found 1 tests, None of them failed. Which is good right?
If you want to make them fail, go change some CSS – weirdo.
PASS 1 test executed in 12.415s, 1 passed, 0 failed, 0 dubious, 0 skipped.

casperjs demo\giuseppecilia.js
Test file: demo\giuseppecilia.js

FAIL Visual change found for screenshot .\screenshots\first period of first article_0.png (6.11% mismatch)
# type: fail
# file: demo\giuseppecilia.js
# subject: false

PhantomCSS found 1 tests, 1 of them failed.
PhantomCSS has created some images that try to show the difference (in the directory .\failures).
Fuchsia colored pixels indicate a difference betwen the new and old screenshots.
FAIL 1 test executed in 13.554s, 0 passed, 1 failed, 0 dubious, 0 skipped.

Details for the 1 failed test:
In demo\giuseppecilia.js
Untitled suite in demo\giuseppecilia.js
fail: Visual change found for screenshot .\screenshots\first period of first article_0.png (6.11% mismatch)

first period of first article_0

This is the “fail” image that permit to individuate the difference/the bug:
first period of first

casperjs demo\giuseppecilia.js
Test file: demo\giuseppecilia.js

PASS No changes found for screenshot .\screenshots\first period of first article_0.png

PhantomCSS found 1 tests, None of them failed. Which is good right?
If you want to make them fail, go change some CSS – weirdo.
PASS 1 test executed in 12.025s, 1 passed, 0 failed, 0 dubious, 0 skipped.

Best practices with PhantomCSS:

  • Name your screenshots!
  • CSS3 selectors for testing
  • PhantomCSS should not be used to replace functional tests
  • Don’t try to test all the visuals
  • Full page screenshots are a bad idea
  • Scaling visual regression testing within a large team
  • Scaling visual regression testing with Git

What is CasperJS?

CasperJS is a navigation scripting & testing utility for the PhantomJS (WebKit) and SlimerJS (Gecko) headless browsers, written in Javascript.
It’s easy to install and easy to start!

var casper = require('casper').create();
casper.start('', function() {

Run it:
casperjs sample.js

we created a new Casper instance
we started it and opened
once the page has been loaded, we asked to print the title of that webpage (the content of its title tag)
we executed the whole process

CasperJS is also a testing framework; test scripts are slightly different than scraping ones, though they share most of the API.

A simplest test script:

casper.test.begin("Hello, Test!", 1, function(test) {

Run it using the casperjs test subcommand:
casperjs test hello-test.js

Test file: hello-test.js
#Hello, Test!
PASS Subject is strictly true
PASS 1 test executed in 0.023s, 1 passed, 0 failed, 0 dubious, 0 skipped.

CasperJS makes an heavy use of selectors in order to work with the DOM, and can transparently use either CSS3 or XPath expressions.

The tester module
CasperJS can export the results of the test suite to an XUnit XML file, which is compatible with continuous integration tools such as Jenkins. To save the XUnit log of your test suite, use the –xunit option:
casperjs test googletesting.js –xunit=log.xml

Export a test case recorded with Selenium IDE

There are many languages to export a test case recorded with Selenium IDE:

  • Ruby
  • Java
  • Python
  • C#

and WebDriver.


require "json"
require "selenium-webdriver"
require "rspec"
include RSpec::Expectations

describe "Pinschertestingruby" do

  before(:each) do
    @driver = Selenium::WebDriver.for :firefox
    @base_url = ""
    @accept_next_alert = true
    @driver.manage.timeouts.implicit_wait = 30
    @verification_errors = []
  after(:each) do
    @verification_errors.should == []
  it "test_pinschertestingruby" do
    @driver.get(@base_url + "/?gfe_rd=cr&ei=_tZaVpb8EKfD8gepw63ABA&gws_rd=ssl")
    @driver.find_element(:id, "lst-ib").clear
    @driver.find_element(:id, "lst-ib").send_keys "giuseppe cilia pinscher tes"
    @driver.find_element(:css, "#sbse0 > div").click
    @driver.find_element(:id, "lst-ib").clear
    @driver.find_element(:id, "lst-ib").send_keys "giuseppe cilia pinscher testing"
    @driver.find_element(:link, "Pinscher Testing | “How can I best get up the mountain ...").click
    @driver.find_element(:css, "ul.main-menu > > a").click
    @driver.find_element(:link, "pinschertesting").click
  def element_present?(how, what)
    ${receiver}.find_element(how, what)
  rescue Selenium::WebDriver::Error::NoSuchElementError
  def alert_present?()
  rescue Selenium::WebDriver::Error::NoAlertPresentError
  def verify(&blk)
  rescue ExpectationNotMetError => ex
    @verification_errors << ex
  def close_alert_and_get_its_text(how, what)
    alert = ${receiver}.switch_to().alert()
    alert_text = alert.text
    if (@accept_next_alert) then
    @accept_next_alert = true



package com.example.tests;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Pinschertestingjava {
  private WebDriver driver;
  private String baseUrl;
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

  public void testPinschertestingjava() throws Exception {
    driver.get(baseUrl + "/?gfe_rd=cr&ei=_tZaVpb8EKfD8gepw63ABA&gws_rd=ssl");
    driver.findElement("lst-ib")).sendKeys("giuseppe cilia pinscher tes");
    driver.findElement(By.cssSelector("#sbse0 > div")).click();
    driver.findElement("lst-ib")).sendKeys("giuseppe cilia pinscher testing");
    driver.findElement(By.linkText("Pinscher Testing | “How can I best get up the mountain ...")).click();
    driver.findElement(By.cssSelector("ul.main-menu > > a")).click();

  public void tearDown() throws Exception {
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {

  private boolean isElementPresent(By by) {
    try {
      return true;
    } catch (NoSuchElementException e) {
      return false;

  private boolean isAlertPresent() {
    try {
      return true;
    } catch (NoAlertPresentException e) {
      return false;

  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      String alertText = alert.getText();
      if (acceptNextAlert) {
      } else {
      return alertText;
    } finally {
      acceptNextAlert = true;



# -*- coding: utf-8 -*-
from selenium import webdriver
from import By
from selenium.webdriver.common.keys import Keys
from import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class Pinschertestingpython(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.base_url = ""
        self.verificationErrors = []
        self.accept_next_alert = True
    def test_pinschertestingpython(self):
        driver = self.driver
        driver.get(self.base_url + "/?gfe_rd=cr&ei=_tZaVpb8EKfD8gepw63ABA&gws_rd=ssl")
        driver.find_element_by_id("lst-ib").send_keys("giuseppe cilia pinscher tes")
        driver.find_element_by_css_selector("#sbse0 > div").click()
        driver.find_element_by_id("lst-ib").send_keys("giuseppe cilia pinscher testing")
        driver.find_element_by_link_text(u"Pinscher Testing | “How can I best get up the mountain ...").click()
        driver.find_element_by_css_selector("ul.main-menu > > a").click()
    def is_element_present(self, how, what):
        try: self.driver.find_element(by=how, value=what)
        except NoSuchElementException, e: return False
        return True
    def is_alert_present(self):
        try: self.driver.switch_to_alert()
        except NoAlertPresentException, e: return False
        return True
    def close_alert_and_get_its_text(self):
            alert = self.driver.switch_to_alert()
            alert_text = alert.text
            if self.accept_next_alert:
            return alert_text
        finally: self.accept_next_alert = True
    def tearDown(self):
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":



using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;

namespace SeleniumTests
    public class Pinschertestingc
        private IWebDriver driver;
        private StringBuilder verificationErrors;
        private string baseURL;
        private bool acceptNextAlert = true;
        public void SetupTest()
            driver = new FirefoxDriver();
            baseURL = "";
            verificationErrors = new StringBuilder();
        public void TeardownTest()
            catch (Exception)
                // Ignore errors if unable to close the browser
            Assert.AreEqual("", verificationErrors.ToString());
        public void ThePinschertestingcTest()
            driver.Navigate().GoToUrl(baseURL + "/?gfe_rd=cr&ei=_tZaVpb8EKfD8gepw63ABA&gws_rd=ssl");
            driver.FindElement(By.Id("lst-ib")).SendKeys("giuseppe cilia pinscher tes");
            driver.FindElement(By.CssSelector("#sbse0 > div")).Click();
            driver.FindElement(By.Id("lst-ib")).SendKeys("giuseppe cilia pinscher testing");
            driver.FindElement(By.LinkText("Pinscher Testing | “How can I best get up the mountain ...")).Click();
            driver.FindElement(By.CssSelector("ul.main-menu > > a")).Click();
        private bool IsElementPresent(By by)
                return true;
            catch (NoSuchElementException)
                return false;
        private bool IsAlertPresent()
                return true;
            catch (NoAlertPresentException)
                return false;
        private string CloseAlertAndGetItsText() {
            try {
                IAlert alert = driver.SwitchTo().Alert();
                string alertText = alert.Text;
                if (acceptNextAlert) {
                } else {
                return alertText;
            } finally {
                acceptNextAlert = true;

Record and Run again with Selenium IDE

We record something with Selenium IDE, but before need download and install it.

Open Firefox browser -> Tools -> add-ons -> search “selenium ide” -> Install “Selenium IDE 1.* (Record, edit and play Selenium tests)” and “Selenium IDE Button 1.* (Just one simple toolbar button to open Selenium IDE)”.

Open Selenium IDE and try to search in the browser.
Return in the Selenium IDE and stop the registration. (Click on red ball.)

I have searched “giuseppe cilia pinscher testing”, clicked on first result, clicked on “Contact”, and twitter account.

Selenium IDE has recorded my events and now I can modify, run again and export in many formats!


giuseppe cilia pinscher tes
css=#sbse0 > div

giuseppe cilia pinscher testing
link=Pinscher Testing | “How can I best get up the mountain ...

css=ul.main-menu > > a


So to run again with Selenium IDE need click on “Run all commands” or “Run only the command selected”.
Also Selenium IDE provides a slider with Slow and Fast pointers to control the speed of execution.

Page 1 of 6

Powered by WordPress & Theme by Anders Norén