Skip to main content
Automate Your Data, Free
Your Mind
Aaron Swerlein
• About Me
• CRUD
• ETL
• Testing
• Benefits of Automation
• Tools
• Examples
• Questions
Contents
2
• I have a 7 year old daughter.
• I enjoy playing card games (Euchre, Rummy, Uno, MTG)
• Love watching movies -> /(H|B)ollywood/
• I am an identical twin.
About Me
3
Introduction | CRUD
4
Introduction | ETL Flow
5
Arrange
• Source file/table
• Front end
application
Action
• Stored Procedure,
SQL script
• Submitting form
on front end
Assert
• Data in target
Introduction | Testing
6
Database Testing
7
Database Testing | CRUD
8
Create
• New groups
or users
Read
• Connect to
database
• Validate
tables/views
Update
• Change
existing
groups or
accesses
Delete
• Inability to
connect
Table Testing
9
Table Testing | CRUD
10
Create
• New column,
constraint,
relationship
Read
• Validate
existence of
table
Update
• Table changes
Delete
• Removing
constraints
• Removing
Columns
• Removing
relationships
Data Testing
11
Data Testing | CRUD
12
Create
• Inserted record
is present
Read
• Can access data
Update
• Record is
present, but
original record
no longer there
Delete
• Record no
longer exists
Benefits of Automation | Time
13
Benefits of Automation | Coverage
14
Benefits of Automation | Effort
15
• Image from Bahubali
Benefits of Automation | Deployment
16
Benefits of Automation |Jenkins
17
Benefits of Automation | Jenkins
18
Benefits of Automation | Jenkins
19
Benefits of Automation | Living Documentation
20
Benefits of Automation | Persistence
21
Scenario: validating speaker at QA or the Highway
When the user navigates to the qa or highway speakers webpage
Then the user validates the speaker Kyle Swerlein is present
Tools
Ruby/Cucumber
23
• Ruby
– Expressive language
– Good flexibility
• Cucumber
– Allows for plain English scenarios to express requirements.
– Helps bridge the developer – analyst knowledge gap
Cucumber Example
24
@regression
Scenario: validating test table loaded after jobs run
Given data is present in the source
When job 1 is executed
And job 2 is executed
And job 3 is executed
Then test table is loaded
Ruby Gems
25
• Active Record:
– Default for Ruby on Rails
– Large bulky library, includes all of functionality
• Sequel:
– Lighter gem
– Uses adapters and plugins to add functionality to core gem
• Other:
– IBM_DB, OCI8, ADO
• Sequel is a RubyGem which allows a user to connect to a
database.
• It includes a comprehensive ORM layer for mapping records to
Ruby objects and handling associated records. (Active-Record
Design Pattern)
• Sequel has adapters for ADO (access), IBM_DB, JDBC,
MySQL, ODBC, Oracle, Hadoop, and many others
Ruby Gem - Sequel
26
ORM (Object Relational Mapping)
27
• Sequel.connect()
Sequel.connect(adapter: 'adapter', database: ‘database',
username: 'username', password: 'password‘, port: ’port’)
Sequel.connect("#{adapter}://#{username}:#{password}@#{hostname}:#{
port}/#{database}"
• Sequel.ado()
• $connection
Sequel Connection Examples
28
Sequel.ado(conn_string: "Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=C:/db/test_location.accdb")
Creating Table classes
29
class TableName <
Sequel::Model($oracle_connection[“database_name__table_name".to_sym])
set_primary_key :primary_key
end
class TableName < Sequel::Model(
$oracle_connection[Sequel.qualify(“database_name”, “table_name")])
set_primary_key :primary_key
end
Sequel.split_symbols = true
Querying with Sequel
30
• Once connected to a Database you can query a couple of
different ways.
– Straight SQL statement
– Sequel ruby methods
Sequel Using SQL
31
• The Sequel library has different methods which can be called
passing in a SQL query. To do this, you need to call the
instantiated connection object you created i.e. $connection
– $connection.run(‘sql’)
– $connection.fetch(‘sql’)
Sequel Using Ruby
32
where/exclude
order/reverse
select
Joininsert
update
delete
SQL VS. SEQUEL | Create
33
TableName.insert(presenter_name: 'Aaron Swerlein',
conference_name: 'QA or the Highway 2017',
talk_time: '2017-02-27 11:05:00.000000')
SQL VS. SEQUEL | Read
34
TableClass.select(:column_a, :column_b)
.where(column_a: 'text')
.where(column_b: [0,9])
.group(:column_a)
.order(:column_a)
SQL VS. SEQUEL | Update
35
TableName.where(presenter_name: 'Aaron Swerlein')
.where(conference_name: 'QA or the Highway')
.update(talk_time: '2018-02-27 11:05:00.000000')
SQL VS. SEQUEL | Delete
36
TableName.where(presenter_name: 'Aaron Swerlein')
.where(conference_name: 'QA or the Highway').delete
Helpful Sequel library
37
• A built in Sequel library which is very useful is the inflector
library. This allows for basic string manipulations which can
make testing easier. Here are some examples and usages.
method input output
camelize/camelcase ‘test_class’ ‘TestClass’
constantize ‘test_class’ TestClass
underscore ‘TestClass’ ‘test_class’
Examples
Test Samples: Ruby
39
Automation Demo
40
Helpful links
41
http://sequel.jeremyevans.net/rdoc/
https://github.com/jeremyevans/sequel
https://github.com/jeremyevans/sequel/blob/master/doc/querying.rdoc
https://twin.github.io/ode-to-sequel/
Questions
42
Contact Information
43
• Email
– aswerlein511@gmail.com
• LinkedIn
– https://www.linkedin.com/in/aaron-swerlein-160b5269
• GitHub
– https://github.com/aswerlein511/SequelATDDDemo
Version
44
DATE
AUTHOR VERSION REASON
01/17/2017 Aaron Swerlein 1.0 Created document /draft