Testing Strategies Sources: Code Complete, 2nd Ed., Steve McConnell

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Software Testing. Quality is Hard to Pin Down Concise, clear definition is elusive Not easily quantifiable Many things to many people You'll know it when.
1 Integration Testing CS 4311 I. Burnstein. Practical Software Testing, Springer-Verlag, 2003.
Testing Strategies Sources: Code Complete, 2 nd Ed., Steve McConnell Software Engineering, 5 th Ed., Roger Pressman Testing Computer Software, 2 nd Ed.,
What is Unit Testing? How TDD Works? Tsvyatko Konov Telerik Corporation
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Illinois Institute of Technology
16/27/2015 3:38 AM6/27/2015 3:38 AM6/27/2015 3:38 AMTesting and Debugging Testing The process of verifying the software performs to the specifications.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Software System Integration
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
ECE 355: Software Engineering
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
TESTING.
INFO 637Lecture #81 Software Engineering Process II Integration and System Testing INFO 637 Glenn Booker.
CMSC 345 Fall 2000 Unit Testing. The testing process.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Testing in Extreme Programming
INT-Evry (Masters IT– Soft Eng)IntegrationTesting.1 (OO) Integration Testing What: Integration testing is a phase of software testing in which.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
1 Integration Testing CS 4311 I. Burnstein. Practical Software Testing, Springer-Verlag, 2003.
Testing, Testing & Testing - By M.D.ACHARYA QA doesn't make software but makes it better.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
CSC 480 Software Engineering Test Planning. Test Cases and Test Plans A test case is an explicit set of instructions designed to detect a particular class.
Integration testing Integrate two or more module.i.e. communicate between the modules. Follow a white box testing (Testing the code)
Unit Testing. F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have?
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
CSC 108H: Introduction to Computer Programming
Software Development.
Introduction to Software Quality Assurance & Testing
Software Testing Strategies for building test group
Unit Testing.
Group mambers: Maira Naseer (BCS ).
Unit Testing - solid fundamentals
Testing Verification and the Joy of Breaking Code
Software Engineering (CSI 321)
Integration Testing.
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
Software engineering – 1
Chapter 18 Software Testing Strategies
Levels Of Testing and Special Tests
Chapter 13 & 14 Software Testing Strategies and Techniques
Applied Software Implementation & Testing
Unit testing C# classes
Strategies For Software Test Documentation
History, Characteristics and Frameworks
Introduction to Software Testing
Lecture 09:Software Testing
Software System Integration
Higher-Level Testing and Integration Testing
Testing and Test-Driven Development CSC 4700 Software Engineering
Computer Science Testing.
CS240: Advanced Programming Concepts
Integration Testing CS 4311
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
UNIT 5 EMBEDDED SYSTEM DEVELOPMENT
UNIT 5 EMBEDDED SYSTEM DEVELOPMENT
CS 240 – Advanced Programming Concepts
Software Testing “If you can’t test it, you can’t design it”
Integration Reading: McConnell, Code Complete, Ch. 29
Applying Use Cases (Chapters 25,26)
Chapter 11: Integration- and System Testing
Chapter 11: Integration and System Testing
CS410 – Software Engineering Lecture #11: Testing II
Integration Testing.
Software Testing Strategies
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Presentation transcript:

Testing Strategies Sources: Code Complete, 2nd Ed., Steve McConnell Software Engineering, 5th Ed., Roger Pressman Testing Computer Software, 2nd Ed., Cem Kaner, et. Al.

Overall Testing Strategy System Engineering System Testing (Final) Requirements System Testing (Software) Design Integration Testing Construction Unit Testing System Engineering The software you're building may be only one part of a much larger system containing many hardware and software components System Engineering deals with engineering the entire system, not just the software components, and goes beyond the scope of Software Engineering

Unit Testing Tests the basic units that make-up a software system (in object-oriented programming this means testing at the class level) Performed by the programmer (not a separate testing group) How the programmer says “I did what I was supposed to do, and it works”. If it isn’t tested, it doesn’t work! Part of being a professional Saves debugging time May be manual or automated

Automated Unit Testing Code written to exercise the functionality in the unit under test Alerts the programmer to errors Easy to run at any time (before and after changes, etc.) Makes your life as a programmer easier Eliminates the fear of making changes A collection (suite) of automated unit tests becomes a regression test Usually written using a testing framework

xUnit Testing Frameworks Family of tools and framework code supporting automated unit testing for various programming languages JUnit VBUnit NUnit CPPUnit RubyUnit SUnit PyUnit Based on a design for testing by Kent Beck Most tools contain command line and GUI implementation Integrated into popular IDEs

xUnit Testing Design Write a separate test method for each test Use assertions that are expected to be true setUp() method executed before each test method (for common setup code) tearDown() method executed after each test Failures reported in various ways, depending on language and tool (command-line, GUI, IDE integrated)

JUnit Versions >= 4.0 Create a separate test class Write test methods (marked with @Test) Include assertions in test methods Mark methods with @Before and @After for test fixture (@BeforeEach and @AfterEach-–and several others in Junit 5)

Problems with Unit Testing Testing comes at the end of the development cycle when budgets and schedules get tight Programmers tend not to write enough (if any) tests Solution: Test-Driven Development Move testing to the front of the process Let tests drive the development effort

Test-Driven Development

Test-Driven Development Principles Write tests before functionality Functionality is not complete until current and any previous tests pass Only one test should be failing at any given time Let tests drive the code No functionality is written unless required by a test Start with the simplest way to make the test pass Add complexity only when required by a test User refactoring to clean up the code and eliminate duplication (in the code and the tests)

Test-Driven Development Demo

Test Doubles Support isolation of the unit under test (UUT) Dummy The simplest form of a test double. Used for simple parameter or return values. Stub May have simple logic to provide different outputs Spy Records some information for later verification (such as how many times a method was called) In Mockito, a mocking decorator for a real object Mock Normally generated by mocking frameworks to provide specific return values or throw exceptions in response to method calls. Records information that can be used at end of test to verify method call order and times called Expectation set at generation. Expectation failures result in test failure

Unit Testing: Using mocks and drivers to isolate the class under unit test Class to Test cases Results Supported by frameworks like JUnit Generated by frameworks like Mockito or EasyMock

Unit Testing: What do mocks do? Return a hard-coded answer regardless of the input Validate method call sequence (including parameter values) Validate the number of times a method was called Generate errors (e.g., throw exceptions)

Unit Testing: What do drivers do? Invokes the class with fixed inputs If an oracle is available, inputs can be generated rather than fixed Compares actual outputs with expected outputs Records failure if expected and actual outputs don’t match Normally continues to execute even if a test case fails Generates report detailing what worked and what didn’t

Integration Testing Integration involves combining the individual software units into larger functional units If the units work individually, why wouldn't they work when you put them together? Ask the 2010 Miami Heat Example: Interactions between units may be flawed Mars Orbiter disaster caused by one module assuming English units and another assuming Metric units

Integration Testing Big-Bang integration Entire system is integrated at once The system doesn't work, and you don't know why Incremental integration Add a piece, retest the system, Add a piece, retest the system, … If it breaks, you know what caused the problem (i.e., the last piece you added) Integration Testing is testing that's done during integration to ensure that the system continues to work each time a new piece is added

Top-Down Integration Testing Top module is tested with test doubles Test doubles are replaced one at a time, either breadth-first or depth-first Tests are run each time new modules are integrated

Bottom-Up Integration Testing Modules are integrated in a bottom-up fashion until the entire system has been assembled SH: Depth first here means from the bottom up (not the normal connotation of depth first, i.e. top down). Reached by a path in what would be a depth first traversal from the top. Tests are run each time new modules are integrated Drivers must be developed, but test doubles are not needed

Sandwich Integration Combination of top-down and bottom-up integration Integrate from the top and from the bottom as it makes sense, and meet somewhere in the middle

Continuous Integration Some projects wait several weeks between integrations Between integrations, engineers work on their pieces in relative isolation Each integration produces a new "build" The system may not build successfully between integrations A better approach for many projects is "continuous integration" A minimal working system is checked into source control Engineers check in new code every time they finish a meaningful unit of work Engineers must never break the build, and are responsible for adding new test cases to exercise the new code The system is built and tests are run every night to ensure that all is well The system is always integrated and build-able

System Testing Black box testing to ensure that the product meets all of the specified requirements Performed by independent testing group The testing organization should be separate from the development organization to avoid conflict of interest The testing organization creates a “test plan” that details how the product will be tested Development delivers periodic builds of the complete system Acceptance test is run on new builds to verify that they're stable enough to test If a build fails the acceptance test, it's rejected and no testing resources are expended on it If a build passes the acceptance test, tests are run and bugs are entered into the bug tracking system

System Testing Before shipping a product it's important to get feedback from real customers Alpha Testing Product not yet feature-complete (some things are missing) Give the product to trusted, enthusiastic customers for evaluation Could be done at your place or theirs Lots of hand-holding by the developers Incentives to alpha testers could include influence on product features or early access to needed features Beta Testing Product much closer to shipment than with alpha testing Product is feature-complete (debugging and tuning still in progress) Broader distribution to a less selective group of customers Less hand-holding Incentives could include cash, free software or customer support, early access to needed features

System Testing When are we done testing? "You're never done testing, the burden simply shifts from you to your customer." "You're done testing when you run out of time or you run out of money." You're done testing when: All "show stopper" bugs have been fixed The rate at which new bugs are being found falls below some acceptable threshold If your testing is thorough, the rate at which you're finding new bugs is correlated to how many bugs still remain

System Testing Can we predict when we'll be done testing in advance? An estimation and scheduling problem How about this? Record the rate at which you're finding bugs each week Once you've got several data points, fit a curve to the data that can be used to predict the date at which the bug rate will be low enough to ship This might be better than guessing

Regression Testing (I) Any change to a software product, even a slight one, has the potential to cause bugs anywhere in the system Basically, you have to assume that anything can break at any time Regression testing is done on every build to ensure that new code (including bug fixes) did not break features that used to work It's not feasible to re-run all prior tests on every build (especially manual tests) The regression test suite is a subset of tests that covers all product areas and can feasibly be run on every build The regression test suite will evolve (i.e., grow larger) over time

Regression Testing (II) In addition to having regression tests that cover all functional areas of the product, you should also have a regression test for every bug that has been fixed Whenever a bug is discovered, if you don't already have one, design a test case that can be used later to verify that the bug has been fixed After the bug is fixed, re-run the test case on each new build to ensure that the bug stays fixed Experience has shown that fixed bugs often get “unfixed” later Why? Source control mistakes (i.e., somebody unintentionally overwrites the bug fix in the code repository) The bug fix was “fragile” (i.e., it barely worked, and some later change pushes it over the edge) The feature in which the bug was found is later redesigned and re-implemented. The original mistake is repeated, thus reintroducing the bug

Customer Acceptance Testing After system testing is complete, the customer might perform a "customer acceptance test" before signing off on the product The customer acceptance test is a suite of tests that will be run by the customer (or someone they hire) to ensure that the product meets requirements