Testing JUnit Testing. Testing Testing can mean many different things It certainly includes running a completed program with various inputs It also includes.

Slides:



Advertisements
Similar presentations
Software Quality Assurance Inspection by Ross Simmerman Software developers follow a method of software quality assurance and try to eliminate bugs prior.
Advertisements

Informatics 43 – May 5, Restatement of goals Want to verify software’s correctness  Need to test  Need to decide on test cases  No set of test.
Well-behaved objects 4.0 Testing. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to.
Chapter Day 17. © 2007 Pearson Addison-Wesley. All rights reserved6-2 Agenda Day 17 Problem set 3 posted  10 problems from chapters 5 & 6  Due in 3.
Validating and Improving Test-Case Effectiveness Author: Yuri Chernak Presenter: Lam, Man Tat.
1 Software Testing and Quality Assurance Lecture 30 – Testing Systems.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 Miscellaneous Java … a collection of short topics that we need to get to at some point …
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
 QUALITY ASSURANCE:  QA is defined as a procedure or set of procedures intended to ensure that a product or service under development (before work is.
Chapter 11: Testing The dynamic verification of the behavior of a program on a finite set of test cases, suitable selected from the usually infinite execution.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
Test Design Techniques
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Introduction to Unit Testing Jun-Ru Chang 2012/05/03.
Software Testing. Definition To test a program is to try to make it fail.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
© 2012 IBM Corporation Rational Insight | Back to Basis Series Chao Zhang Unit Testing.
Introduction Telerik Software Academy Software Quality Assurance.
Class Library, Formatting, Wrapper Classes, and JUnit Testing
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.
© 2004 Pearson Addison-Wesley. All rights reserved November 9, 2007 Method Design & Method Overloading ComS 207: Programming I (in Java) Iowa State University,
Lecture 11 Testing and Debugging SFDV Principles of Information Systems.
Software Testing The process of operating a system or component under specified conditions, observing and recording the results, and making an evaluation.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Chapter 6 Object-Oriented Design Part 3. © 2004 Pearson Addison-Wesley. All rights reserved6-2 Outline Enumerated Types Revisited Method Design Testing.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Software Defects.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
1 Object-Oriented Design Now we can extend our discussion of the design of classes and objects Chapter 6 focuses on: software development activities determining.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
 Software Testing Software Testing  Characteristics of Testable Software Characteristics of Testable Software  A Testing Life Cycle A Testing Life.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
SOFTWARE TESTING SOFTWARE TESTING Presented By, C.Jackulin Sugirtha-10mx15 R.Jeyaramar-10mx17K.Kanagalakshmi-10mx20J.A.Linda-10mx25P.B.Vahedha-10mx53.
Informatics 43 – May 3, Restatement of goals Want to verify software’s correctness  Need to test  Need to decide on test cases  No set of test.
 Software reliability is the probability that software will work properly in a specified environment and for a given amount of time. Using the following.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
SOFTWARE TESTING AND QUALITY ASSURANCE. Software Testing.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
© 2004 Pearson Addison-Wesley. All rights reserved April 5, 2006 Method Design & Method Overloading ComS 207: Programming I (in Java) Iowa State University,
Software Testing and Quality Assurance Practical Considerations (1) 1.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
Chapter 7 Object-Oriented Design
Homework Assignments APP B Reference on Junit Testing.
Regression Testing with its types
John D. McGregor Session 9 Testing Vocabulary
Approaches to ---Testing Software
Dept of Computer Science University of Maryland College Park
Software Quality Engineering
Verification and Testing
Software engineering – 1
Software Engineering 1, CS 355 Unit Testing with JUnit
Applied Software Implementation & Testing
Verification and Validation Unit Testing
Testing and Test-Driven Development CSC 4700 Software Engineering
Welcome to Corporate Training -1
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
CSE 1020:Software Development
Presentation transcript:

Testing JUnit Testing

Testing Testing can mean many different things It certainly includes running a completed program with various inputs It also includes any evaluation performed by human or computer to assess quality Some evaluations should occur before coding even begins The earlier we find an problem, the easier and cheaper it is to fix

Testing The goal of testing is to find errors As we find and fix errors, we raise our confidence that a program will perform as intended We can never really be sure that all errors have been eliminated So when do we stop testing? –Conceptual answer: Never –Snide answer: When we run out of time –Better answer: When we are willing to risk that an undiscovered error still exists

Reviews A review is a meeting in which several people examine a design document or section of code It is a common and effective form of human-based testing Presenting a design or code to others: –makes us think more carefully about it –provides an outside perspective Reviews are sometimes called inspections or walkthroughs

Test Cases A test case is a set of input and user actions, coupled with the expected results Often test cases are organized formally into test suites which are stored and reused as needed For medium and large systems, testing must be a carefully managed process Many organizations have a separate Quality Assurance (QA) department to lead testing efforts

Defect and Regression Testing Defect testing is the execution of test cases to uncover errors The act of fixing an error may introduce new errors After fixing a set of errors we should perform regression testing – running previous test suites to ensure new errors haven't been introduced It is not possible to create test cases for all possible input and user actions Therefore we should design tests to maximize their ability to find problems

Black-Box Testing In black-box testing, test cases are developed without considering the internal logic They are based on the input and expected output Input can be organized into equivalence categories Two input values in the same equivalence category would produce similar results Therefore a good test suite will cover all equivalence categories and focus on the boundaries between categories

White-Box Testing White-box testing focuses on the internal structure of the code The goal is to ensure that every path through the code is tested Paths through the code are governed by any conditional or looping statements in a program A good testing effort will include both black-box and white-box tests

JUnit Testing Testing is critical to software quality Good test plans are difficult to specify but also difficult to document precisely Good testing must be repeatable Good testing is tedious Testing is a good candidate for automation Some methodologies such as “Extreme Programming” mandate daily builds and automated unit testing

JUnit Testing In project 1, when we developed our Java code for the QuadraticSolver class, we used the CLI class itself as the “driver” to execute test cases We manually entered our test case values and visually verified whether the response provided was correct or not This testing process was labor intensive!! The JUnit framework helps us build a “test case” class to automate testing of a “class under test”

JUnit Testing TestCaseTestSolver QuadraticSolver + assertEquals( ) + setA( ) … + getEquation( ) + getSolution( ) + testSolver( ) “Class Under Test” TestSolver “Driver Class” “junit.framework.TestCase Class” extends depends on

JUnit Testing Useful method inherited from TestCase class: assertEquals(“should be value”, cut.method( )); The assertEquals method flags discrepancies between the “should be” value and the result returned by the “class under test” method( ) assertEquals method automatically displays the difference between the “should be value” and the actual return value received

JUnit Test for QuadraticSolver import junit.framework.TestCase; public class TestSolver extends TestCase { private QuadraticSolver cut; public TestSolver() { cut = new QuadraticSolver(); // Instantiate Class Under Test } // First of six test case methods for the QuadraticSolver class public void test2RealRoots() { cut.setA(1); cut.setB(0); cut.setC(-1); assertEquals("Solving: 1x**2 + 0x -1 = 0", cut.getEquation()); assertEquals("Root 1 is 1.0\nRoot 2 is -1.0", cut.getSolution()); }

JUnit Testing Test Case Execution 1 test failed: TestSolver test2RealRoots test2ImaginaryRoots testOnly1Root testLinear testNoSolution testAnySolution Failure: expected: but was:

JUnit Testing The Java code in the TestCase class(es) precisely documents the test cases It allows them to be run automatically It allows people other than the test designer to run them It prevents oversights in identification of any discrepancies in the results