Concept "Software Testing"

From SMW CindyKate - Main
Component 601328
Jump to: navigation, search

Content


The following table serves as a reminder to myself about why (and how) I test software. It is a working document and therefore neither complete nor objectively impeccable.

WHAT
do we write?
WHY
do we write that?
WHERE
do we write that?
Executable documentation about your system
HOW
do we write that?
(Not what is it, but what DOES it DO?)
Specification language Who reads this? Who edits this?

Cucumber

"Build the right things!"

Features: Why?1

Who? What?
2
Scenarios: Specification by examples (Make abstract thinking unnecessary!)
Steps
  • Describe the behaviour you wish you had
  • → developing your ubiquitous language (UL)
features/*.feature
# healthtest.feature
Feature: LCC SMW Healthtest
  Scenario: Set up LCCFeatureContext
    * I instantiate the LCCFeatureContext
    * I connect to the "SSH: LCC SMW APP"
Before/After  Temporary environment for
              all features?
Feature       System behaviour?
  Background  Common introductory steps for
              all scenarios in this feature?
  Scenario Outline
  Scenario    PARAMETRIZED example for
              system behaviour?
    Given     Conditions/context?
    When      Actions/events?
    Then      Expected results?
    And/But/*
  • Natural language3 for reasoning
  • Gherkin (Cucumber DSL)4 for semantic structuring describing the behaviour of your system
  • Every human being involved, by natural language
  • Computer, by Gherkin/regex
  • Moderator and/with/for every human being involved

Cucumber support code

features/support/*.rb
# lcc_feature_context.rb
class LCCFeatureContext
...
  def map_context context
    case context
    when "SSH: LCC SMW APP"
      context = @@app_ssh_context
    end
  end
...
  def app_ssh_context access_profile
    @@app_ssh_context = SSHConnection.new(profile).connector
  end
...
end

Cucumber step definitions

  • Define the API calls you wish you had
  • → developing your domain specific language (DSL) based on UL
features/step_definitions/*.rb
# instantiate_the_lcc_feature_context_steps.rb
When(/^I instantiate the LCCFeatureContext$/) do
  $lcf = LCCSMWTools::LCCFeatureContext.new
end

# context_connectors_steps.rb
When(/^I connect to the "(.*?)"$/) do |context|
  profile = LCCProfileFromYAML.new(ENV['APP']).app_ssh_root_access
  $lcf.app_ssh_context(profile)
end

Pass or raise an exception

* /^<regexp>$/
    begin/raise/rescue  API calls?
    expect              Implementation?
  • Ruby for "translating"
  • Your DSL for reasoning
  • RSpec DSL5 for semantic structuring describing the expected behaviour of instances of your objects
  • Scrum master
  • Developers
  • Computer
  • Scrum master
  • Developers

RSpec tests

"Build the things right!"

  • Describe the functionality you wish you had for each API call defined
spec/

Meet or fail expectations

describe      Object?
  context
    before
    after
    around
    it        Example for object behaviour?
      expect  Implementation?

Code library

  • Implement the functionality for each API call defined
bin/            CLI
lib/
  entities/     Business objects
  interactors/  API
  boundaries/   Delivery systems
  helpers/
# lcc_appliance_profile_from_yaml.rb
def appliance_ssh_root_access
  params = {
    protocol: { 'APP-SSH'           => 'Protocol' },
    port:     { 'APP-SSH'           => 'Port' },
    host:     { 'APP-SSH'           => 'Host' },
    username: { 'APP-SSH-USER-ROOT' => 'Username' },
    keyfile:  { 'APP-SSH-USER-ROOT' => 'Keyfile'}
  }
  self.check_params(params)
  params[:url] = "#{params[:username]}@#{params[:host]}"
  return params
end
  • Any programming language for implementing
modules, classes and methods
  • Developers
  • Computer
  • Developers


References

  1. ^  Avoid YAGNI (→ TDD)
  2. ^  Feature injection template
  3. ^  cucumber --i18n help
  4. ^  cucumber --i18n en Cucumber CLI matchers
  5. ^  RSpec expectations