Testing of the data access layer and the database itself



Similar documents
David Dye. Extract, Transform, Load

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

Basic Unix/Linux 1. Software Testing Interview Prep

Oracle Database 10g Express

Oracle Database 10g: Introduction to SQL

ICAB4136B Use structured query language to create database structures and manipulate data

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

MySQL for Beginners Ed 3

BCA. Database Management System

Instant SQL Programming

Oracle SQL. Course Summary. Duration. Objectives

How To Create A Table In Sql (Ahem)

Introduction to Microsoft Jet SQL

1 File Processing Systems

Revolutionized DB2 Test Data Management

Business Application Services Testing

SQL. Short introduction

Oracle. Brief Course Content This course can be done in modular form as per the detail below. ORA-1 Oracle Database 10g: SQL 4 Weeks 4000/-

The Relational Model. Why Study the Relational Model?

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Oracle Database: SQL and PL/SQL Fundamentals

Relational Database: Additional Operations on Relations; SQL

Geodatabase Programming with SQL

Database Query 1: SQL Basics

Oracle 10g PL/SQL Training

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Developing Microsoft SQL Server Databases 20464C; 5 Days

Oracle Database 12c: Introduction to SQL Ed 1.1

1. INTRODUCTION TO RDBMS

Developing Microsoft SQL Server Databases MOC 20464

Oracle Database: SQL and PL/SQL Fundamentals NEW

20464C: Developing Microsoft SQL Server Databases

Introduction to Databases

Oracle Database 11g SQL

DIPLOMA IN WEBDEVELOPMENT

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. ETL Testing

Oracle Database: SQL and PL/SQL Fundamentals

Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

The Structured Query Language. De facto standard used to interact with relational DB management systems Two major branches

Developing Microsoft SQL Server Databases

Course 20464: Developing Microsoft SQL Server Databases

SQL Server. 1. What is RDBMS?

BCA 421- Java. Tilak Maharashtra University. Bachelor of Computer Applications (BCA) 1. The Genesis of Java

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

There are five fields or columns, with names and types as shown above.


Oracle EXAM - 1Z Oracle Database 11g Security Essentials. Buy Full Product.

Developing Microsoft SQL Server Databases (20464) H8N64S

Oracle(PL/SQL) Training

Querying Microsoft SQL Server

SQL Server Developer Training Program. Topics Covered

QA Tools (QTP, QC/ALM), Selenium with Java, Mobile with Automation, Unix, SQL, SOAP UI

Oracle Database 11 g Performance Tuning. Recipes. Sam R. Alapati Darl Kuhn Bill Padfield. Apress*

Relational Databases and SQLite

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

IT2304: Database Systems 1 (DBS 1)

Oracle Database 10g: Program with PL/SQL

A basic create statement for a simple student table would look like the following.

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

Conventional Files versus the Database. Files versus Database. Pros and Cons of Conventional Files. Pros and Cons of Databases. Fields (continued)

DBMS / Business Intelligence, SQL Server

IT2305 Database Systems I (Compulsory)

Ch.5 Database Security. Ch.5 Database Security Review

Course 20464C: Developing Microsoft SQL Server Databases

Basic Concepts of Database Systems

MS Designing and Optimizing Database Solutions with Microsoft SQL Server 2008

HP Quality Center. Upgrade Preparation Guide

Database Replication with MySQL and PostgreSQL


Database Setup. Coding, Understanding, & Executing the SQL Database Creation Script

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours

Oracle Database: Introduction to SQL

SQL Server Training Course Content

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

Course ID#: W 35 Hrs. Course Content

Database Programming with PL/SQL: Learning Objectives

QA Tools (QTP, QC/ALM), ETL Testing, Selenium, Mobile, Unix, SQL, SOAP UI

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA

5. CHANGING STRUCTURE AND DATA

Teradata Utilities Class Outline

Oracle EXAM - 1Z Oracle Database 11g Release 2: SQL Tuning. Buy Full Product.

Oracle Database: Introduction to SQL

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

Querying Microsoft SQL Server 20461C; 5 days

Databases in Engineering / Lab-1 (MS-Access/SQL)

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. COURSE CURRICULUM COURSE TITLE: DATABASE MANAGEMENT (Code: ) Information Technology

Scheme G. Sample Test Paper-I

INTRODUCING ORACLE APPLICATION EXPRESS. Keywords: database, Oracle, web application, forms, reports

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

White Paper. Blindfolded SQL Injection

MOC 20461C: Querying Microsoft SQL Server. Course Overview

Databases What the Specification Says

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

50238: Introduction to SQL Server 2008 Administration

Transcription:

Testing of the data access layer and the database itself Vineta Arnicane and Guntis Arnicans University of Latvia TAPOST 2015, 08.10.2015 1

Prolog Vineta Arnicane, Guntis Arnicans, Girts Karnitis DigiBrowser as a tool for testers is replaced by Vineta Arnicane and Guntis Arnicans Testing of the data access layer and the database itself 2

Database application testing «A database application is a computer program whose primary purpose is entering and retrieving information from a computerized database» (Wikipedia) Tons of applications are developed How do developers perform testing? Is adequate attention granted to testing of database itself and interactions with it? 3

Typical testing approach Approach: take an application as a black box software design test cases according to formal or informal specification [prepare database initial state] run test cases verify results (software behavior) It is a black box testing! sometimes testers have no access to source code sometimes testers have no programming skills or they are not IT specialists at all 4

Database testing in Wikipedia Term «database testing» is not too popular (the Wikipedia article is created 5 December 2011) There are many interpretations what this term means (Wikipedia does not provide a clear definition at all) «It is important to test in order to obtain a database system which satisfies the ACID properties (Atomicity, Consistency, Isolation, and Durability) of a database management system» «Database testing usually consists of a layered process, including the user interface (UI) layer, the business layer, the data access layer and the database itself» 5

What is database testing? I Source: http://testsoftwarefaq.blogspot.com/2014/02/database-testing-faq.html Database testing involves some in depth knowledge of the given application and requires more defined plan of approach to test the data Key issues include: 1) Data integrity 2) Data validity 3) Data manipulation and updates Tester must be aware of the database design concepts and implementation rules 6

What is database testing? II Source: http://testsoftwarefaq.blogspot.com/2014/02/database-testing-faq.html Database testing is all about testing: joins, views, imports and exports, testing the procedures, checking locks, indexing, etc. It s not about testing the data in the database (!) Usually database testing is performed by DBA (!) 7

What is database testing? III Source: http://testsoftwarefaq.blogspot.com/2014/02/database-testing-faq.html Database testing basically includes the following: 1) Data validity testing 2) Data integrity testing 3) Performance related to data base 4) Testing of procedure, triggers and functions For doing data validity testing you should be good in SQL queries For data integrity testing you should know about referential integrity and different constraints For performance related things you should have idea about the table structure and design For testing procedures, triggers and functions you should be able to understand the same 8

Using of SQL statements in database testing Source: http://testsoftwarefaq.blogspot.com/2014/02/database-testing-faq.html The most important statement for database testing is the SELECT statement, which returns data rows from one or multiple tables that satisfy a given set of criteria You may need to use other DML (Data Manipulation Language) statements like INSERT, UPDATE and DELETE to manage your test data You may also need to use DDL (Data Definition Language) statements like CREATE TABLE, ALTER TABLE, and DROP TABLE to manage your test tables You may also need to some other commands to view table structures, column definitions, indexes, constraints and stored procedures 9

Types of database testing Structural testing Schema Database elements - tables, columns Default values for a column Data invariants for a single column Data invariants involving several columns Referential integrity rules Stored procedures/functions Triggers Views testing Constraints Database server validations Existing data quality Functional database testing Checking data integrity and consistency Login and user security Incoming data values Outgoing data values (from queries, stored functions, views...) Non-functional testing Load testing Stress testing 10

Database functional testing tasks Database initialization - put database into a known state before running tests to make sure that the tests will be executed correctly Functional testing - check that the application operates with the database correctly Data verification - check the structure and the actual content of a database 11

Necessity for white box testing Black box testing cannot reveal all defects in software White box testing allows to find specific problems and to evaluate a testing quality by exploiting various testing coverage metrics But it requires good IT skills and understanding what we can do and what we cannot, and how many resources it takes 12

Software testing coverage (ISTQB) statement coverage branch coverage condition coverage decision condition coverage multiple condition coverage decision coverage modified condition / condition coverage (MC/DC) LCSAJ coverage path coverage N-swich coverage boundary value coverage equivalence partition coverage data flow coverage Source: http://www.seguetech.com/blog/2014/06/13/howmuch-test-coverage-enough-testing-strategy 13

SQL statement itself is like a program select e.company, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c where e.city_id = c.id and e.age > 30 and e.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 14

SQL statement itself is like a program select e.company, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c where e.city_id = c.id and e.age > 30 and e.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 Is it enough to «cover» this statement only with one test case? No, of course! Wait! What is a test case? This statement maybe depend on input data or maybe do not. It also depends on a database state while its executing 15

SQL statement itself is like a program select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age > 30 and m.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 Mistakes using table identifiers (letters): It is easy use wrong letter (cities c, companies m) wrong table for record counting (c.id or m.id instead of e.id in count(e.id)) 16

SQL statement itself is like a program select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age > 30 and m.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 Wrong conditions: e.age >= 30, e.age < 30, e.age > 20, e.age > 40, e.age > 60 wrong operator and, or, not (e.g. not like) subcondition is not included into parenthesis Upper/lower letters (Microsoft, Microsoft) Whole word (Microsoftware, SuperMicrosoft) 17

SQL statement itself is like a program select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age > 30 and m.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 Additional conditions (having): avg_salary <2000 avg_salary <=2000 avg_salary >2000 avg_salary <3000 18

SQL statement itself is like a program select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age > 30 and m.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 Aggregation functions: Is it possible that count(e.id) returns 0? Maybe e.salary has different currencies in different records? 19

SQL statement itself is like a program select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age > 30 and m.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 Join problems in where clause: NULL values in fields (e.city_id, e.company_id) inner, left or right join missed records (database integrity is broken) excessive records (duplicates) cause wrong result 20

SQL statement itself is like a program select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age > 30 and m.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 SQL SELECT statement has many commands/functions/options Different DBMS use different SQL standards with «specific features» For adequate SQL statement testing we need: various database states (deciding what data we need; generating needed records, initializing database for each «test case») oracle for evaluating execution result 21

Coverage criteria for testing SQL queries Good criteria helps to create needed database states and optimize number of states Only a few groups of researchers worked on this issue Criteria are developed for the most popular cases Most of testers do not know about criteria There are no well-described cases of usage in industry Automation or tool support is weak 22

Principles of criteria (JOIN) from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id We need database states for «e.city_id = c.id» where no records in both tables no records in one table city_id has NULL and not NULL values exactly one matching many matchings (usual number, large number) no matchings combinations of previous requirements Condition coverage for e.city_id = c.id and e.company_id = m.id FF, FT, TF, TT Combinations of both mentioned groups 23

Principles of criteria (condition) e.age > 30 and m.company like «%Microsoft%» We need database states for «e.age > 30» where no matchings exactly one matching many matchings (usual number, large number) combinations of previous requirements Condition coverage for e.age > 30 and m.company like «%Microsoft%» FF, FT, TF, TT Combinations of both mentioned groups 24

Principles of criteria (other) group by company, city order by avg_salary desc having avg_salary < 2000 For each clause we can define similar coverage requirements 25

Dynamically created SQL statement «select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age >» + agevar + «and m.company like %» + companyvar + «% group by company, city order by avg_salary desc having avg_salary <» + salaryvar Symbolic execution can help us to obtain all or significant part of all possible SQL SELECT statements If input values goes from database or user, then number of variants can be infinite 26

Mutation testing select m.company, c.id, c.city, sum(e.salary)/count(e.id) as avg_salary from employees e, cities c, companies m where e.city_id = c.id and e.company_id = m.id and e.age > 30 and m.company like «%Microsoft%» group by company, city order by avg_salary desc having avg_salary < 2000 Make a mutation of the original statement, e.g. e.age >= 30 Execute all test cases If all results are the same as for the original statement, then test suite is not adequate Do these steps for all possible mutations 27

Other SQL statements Insert Delete Update Etc. SELECT is read only operation Most of other statements change database schema or data We need to verify changes in the database! 28

Conclusions Database testing problem is hard and huge resource consuming Nor researchers, nor practitioners have solutions for adequate database testing A lot of theoretical results are unknown for practitioners There are not many tools supporting at least part of database testing activities Most of tools are developed in universities and are not maintained 29

Epilogue DigiBrowser is[/was] a tool that can help relational database exploring un data inspecting more easily then other data browsers DigiBrowser does not require writing SQL queries and can by used by non-it specialists Thanks! 30