CSC 395 – Software Engineering Lecture 10: Execution-based Testing –or– We can make it better than it was. Better...faster...agiler.

Slides:



Advertisements
Similar presentations
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
Advertisements

An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
1 Software Engineering Lecture 11 Software Testing.
Objectives: Test Options JUnit Testing Framework TestRunners Test Cases and Test Suites Test Fixtures JUnit.
Approach of Unit testing with the help of JUnit Satish Mishra
Testing and Debugging CS221 – 2/13/09. Airline Program.
Testing and Debugging pt.2 Intro to Complexity CS221 – 2/18/09.
Intro to CIT 594
Intro to CIT 594
1 Software Testing and Quality Assurance Lecture 23 – JUnit Tutorial.
JUnit, Revisited 17-Apr-17.
JUnit. Why is testing good? Due to psychological factors, programmers are bad testers. A computer can test much faster than a human Philosophy: “If it.
24-Jun-15 JUnit. 2 Test suites Obviously you have to test your code to get it working in the first place You can do ad hoc testing (running whatever tests.
TDD Test-Driven Development. JUnit 4.0 To use annotations need to import org.junit.Test To use assertion need to import org.junit.Assert.* No need to.
CSC 395 – Software Engineering Lecture 9: Testing -or- How I Stopped Worrying and Learned to Love the Bug.
Introduction to a Programming Environment
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 27 Slide 1 Quality Management 1.
Ranga Rodrigo. Class is central to object oriented programming.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
© Dr. A. Williams, Fall Present Software Quality Assurance – JUnit Lab 1 JUnit A unit test framework for Java –Authors: Erich Gamma, Kent Beck Objective:
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMMING PRACTICES Unit Testing.
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.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
Sadegh Aliakbary Sharif University of Technology Spring 2012.
Unit testing Unit testing TDD with JUnit. Unit Testing Unit testing with JUnit 2 Testing concepts Unit testing Testing tools JUnit Practical use of tools.
GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng
CSC 216/001 Lecture 4. Unit Testing  Why is it called “unit” testing?  When should tests be written?  Before the code for a class is written.  After.
Test automation / JUnit Building automatically repeatable test suites.
A Novel Approach to Unit Test: The Aspect-Oriented Way Guoqing Xu and Zongyuan Yang Software Engineering Lab (SEL) East China Normal University
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Software Construction Lecture 18 Software 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.
Introduction to JUnit 3.8 SEG 3203 Winter ‘07 Prepared By Samia Niamatullah.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
JUnit Adam Heath. What is JUnit?  JUnit is a unit testing framework for the Java programming language  It allows developers to swiftly and easily test.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
JUnit Don Braffitt Updated: 10-Jun-2011.
JUnit. Introduction JUnit is an open source Java testing framework used to write and run repeatable tests JUnit is integrated with several IDEs, including.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
Extreme programming (XP) Variant of agile Takes commonsense practices to extreme levels © 2012 by Václav Rajlich1.
1 CSC 216 Lecture 3. 2 Unit Testing  The most basic kind of testing is called unit testing  Why is it called “unit” testing?  When should tests be.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved.
Unit Testing. F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have?
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Observing the Current System Benefits Can see how the system actually works in practice Can ask people to explain what they are doing – to gain a clear.
Software Design– Unit Testing SIMPLE PRIMER ON Junit Junit is a free simple library that is added to Eclipse to all automated unit tests. The first step,
CS223: Software Engineering Lecture 18: The XP. Recap Introduction to Agile Methodology Customer centric approach Issues of Agile methodology Where to.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
Unit Testing in Eclipse Presented by David Eisler 08/09/2014.
SWE 434 SOFTWARE TESTING AND VALIDATION LAB2 – INTRODUCTION TO JUNIT 1 SWE 434 Lab.
Advanced programming Practices
Lecture 5: Test-Driven Development Basics
Unit Testing.
Software Construction Lab 10 Unit Testing with JUnit
Introduction to JUnit CS 4501 / 6501 Software Testing
More JUnit CS 4501 / 6501 Software Testing
Software Engineering 1, CS 355 Unit Testing with JUnit
JUnit 28-Nov-18.
JUnit 28-Nov-18.
Introduction to JUnit CS 4501 / 6501 Software Testing
Advanced Programming Behnam Hatami Fall 2017.
More JUnit CS 4501 / 6501 Software Testing
Introduction to JUnit IT323 – Software Engineering II
Testing 24-Feb-19.
Advanced programming Practices
CS 240 – Advanced Programming Concepts
Computer Science 340 Software Design & Testing
Presentation transcript:

CSC 395 – Software Engineering Lecture 10: Execution-based Testing –or– We can make it better than it was. Better...faster...agiler

Today’s Goal Discuss execution-based testing When this testing should be performed Who should do this testing What this testing should entail Discuss Java-based testing approach

Who Should Do The Testing Original Programmer Deadline-focused Job requires writing correct code quickly Believes code correct Familiar with code Testing Team Member Quality-focused Job requires finding all faults Assumes faults exist No knowledge of code

When Should Testing Occur Turns out, agile methods not all bad Testing process begins before coding Develop unit tests before coding Check that individual classes/methods work Part of transition from design to development Helps developers understand design Focuses developers thoughts before coding Enables simple checks during coding process These tests are a first unofficial step

What Should Test Case Do? Want to limit number of test cases Each test case takes time (e.g., $$$$) Reasonably expect each test to find an error Why test something that would not find an error? Must know which error test would find What is value of test if it does not solve problems? Tests should not do too much Results of complex tests are hard to understand Keep collection of “best practice” tests

Testing Strategy Tests begin at finest possible granularity Focuses debugging on fewest lines of code Enables testing to begin as soon as possible Slowly builds up to highest level tests Unit tests look at class/method level Simple tests run regularly during coding session Integration tests examine class interactions System/validation tests looks to see entire system works & fulfills client’s requirements

Assertions in Java Test that boolean property holds Place anywhere in a method Tested * each time method executed, so can slow performance Very useful for internal, α, & β programs Assertions added or removed at runtime java –ea runs program while testing assertions Assertions ignored when –ea flag not specified Can document & test assumptions in code But not good for unit tests or finding source

Automated Unit Testing Automation important on large projects Allows continued testing as code written Prevents regression failures JUnit popular system for unit testing Written in Java and incorporated into Eclipse Performs tests on individual classes Limits code used when performing checks Testing starts immediately Tests flow from design documents

Writing JUnit Tests Define test class for each class Each test case should become method JUnit automatically runs all tests in a class Eclipse executes all test classes in a project Relies on Java annotations Adds information to individual methods Relative new to Java, but growing in popularity Especially good for large projects or when performance is crucial

Running JUnit Tests Each class method At most 1 method can have annotation For each method Run all methods These perform any necessary setup Execute method Run all methods Close files and other cleanup Finally, method

JUnit assert____ Methods Actual tests performed using these methods assertTrue(boolean test) assertFalse(boolean test) assertSame(Object expected, Object actual) assertNotSame(Object expected, Object actual) assertNull(Object object) assertNotNull(Object object) fail()

Other Important Tests Tests better fail before code is written But do not want to see these as annotation tells JUnit to skip test Tests must also check methods fail correctly Declare exception to be thrown in Test passes only when MyException thrown

For Next Lecture Discuss object-orientation approach Goals of OO-based languages Important features of OO-based software How OO goals used in software engineering Begin thinking about next stage of project Must develop analysis & design from your requirements document These are make-or-break parts of any project