From Spec-based Testing to Test Automation and Beyond

Slides:



Advertisements
Similar presentations
Introduction to Software Testing Chapter 1 Model-Driven Test Design Paul Ammann & Jeff Offutt
Advertisements

Introduction to Software Testing Chapter 2.6 Graph Coverage for Use Cases Paul Ammann & Jeff Offutt
COVERAGE CRITERIA FOR TESTING 1. ill-defined terms in Testing  complete testing  exhaustive testing  full coverage Are poorly defined terms because.
Of 23 Generating Automated Tests from Behavioral Models Jeff Offutt (Research with Dr. Nan Li, currently with MediData Solutions) Software Engineering.
Introduction to Software Testing Chapter 2.6 Graph Coverage for Use Cases Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Terms: Test (Case) vs. Test Suite
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
Verification and Validation Overview References: Shach, Object Oriented and Classical Software Engineering Pressman, Software Engineering: a Practitioner’s.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
First delivery of the course Software Quality and Testing Katerina Zdravkova, Anastas Mišev
Introduction to Software Testing Paul Ammann & Jeff Offutt Updated 24-August 2010.
Introduction to Software Testing. OUTLINE Introduction to Software Testing (Ch 1) 2 1.Spectacular Software Failures 2.Why Test? 3.What Do We Do When We.
1 Graph Coverage (6). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
Introduction to Software Testing (2nd edition) Chapter 4 Putting Testing First Paul Ammann & Jeff Offutt August.
Why Are My Tests Dumb? Jeff Offutt George Mason University.
Introduction to Software Testing Model-Driven Test Design and Coverage testing Paul Ammann & Jeff Offutt Update.
Software Testing and Quality Assurance Practical Considerations (1) 1.
Cs498dm Software Testing Darko Marinov January 24, 2012.
Software Development. The Software Life Cycle Encompasses all activities from initial analysis until obsolescence Analysis of problem or request Analysis.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Software Development.
Requirements Specification
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Regression Testing with its types
Software Engineering (CSI 321)
Paul Ammann & Jeff Offutt
Generating Automated Tests from Behavior Models
Test Automation CS 4501 / 6501 Software Testing
Testing All Input is Evil pt 2.
Paul Ammann & Jeff Offutt
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Input Space Partition Testing CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Software Testing.
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Coverage-Based Test Design CS 4501 / 6501 Software Testing
Jeff Offutt SWE 637 Software Testing
Faults, Errors, Failures CS 4501 / 6501 Software Testing
Beyond Test Automation (Why Are My Tests Dumb?)
Paul Ammann & Jeff Offutt
Logic Coverage CS 4501 / 6501 Software Testing
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Introduction to Software Testing Chapter 2 Model-Driven Test Design
It is great that we automate our tests, but why are they so bad?
Introduction to Software Testing
Paul Ammann & Jeff Offutt
Testing and Test-Driven Development CSC 4700 Software Engineering
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
Software Testing and Maintenance Maintenance and Evolution Overview
Test Automation CS 4501 / 6501 Software Testing
Logic Coverage CS 4501 / 6501 Software Testing
ISP Coverage Criteria CS 4501 / 6501 Software Testing
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
(some of) My Research Engineering is about getting technology to do what it does well so humans can do what they do well Jeff Offutt Professor of Software.
Jeff Offutt SWE 637 Software Testing
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Software Development Cycle
Test Cases, Test Suites and Test Case management systems
Paul Ammann & Jeff Offutt
Review for Final – Spring 2018
Review for Final – Spring 2019
Chapter 10: Testing and Quality Assurance
Presentation transcript:

From Spec-based Testing to Test Automation and Beyond Jeff Offutt George Mason University Skövde University TOCSYC Project https://www.cs.gmu.edu/~offutt

Early history of MBT (my perspective) The oldest related paper I have found: An approach to program testing, J C Huang. ACM Computing Surveys, 7(3):113-128, 1975 Graph-based testing Used flowcharts—an old function-level modeling technique Suggested edge coverage An early specification-based paper I co-authored: Using formal methods to derive test frames in category-partition testing, Ammann and Offutt. Computer Assurance Conference, 1994 Formal modeling language: Z Criteria: Combinatorial testing, each choice, base choice 161 citations (Google scholar) © Jeff Offutt AMOST 2018

Early history of MBT (my perspective) I fell in love with formal specs for awhile Criteria for generating specification-based tests, J Offutt, Y Xiong, and S Liu. Fifth IEEE International Conference on Engineering of Complex Computer Systems, 1999 Model: Finite state machines Criteria: edge coverage, predicate testing, edge-pair 200 citations I had a 3-year research grant from Rockwell-Collins to develop specification-based testing criteria Surprisingly, I learned something very important … © Jeff Offutt AMOST 2018

Early history of MBT (my perspective) Management thought software engineers were using formal specifications to model aerospace software BUT … The engineers hated formal specifications !!!! They were perceived as not cost-effective Engineers did not believe formal specs helped create better software They thought formal specs were too hard Engineers were not mathematicians © Jeff Offutt AMOST 2018

Early history of MBT (my perspective) But engineers used informal models such as UML diagrams My student and I realized informal models were almost as useful for generating tests as formal models Generating tests from UML specifications, Offutt and Abdurazik. International Conference on the Unified Modeling Language (now MBT), 1999 Model: Finite state machines Criteria: edge coverage, predicate testing, edge-pair Citations: 566 Using UML collaboration diagrams for static checking and test generation, Abdurazik and Offutt. International Conference on the Unified Modeling Language, 2000 313 citations © Jeff Offutt AMOST 2018

Should models be formal? In the early 1990s, models tended to be formal Mathematically-based Formal semantics Rigorous syntax that could be checked Inventors created models that did not have formal semantics as a tradeoff between checkable syntax and the potential for widespread use This started a war based on an imagined competition between formal specifications and informal models!! A war that continues to punish us all … especially young scientists © Jeff Offutt AMOST 2018

MBT to model-driven test design When developing our book, Ammann and I tried to integrate the hundreds of test criteria One idea was to generalize, or abstract, mathematical structures from software artifacts Artifact-based graphs to abstract graphs code designs requirements formal models CFGs statecharts Abstract graph use cases FSMs, PNs 1 3 2 4 © Jeff Offutt AMOST 2018

MBT to model-driven test design Artifact-based logical expressions to abstract logical predicates code designs requirements formal models decisions statecharts decisions use case decisions FSMs, PNs, SMV Abstract Predicate (A & B ) | (C & D) © Jeff Offutt AMOST 2018

Abstraction-based test design test requirements model / structure DESIGN ABSTRACTION LEVEL software artifact IMPLEMENTATION ABSTRACTION LEVEL input values pass / fail test results test scripts test cases © Jeff Offutt AMOST 2018

Abstraction-based test design Note we did not call it “model-based testing” Even though “abstract graphs” are clearly models But they can be derived from formal specs or informal models Please: Let’s stop criticizing each other for being too formal or not formal enough © Jeff Offutt AMOST 2018

What’s next I have recently become interested in test automation in the context of model-based testing © Jeff Offutt AMOST 2018

Test automation in general Test case management Source of tests Commonly automated in practice Test requirements generation Test value generation Test execution © Jeff Offutt AMOST 2018

Test automation in general Automate additional test generation steps Test case management Source of tests Models, formal or informal, I don’t care … … allows this to be automated Test requirements generation Test value generation Test execution © Jeff Offutt AMOST 2018

A typical MBT process Test criterion Test requirements (subpaths) Abstract tests (test paths) Concrete tests Test oracles Model Criterion Test Requirements Abstract Tests Concrete Tests Extra Info Test Execution Test Reports © Jeff Offutt AMOST 2018

Using MBT to improve test oracles Revealability : Making sure our test oracles look in the right place to see the failures © Jeff Offutt AMOST 2018

Observed Final Program State RIPR model Reachability Infection Propagation Revealability Test Final Program State Observed Final Program State Reaches Fault Incorrect Final State Infects Error Program State Propagates Reveals Test Oracles © Jeff Offutt AMOST 2018

Observed Final Program State RIPR Model Reachability Infection Propagation Revealability Test Final Program State Reaches Observed Final Program State Fault Incorrect Final State Infects Error Program State Propagates Reveals Test Oracles © Jeff Offutt AMOST 2018

Test oracle problem An automated test must check whether the behavior was correct (assertions in Junit) Q1: How much of the program state should be checked ? (that is, which variables ? ) More checking adds more cost Q2: How often should state be checked ? Once at end of test ? After every transition ? © Jeff Offutt AMOST 2018

Testers often write bad oracles Tests that caused failure Tests that revealed % tests that revealed tests that caused failure, did not reveal % did not reveal UG 30 26 86.67 4 13.33 FG 25 19 76.00 6 24.00 PG 21 12 57.14 9 42.86 FT 17 8 47.06 52.94 Total 93 65 69.89 28 30.11 Almost a third of the failures were not noticed Almost half the tests written by professional software engineers had broken test oracles © Jeff Offutt AMOST 2018

MBT-based test oracles What does a good test oracle evaluate? Can model-based testing help us write better test oracles? © Jeff Offutt AMOST 2018

MBT-based test oracle strategies Null OS (does the program crash) State Invariant OS SI + member objects SI + returns SI + member objects + returns SI + params SI + member objects + returns + params © Jeff Offutt AMOST 2018

Test Oracle Strategies f requency After each transition Once at end of test Requires analysis by tester precision NOS null (crash) SIOS state invariant (SI) OS1 SI member objects OS2 SI returns OS3 SI objects returns OS5 SI params OS6 SI objects returns params Can be created from mappings Free © Jeff Offutt AMOST 2018

Precision—% Faults Revealed 28,881,000 tests executed (12 OSes * 250 tests * 9627 faults) More precise OSes are not always more effective © Jeff Offutt AMOST 2018

Frequency—% Faults Revealed Checking after each transition vs. checking at the end of the test Multiple checks is not significantly more effective © Jeff Offutt AMOST 2018

Test oracle strategy findings Crash testing (NOS) wastes much of testing effort Penny wise, pound foolish The most cost-effective choice is to check the state invariants once at the end of the tests (SIOS) Only one check needed Can be partially derived automatically from the model Joint work with Dr. Nan Li © Jeff Offutt AMOST 2018

Using MBT to make tests smarter Self-determination : Tests should be more self contained © Jeff Offutt AMOST 2018

These tests are as dumb as single-cell organisms !! Old Style Tests Values invented by humans Scripts were pieces of paper with steps Turn on computer Type : “Run myProgram” Enter name : “George P. Burdell” Enter age : “-25” Simple directions to humans Slow! Error prone! Limited repeatability! These tests are as dumb as single-cell organisms !! Almost impossible to integrate criteria © Jeff Offutt AMOST 2018

Single-cell tests are incompatible with Limitations Single-cell tests are incompatible with model-based testing © Jeff Offutt AMOST 2018

These multi-cellular tests show the first signs of intelligence! Modern Dumb Tests Test values Created by a mix of humans and test data generators Satisfy well-documented goals, test criteria, or specialized domain needs Integrated into automated test scripts (eg, JUnit) Includes a small amount of brain power … these tests know what results to expect (eg, JUnit assertions) Fast … repeatable … These multi-cellular tests show the first signs of intelligence! © Jeff Offutt AMOST 2018

But this test does not know … Multicellular Tests But this test does not know … Test Values Expected results Before values After values Why is it there? When should it run? When should it change? When should it die? © Jeff Offutt AMOST 2018

Intelligent tests need self-awareness and self-determination! © Jeff Offutt AMOST 2018

Intelligent Tests Intelligent tests need self-awareness and self-determination! Each test should encode traceability … what it covers Tests should check what has changed, and rerun if necessary Tests should alert tester when they no longer match the software Tests should quietly go away when no longer needed © Jeff Offutt AMOST 2018

MBT and TDD Test-driven development is used more often every year. How can MBT work in a TDD process? © Jeff Offutt AMOST 2018

TDD summary Rule 1: Only write code to fix a “failing” test Rule 2: Get one test to run before going to the next test Traditional development cycle Design Code Test Test-driven development cycle Test Code Refactor TDD allows decisions to be made when they are needed and the engineer is ready © Jeff Offutt AMOST 2018

How does TDD impact MBT? When do we create a model? Before starting TDD tests? After software is finished? During refactoring steps? Agile processes prefer executable artifacts Should we focus on executable models? Can we use models to track changes and regression testing issues? © Jeff Offutt AMOST 2018

Summary We should not fight over how formal models should be Both formal and informal models have benefits This split is artificial, painful, and wastes energy Model-based testing can help extend test automation Test oracles are important but often low quality Model-based testing can help Automated tests can, and should be, smarter We don’t know how MBT and TDD can play together Jeff Offutt https://www.cs.gmu.edu/~offutt © Jeff Offutt AMOST 2018