Beyond Test Automation (Why Are My Tests Dumb?)

Slides:



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

Introduction to Software Testing Chapter 9.2 Challenges in Testing Software – Software Testability Paul Ammann & Jeff Offutt
Of 23 Generating Automated Tests from Behavioral Models Jeff Offutt (Research with Dr. Nan Li, currently with MediData Solutions) Software Engineering.
Paul Ammann & Jeff Offutt
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
CMSC 345 Fall 2000 Unit Testing. The testing process.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 437 Software Testing
Of 18 Is Bytecode Instrumentation as Good as Source Instrumentation? An Empirical Study with Industrial Tools Nan Li, Xin Meng, Jeff Offutt, and Lin Deng.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
Software Testing and Quality Assurance Practical Considerations (4) 1.
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.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Introduction to Software Testing Chapter 9.2 Program-based Grammars Paul Ammann & Jeff Offutt
Introduction to Software Testing (2nd edition) Chapter 4 Putting Testing First Paul Ammann & Jeff Offutt August.
TESTING FUNDAMENTALS BY K.KARTHIKEYAN.
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.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Testability.
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Software Testing.
Regression Testing with its types
Testing Tutorial 7.
Generating Automated Tests from Behavior Models
John D. McGregor Session 9 Testing Vocabulary
Test Automation CS 4501 / 6501 Software Testing
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Designing For Testability
Input Space Partition Testing CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Coverage-Based Test Design CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
John D. McGregor Session 9 Testing Vocabulary
Syntax-based Testing CS 4501 / 6501 Software Testing
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
How the Web Brought Evolution Back Into Design
Introduction to Software Testing Chapter 2 Model-Driven Test Design
John D. McGregor Session 9 Testing Vocabulary
It is great that we automate our tests, but why are they so bad?
Introduction to Software Testing Chapter 9.2 Program-based Grammars
From Spec-based Testing to Test Automation and Beyond
Paul Ammann & Jeff Offutt
Introduction to Software Testing
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Test Automation CS 4501 / 6501 Software Testing
ISP Coverage Criteria CS 4501 / 6501 Software Testing
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
(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
A Test Automation Language for Behavioral Models
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
George Mason University
Paul Ammann & Jeff Offutt
Review for Final – Spring 2018
Testing.
Review for Final – Spring 2019
Mutation Testing Faults are introduced into the program by creating many versions of the program called mutants. Each mutant contains a single fault. Test.
Design Contracts and Errors A Software Development Strategy
Presentation transcript:

Beyond Test Automation (Why Are My Tests Dumb?) Jeff Offutt Software Engineering George Mason University Fairfax, VA USA www.cs.gmu.edu/~offutt/ offutt@gmu.edu

Outline Why do we have so many dumb things? Simple tests Automated tests Quality of test oracles Smart tests ICTSS, October 2016 Jeff Offutt

Why doesn’t my door open itself ? I Want Smart Things Why doesn’t my door open itself ? ICTSS, October 2016 Jeff Offutt

Which way do you pull to open? This Door Even Lies Which way do you pull to open? ICTSS, October 2016 Jeff Offutt

This Door Sits There Like a Dummy Shhh … it’s a secret ! ICTSS, October 2016 Jeff Offutt

Even Our Computers Are Stupid ! ICTSS, October 2016 Jeff Offutt

Baby Sitting Service We even have baby sitting services to take care of computers who are too stupid to take care of themselves ! ICTSS, October 2016 Jeff Offutt

How can we remember which control maps to which burner ? Dumb Stove Smarter design How can we remember which control maps to which burner ? ICTSS, October 2016 Jeff Offutt

This makes sense … for a paper calendar Dumb Calendar Sun Mon Tue Wed Thu Fri Sat 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 This makes sense … for a paper calendar ICTSS, October 2016 Jeff Offutt

Month divisions are arbitrary Smarter Calendar Sun Mon Tue Wed Thu Fri Sat 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Feb 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 scroll Month divisions are arbitrary ICTSS, October 2016 Jeff Offutt

Outline Why do we have so many dumb things? Simple dumb tests Automated tests Quality of test oracles Smart tests ICTSS, October 2016 Jeff Offutt

I want tests to be smart too! ICTSS, October 2016 Jeff Offutt

These are as dumb as single-cell organisms !! Old Style Tests Values invented by humans Scripts were pieces of paper with steps Simple directions to humans Slow! 1. Turn on computer 2. Type : “Run myProgram” 3. Enter name : 4. Enter age : “-25” “George P. Burdell” Error prone! Limited repeatability! Very hard to use with test criteria These are as dumb as single-cell organisms !! ICTSS, October 2016 Jeff Offutt

Limitations of Single-Cell Tests Expensive Test suites tend to grow unbounded Requires lots of human care Running tests Adding new tests Deleting out-of-date tests Evolving tests ICTSS, October 2016 Jeff Offutt

Outline Why do we have so many dumb things? Simple tests Automated tests Quality of test oracles Smart tests ICTSS, October 2016 Jeff Offutt

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 to run and repeatable … These multi-cellular tests show the first signs of intelligence! ICTSS, October 2016 Jeff Offutt

The RIPR Model Reachability Infection Propagation Revealability Test Final Program State Reachability Infection Propagation Revealability Observed Final Program State Reaches Observed Final Program State Fault Incorrect Final State Infects Incorrect Program State Propagates Reveals Test Oracles ICTSS, October 2016 Jeff Offutt

Controllability and Observability How easy it is to give a program the inputs needed Its input values, operations, environment variables, external data stores, etc. Observability How easy it is to see the program’s behavior Its outputs, effects on the environment, and other hardware and software components ICTSS, October 2016 Jeff Offutt

Test Automation—Model-Based Tests 2 Abstract Tests [ 1, 2, 3, 2, 1 ] [ 1, 3, 4, 1 ] … 1 3 4 Model level Implementation level Concrete Test ut = new underTest(); ut.m1 (14); ut.m2 (5, 7); ut.m2 (1, 3); ut.m1 (13); ut.m1 (23); public class underTest() { private int X, Y; public m1 (int a) { … }; public m2 (int s, int t) { … }; } ICTSS, October 2016 Jeff Offutt

Automate the transformation The Mapping Problem Transform abstract tests to concrete tests First abstract test: AddChoc, Coin, GetChoc, Coin, AddChoc Nine abstract tests use : 15 “AddChoc” transitions 16 “Coin” transitions 6 “getChoc” transitions Testers often convert abstract to concrete tests by hand Solution? 1 2 3 4 Coin GetChoc AddChoc 1: credit = 0 & #stock = 0 2: credit > 0 & #stock = 0 3: credit = 0 & #stock > 0 4: credit > 0 & #stock > 0 AddChoc / Coin [1, 3, 4, 1, 2, 4] Automate the transformation © Jeff Offutt

Model-Based Test Components Each abstract test component must be mapped to real code in concrete tests Test 3 C4 C4 C4 many times C5 C5 C5 C6 C6 C7 C7 Joint with Nan Li, Test Automation Language Framework for Behavioral Models, AMOST 2015 © Jeff Offutt

Automating Model-Based Test Designs Implementation Model Test Criterion Test Requirements Test Components Test values Test oracles Other values Abstract Tests Concrete Tests ICTSS, October 2016 Jeff Offutt

Automating Model-Based Test Designs Coin Abstract Tests 1. [ 1, 3, 4, 1, 2, 4 ] 2. [ 1, 2, 4, 1, 2, 4 ] 3. [ 1, 2, 4, 3, 4 ] 4. [ 1, 2, 4, 1, 3, 4 ] 5. [ 1, 3, 4, 1, 3, 4 ] 1 2 Coin GetChoc AddChoc AddChoc @Test public class test1() { vm.addChoc (“MM”); vm.coin (100); vm.getChoc (choc); vm.coin (10); assertEquals (1, vm.getStock().size()); } 3 4 Coin GetChoc AddChoc Coin / AddChoc ICTSS, October 2016 Jeff Offutt

Empirical Evaluation Compared assembly with hand process Subjects 9 testers 17 programs (each tester created tests for one program) Assembly Process Find test code for each element from model Enter mappings into test automation tool Create concrete (automated) tests; correct errors Hand Process Find test code for each element from model Write automated tests Correct errors ICTSS, October 2016 Jeff Offutt

Empirical Results Statistic Size Task Automatic (seconds) Manual FSM Nodes 742 FSM Edges 33,983 LOC 232 Num Test Components 196 2325 Num Tests 240 Task Automatic (seconds) Manual Mapping Creation 8364 N/A Test Generation 344 39,670 Total 8708 Errors 48 75% time savings (4-1 speedup) ICTSS, October 2016 Jeff Offutt

Outline Why do we have so many dumb things? Simple tests Automated tests Quality of test oracles Smart tests ICTSS, October 2016 Jeff Offutt

An automated test must include the expected (correct) result Test Oracles An automated test must include the expected (correct) result ICTSS, October 2016 Jeff Offutt

Initial Test Oracle Observations Testers wrote pretty bad test oracles Type of tester % of propagated failures that were revealed Undergraduate students 79% Full-time graduate students 74% Full-time software engineers 63% Full-time testers 61% ICTSS, October 2016 Jeff Offutt

Test Oracle Strategies Verifies if a test passes For example, JUnit assertions Test Oracle Strategy (OS) Specifies what parts of the program state the oracle should check Weak, or less precise, oracles might miss some failures A more precise OS effectively increases observability ICTSS, October 2016 Jeff Offutt

Output Elements for Test Oracles to Check 1. State invariants Check the state invariants as defined in the model 2. Object Members Member variables of objects if a method was called in a transition 3. Return values After a method is invoked 4. Parameter members Member variables of objects that were passed to a method call as parameters ICTSS, October 2016 Jeff Offutt

Test Oracle Strategies Checks object members, parameter members, & return values OS5 Checks parameter members & return values OS4 OS3 Checks object members & return values OS2 OS1 Checks return values Checks object members SIOS Checks state invariants in FSM NOS Just checks for exceptions ICTSS, October 2016 Jeff Offutt

Test Oracle Strategies Evaluation Subjects 16 programs with FSMs 52 .. 14,155 LOC 24 .. 273 transitions 250 tests to satisfy edge coverage on the FSMs 9627 faults generated as mutants (muJava) Equivalent mutants removed by hand Each test set run against all faulty versions of its program ICTSS, October 2016 Jeff Offutt

Percent Faults Detected by Strategies Reached, infected, propagated, and revealed OS % Faults detected Assertions created (cost) OS5 61% 3,455 OS4 58% 472 OS3 3,375 OS2 402 OS1 60% 3,298 SIOS 54% 114 NOS 34% % of propagated that were also revealed 100% 95% 98% 89% 56% Nan Li & Jeff Offutt, Empirical Analysis of Test Oracle Strategies for Model-based Testing, ICST 2014 Nan LI & Jeff Offutt, Test Oracle Strategies for Model-based Testing, TSE 2017 ICTSS, October 2016 Jeff Offutt

Percent Faults Detected by Strategies Reached, infected, propagated, and revealed Tests found 61% of the faults OS % Faults detected Assertions created (cost) OS5 61% 3,455 OS4 58% 472 OS3 3,375 OS2 402 OS1 60% 3,298 SIOS 54% 114 NOS 34% % revealed 100% 95% 98% 89% 56% Slightly more expensive, only misses 5% of failures Inexpensive, only misses 11% of failures Free, but doesn’t see 44% of failures! ICTSS, October 2016 Jeff Offutt

Outline Why do we have so many dumb things? Simple tests Automated tests Quality of test oracles Smart tests ICTSS, October 2016 Jeff Offutt

Composing tests from parts has advantages Multicellular Tests Composing tests from parts has advantages Test Values Expected results Before values After values Parts can be recombined to form new tests Tests can be changed Automation is much easier ICTSS, October 2016 Jeff Offutt

Multicellular Tests are Still Dumb But multicellular tests do not know … Test Values Expected results Before values After values Why do they exist? When should they run? When do they need to evolve? When should they die? ICTSS, October 2016 Jeff Offutt

Intelligent tests need self-awareness and self-determination! ICTSS, October 2016 Jeff Offutt

Self-Aware Tests Documents why the test exists and when to run. But for the tester. The test needs to know this. public class calcTest { // Test 14 // Test path 8: [1, 2, 4, 5, 4, 5, 6, 8] // Edges covered: (1,2), (2,4), (4,5), (5,4), (5,6), (6,8) @Test public void testAdd1 () . . . } ICTSS, October 2016 Jeff Offutt

Self-Deterministic Tests public class calcTest { // Test 28 // Requirement: Divide by zero returns undefined @Test public void testDivide3 () . . . } If the requirement changes, the test can be removed. How can the test recognize the change and delete itself? ICTSS, October 2016 Jeff Offutt

What Do We Need for Multicellular Tests to Evolve Intelligence? Every test must encode its purpose Meaning Why is it there? What is it trying to check? Test Values Expected results Before values After values What test requirement? Functional requirement Criterion (eg, graph edge) Purpose We need a language to describe why a test exists ICTSS, October 2016 Jeff Offutt

What Do We Need for Multicellular Tests to Evolve Intelligence? Tests must exist in a habitat and a society Habitat Test Values Expected results Before values After values Meaning Purpose Habitat An execution framework that allows tests to run themselves Society Ability to query the environment and other tests about status and changes Society ICTSS, October 2016 Jeff Offutt

Getting Intelligent Tests Self aware Habitat Test Values Expected results Before values After values Meaning Purpose Self determination Society ICTSS, October 2016 Jeff Offutt

What Can an Intelligent Test Do? Proactively run on its own Proactively alert engineer when a test fails When software changes ... Decide whether test should run, change, die, or do nothing When the test changes ... Take initiative, but ask for help when necessary ( e.g., values, expected results ) ICTSS, October 2016 Jeff Offutt

Tests should think so testers don’t have to Summary “Intelligent” tests can save enormous amounts of time for software engineers Pre-requisites to developing intelligent tests Test automation Traceability from software artifacts to test ( criteria ) Technical needs Language for describing purpose ( effectiveness & usability ) Rule set for tests to choose actions Execution environment for tests to run in Ability to query the source library Framework for test development Tests should think so testers don’t have to ICTSS, October 2016 Jeff Offutt

We need significant research in test automation Contact Jeff Offutt offutt@gmu.edu http://cs.gmu.edu/~offutt/ George Mason University We need significant research in test automation SBES 2013 © Jeff Offutt