Unit testing (OHJ-306x)

Size: px
Start display at page:

Download "Unit testing (OHJ-306x)"

Transcription

1 Unit testing (OHJ-306x) Tools, techniques, tips and tricks Mika Maunumaa Researcher Tampere University of Technology

2 Introduction What is unit testing? Quick and short intro Terminology review The assignment (Firefox 3.6 alpha 1) Test target Usage scenario Setting up the test environment Tools for unit testing Reading and comprehending the code Things about C-language

3 Unit testing in big picture Testing levels Acceptance testing Carefully selected tests verifying that the system works as customer requires In real environment System testing Tests verifying that the system works are specified In laboratory or real environment Integration testing Depending on abstraction level Tests interaction between modules Tests interaction between subsystems In simulated or laboratory environment Unit testing Testing external behavior of a unit or small cluster of units

4 Unit testing Testing for individual building blocks of a system A unit can be a module, a class or a function Logically bound set Unit Under Test (UUT) MUT, CUT, FUT etc. In object-oriented testing the definition of unit can be a bit vague When object cluster is big enough to be a unit When the cluster becomes too large Integration testing A unit depends on other units Those that uses and drives drivers Imitates the real usage of the UUT Those that are used by UUT stubs Imitates the functionality of the real code Test Suite Group of tests Group of test suites Tests for same part of a unit Tests using same technique Test Case Test sequence with purpose A set of test data, test sequence and expected result Test Case has three stages: Setup and initialization Test sequence Cleanup and reset

5 Unit Test Case execution phases 1a) Test setup Constructs the test setting Prepares stubs for particular test case Correct or incorrect answer Hard to find error situation Disk Full, Memory Full, etc. 1b) Test initialization Prepares UUT Correct initial state Connects UUT to stubs, if necessary Reserves resources DB connection, TCP/IP connection, dynamic memory etc. 2 ) Test sequence exercises the UUT Driver executes usage scenario, verifies the result and prepares the verdict If top-down approach is used, the indirect driver can be used Actual driver exercises indirect driver (some system class) that exercises the actual unit under test 3a) Test cleanup free reserved resources 3b) Test reset unwinds the test setting Depending on test environment and framework you are using, each phase may or may not overlap with next phase

6 Making unit test cases Problem: where to acquire knowledge about UUT Specification for external behavior Black-box testing Mozilla provides no documentation, make assumption about the behavior Reading the code White-box testing Requires code reading and comprehending skills No documenting comments in code code is a document Social engineering Common coding rules and how coders normally avoids to using them Testing techniques Boundary values, NULL-pointers, domain violations Test data tools to extract (good) test data

7 Making unit test cases In general, when you don t have interface specification or the specification is rubbish, you as a tester have to: Use your domain knowledge and practical experience to make educated guess about the interface specification Look for the code for hints that might give you the clue how it should work Count on coverage metric tools and create tests that cover 100% of the code Write tests that verifies if the code works as it is coded (???) Each method should have at least one TestSuite of their own Basic functionality tests for all methods can be in the same TestSuite Each test case should be as small as possible, but not smaller Each test sequence should test one thing and one thing only If there are two or more sequences places in one test case, the failure in one will break the sequence perfect and/or importance test sequence are ignored

8 Making unit test cases The only successful test is the one that finds bugs No bugs found no bugs in the system poor testing A bug is a social creature, if there is one, there can be more Testing more you can only rise your confidence about systems quality However, test which verifies if the unit is behaving as it should are important Enough test cases? Test until you drop Deadline McCabe s cyclomatic complexity metric estimate for lower boundary of the number of test cases Multiconditional coverage -> boolean statements every truth value combination will be tested If (a>1 && b<5) { (a=1,b=5), (a=2, b=5), (a=1, b=4), (a=2,b=4)} Short circuit mechanism

9 Making unit test cases Multiconditional coverage requirement 100 % required, but less can be reached It is only a mean to measure ENOUGH, not the end If you are pursuing only for maximum MC coverage you will forget to test Test contains ALWAYS four parts 1. Prepare (initialize UUT and other data) 2. Execute (prepare method parameters and execute method/function) 3. Examine return values and compare them to expected values 4. Clean up How do you call sequence that does only 1, 2, and 4? A function call Is not a TEST

10 Control flow graph of ParseURL [speclen < 0] speclen < 0 speclen = strlen(spec) IF 3 rivillä 126 [stop!= 0] [colon!= 0] [colon > stop] [stop == 0] [colon == 0] [colon <= stop] IF 4 [return NS_OK] r [speclen!= 0] FOR 2 FOR 1 [len!= 0] [*p > '\0'] [*p <= ' '] [*p <= ' '] [p!= spec] IF 3 [*p!= '\0'] [true *p!= '\0'] [colon == 0] [true colon == 0] [slash == 0]] [*p == ':'] [*p == ':'] [*p == '/'] [*p == '?'] [*p == '#'] [colon!= 0] [slash!= 0] then haara r [!net_isvalidscheme] [net_isvalidscheme] [colon < slash] [slash!= 0] [*(colon+1) == ':'] [*(colon+1)!= ':'] [*p > ' '] [colon == 0] [colon!= 0] [colon >= slash] [slash == 0] [p == spec] else haara r [authoritylen == 0] [pathlen == 0] [authoritylen!= 0] [pathlen!= 0] [*p == ';'] NS_ERROR_MALFORMED_URI [authoritylen!= 0] [*p == '@'] [*p == '['] [stop!= 0] [authoritylen == 0] [pathlen!= 0] [pathlen == 0]

11 Unit test assignment Test testing target is Firefox browser s URL-parser Firefox version 3.6 alpha 1 Parser is line and character based Parses line from left to right UUT is class called nsstdurlparser In file nsurlparsers.cpp (.h) Methods that must be tested (McCabe) ParseURL (32) ParseAfterScheme ( 7) ParseFilePath (12) ParseFileName (6)

12 Unit Test Configuration package UUT [ Test Environment ] nsurlparsers nsiurlparser nsiurlparser nsbaseurlparser +ParseURL() +ParseServerInfo() +ParsePath() #ParseAfterScheme()... +net_isvalidscheme( s : char"*", l : int ) nscautostring nsnoauthurlparser nsauthurlparser +ParseAuthority() +ParseUserInfo()... -str : char"*" -len : int <<constructor>>+nscautostring( s : char"*", l : int ) +ToInteger( err : PRInt32"*" ) : PRInt32 UUT nsstdurlparser +ParseAfterScheme() Stub interfaces

13 UUT usage scenario spec = speclen = strlen(spec) NS_IMETHOD ParseURL(const char *spec, PRInt32 speclen, PRUint32 *schemepos, PRInt32 *schemelen, PRUint32 *authoritypos, PRInt32 *authoritylen, PRUint32 *pathpos, PRInt32 *pathlen); http :// /~testaus spec2 = (spec + authoritypos + 1) // speclen = authlen + pathlen - 1 void ParseAfterScheme(const char *spec2, PRInt32 speclen, PRUint32 *authpos, PRInt32 *authlen, PRUint32 *pathpos, PRInt32 *pathlen) // /~testaus serverinfo = (spec + authoritypos) // serverinfolen = authoritylen NS_IMETHOD ParseServerInfo(const char *serverinfo, PRInt32 serverinfolen, PRUint32 *hostnamepos, PRInt32 *hostnamelen, PRInt32 *port) // :8080 port == 8080 path = (spec + pathpos) pathlen2 = pathlen /~testaus NS_IMETHOD ParsePath(const char *path, PRInt32 pathlen2, PRUint32 *filepathpos, PRInt32 *filepathlen, PRUint32 *parampos, PRInt32 *paramlen, PRUint32 *querypos, PRInt32 *querylen, PRUint32 *refpos, PRInt32 *reflen) /~testaus Rest output paramaters are 0 and -1 (*Pos and *Len)

14 Tools Setting up the unit test environment for assigment Copy assignment files to your working directory mkdir ~/testaus cd ~/testaus /share/tmp/testaus/scripts/setup_unittest cd unittest CTC Coverage measurement tool from Testwell Instruments the source code with measuring code Executed before compilation gcc file.cpp ctc i m gcc file.cpp (instrument with multiconditional cov.) Collects data to mon.dat file Cumulatively, so delete this file before your final test and delivery Requires some environment variables For every login you must execute. /share/testwell/bin/testwell_environment Reading results ctcpost MON.dat less ctc2html for html output Consult their man pages

15 CppUnit - unit test framework Unit test declaration Unit test implementation #include <cppunit/extensions/helpermacros.h> class TestCAutoString : publiccppunit::testfixture { CPPUNIT_TEST_SUITE( TestCAutoString ); CPPUNIT_TEST( testnormalstring ); CPPUNIT_TEST_SUITE_END(); public: void setup(); void teardown(); void testnormalstring(); void testnullstring(); }; #include "testcautostring.h" #include "nsiurlparser.h" CPPUNIT_TEST_SUITE_REGISTRATION( TestCAutoString ); void TestCAutoString::setUp() { // before each test function } void TestCAutoString::tearDown() { // after each test function } void TestCAutoString::testNormalString() { // test steps here }

16 Make and Makefile (MTP 15.5) Build management Compilation rules Compilation targets Assignment contains a Makefile and there is only one line that must be modified... # Do not modify anything else but the list of object # files required by the "unittest" target: #!!! ADD HERE CPPUNIT TESTCASES unittest: unit.o stubs.o testrunner.o testsomething.o $(CTCCC) -o $@ $^ $(LINKFLAGS) stubtest: stubs.o testrunner.o testcautostring.o testutilityfunctions.o unit.o... You should not need to modify anything else

17 Things that they did not taught in school C-string A pointer to memory location Always ends with null character \0 Vector of 8 bit integer values Common translation to ASCII characters Pointer shows the head p == 0x100 The length of the string p is 5 strlen(p) = 5 length of char vector itself is 6 How to access data *p == 72 == H *(p+5) == 0 p[3] == 108 == l C-String cannot be copied as an object char * s=p copies only value 0x100, not the string itself char *s = strdup(p) // free s after use std::string ss(p) Common security risks Do not use C-String functions that does rely on the presence of trailing null character Use strnxxx-functions that takes the maximum number of characters as a parameter p Hello\0 0x100 0x101 0x102 0x103 0x104 0x H e l l o \0

18 Odd things while implementing stubs Do not return stack variable int * func() { int bar = 5; return &bar; } Do not store stack variable to class member Do not store vector pointer parameter to class member Content may have been deleted void someclass::func(const char * p, int length) { strclassmember = p; strclassmember = strndup( p, length ); } Do not rely on atoi-function atoi( Hello World ) == 0 Sometimes it is enough to implement simple stub Test data can order UUT to always call the stub with certain data Implement stub that statically returns what is wanted and error otherwise c-string functions often introduces security risks strdup vs. strndup char * strndup( psrc, copylength )

19 Thank you Questions!

Master Test Plan. for Software Testing Course OHJ-3060/3066, periods I-II year Tampere University of Technolgy Version 3.1.

Master Test Plan. for Software Testing Course OHJ-3060/3066, periods I-II year Tampere University of Technolgy Version 3.1. Master Test Plan for Software Testing Course OHJ-3060/3066, periods I-II year 2008-2009 Tampere University of Technolgy Version 3.1.1 Antti Kervinen ask@cs.tut.fi 18th August 2008 Version 3.1 3.1.1 3.0

More information

Master Test Plan. for Software Testing Course OHJ-3060/3066, periods I-II academic year Tampere University of Technolgy Version 4.0.

Master Test Plan. for Software Testing Course OHJ-3060/3066, periods I-II academic year Tampere University of Technolgy Version 4.0. Master Test Plan for Software Testing Course OHJ-3060/3066, periods I-II academic year 2009-2010 Tampere University of Technolgy Version 4.0.1 Mika Maunumaa mika.maunumaa@tut.fi, Antti Kervinen (original

More information

Unit Testing with JUnit and CppUnit

Unit Testing with JUnit and CppUnit Unit Testing with JUnit and CppUnit Software Testing Fundamentals (1) What is software testing? The process of operating a system or component under specified conditions, observing or recording the results,

More information

Verification and Validation. Assuring that a software system meets a user s needs. Verification vs Validation. The V & V Process

Verification and Validation. Assuring that a software system meets a user s needs. Verification vs Validation. The V & V Process Verification and Validation Assuring that a software system meets a user s needs Ian Sommerville 1995/2000 (Modified by Spiros Mancoridis 1999) Software Engineering, 6th edition. Chapters 19,20 Slide 1

More information

Software Testing Fundamentals. Software Testing Techniques. Information Flow in Testing. Testing Objectives

Software Testing Fundamentals. Software Testing Techniques. Information Flow in Testing. Testing Objectives Software Testing Fundamentals Software Testing Techniques Peter Lo Software Testing is a critical element of software quality assurance and represents the ultimate review of specification, design and coding.

More information

Examining the Code. [Reading assignment: Chapter 6, pp ]

Examining the Code. [Reading assignment: Chapter 6, pp ] Examining the Code [Reading assignment: Chapter 6, pp. 91-104] Static white-box testing Static white-box testing is the process of carefully and methodically reviewing the software design, architecture,

More information

Testing. CMSC 433 Programming Language Technologies and Paradigms Spring A Real Testing Example. Example (Black Box)?

Testing. CMSC 433 Programming Language Technologies and Paradigms Spring A Real Testing Example. Example (Black Box)? Testing CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Testing Feb. 15, 2007 Some slides adapted from FSE 98 Tutorial by Michal Young and Mauro Pezze Execute program on sample input

More information

Verification and Validation

Verification and Validation Chapter 5 Verification and Validation Chapter Revision History Revision 0 Revision 1 Revision 2 Revision 3 Revision 4 original 94/03/23 by Fred Popowich modified 94/11/09 by Fred Popowich reorganization

More information

KU Compilerbau - Programming Assignment

KU Compilerbau - Programming Assignment 716.077 KU Compilerbau - Programming Assignment Univ.-Prof. Dr. Franz Wotawa, Birgit Hofer Institute for Software Technology, Graz University of Technology April 20, 2011 Introduction During this semester

More information

Advanced Software Testing Testing Code with Static Analysis

Advanced Software Testing Testing Code with Static Analysis Advanced Software Testing Testing Code with Static Analysis Advanced Software Testing A series of webinars, this one excerpted from Advanced Software Testing: V3, a book for technical test analysts, programmers,

More information

No Source Code. EEC 521: Software Engineering. Specification-Based Testing. Advantages

No Source Code. EEC 521: Software Engineering. Specification-Based Testing. Advantages No Source Code : Software Testing Black-Box Testing Test-Driven Development No access to source code So test cases don t worry about structure Emphasis is only on ensuring that the contract is met Specification-Based

More information

Black Box Testing. EEC 521: Software Engineering. Specification-Based Testing. No Source Code. Software Testing

Black Box Testing. EEC 521: Software Engineering. Specification-Based Testing. No Source Code. Software Testing Black Box Testing EEC 521: Software Engineering Software Testing Black-Box Testing Test-Driven Development Also known as specification-based testing Tester has access only to running code and the specification

More information

CS 451 Software Engineering Winter 2009

CS 451 Software Engineering Winter 2009 CS 451 Software Engineering Winter 2009 Yuanfang Cai Room 104, University Crossings 215.895.0298 yfcai@cs.drexel.edu 1 Software Testing Techniques FUNDAMENTALS The goal of testing is to find errors. A

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies CODING Good software development organizations normally require their programmers to follow some welldefined and standard style of coding called coding standards. Most software development organizations

More information

Testing. Unit, integration, regression, validation, system. OO Testing techniques Application of traditional techniques to OO software

Testing. Unit, integration, regression, validation, system. OO Testing techniques Application of traditional techniques to OO software Testing Basic ideas and principles Traditional testing strategies Unit, integration, regression, validation, system OO Testing techniques Application of traditional techniques to OO software Testing-11,

More information

CMSC 132: OBJECT-ORIENTED PROGRAMMING II

CMSC 132: OBJECT-ORIENTED PROGRAMMING II CMSC 132: OBJECT-ORIENTED PROGRAMMING II Program Testing Department of Computer Science University of Maryland, College Park Debugging Is Harder Than Coding! Debugging is twice as hard as writing the code

More information

Programming And Testing at Unit Level

Programming And Testing at Unit Level 1 What programmer must know in order to produce good quality code? Mika Maunumaa, researcher ~5 years in academia researching UML, testing and software processes ~10 years in industry as a developer and

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

SOFTWARE ENGINEERING IT 0301 Semester V B.Nithya,G.Lakshmi Priya Asst Professor SRM University, Kattankulathur

SOFTWARE ENGINEERING IT 0301 Semester V B.Nithya,G.Lakshmi Priya Asst Professor SRM University, Kattankulathur SOFTWARE ENGINEERING IT 0301 Semester V B.Nithya,G.Lakshmi Priya Asst Professor SRM University, Kattankulathur School of Computing, Department of IT 1 School of Computing, Department 2 SOFTWARE TESTING

More information

Programming Studio #9 ECE 190

Programming Studio #9 ECE 190 Programming Studio #9 ECE 190 Programming Studio #9 Concepts: Functions review 2D Arrays GDB Announcements EXAM 3 CONFLICT REQUESTS, ON COMPASS, DUE THIS MONDAY 5PM. NO EXTENSIONS, NO EXCEPTIONS. Functions

More information

Software Testing. Testing 1

Software Testing. Testing 1 Software Testing Testing 1 Background Main objectives of a project: High Quality & High Productivity (Q&P) Quality has many dimensions reliability, maintainability, interoperability etc. Reliability is

More information

Important From Last Time

Important From Last Time Important From Last Time Embedded C Pros and cons Macros and how to avoid them Intrinsics Interrupt syntax Inline assembly Today Advanced C What C programs mean How to create C programs that mean nothing

More information

Page 1. Today. Important From Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right?

Page 1. Today. Important From Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right? Important From Last Time Today Embedded C Pros and cons Macros and how to avoid them Intrinsics Interrupt syntax Inline assembly Advanced C What C programs mean How to create C programs that mean nothing

More information

Introduction to Software Testing Chapter 4 Input Space Partition Testing

Introduction to Software Testing Chapter 4 Input Space Partition Testing Introduction to Software Testing Chapter 4 Input Space Partition Testing Paul Ammann & Jeff Offutt http://www.cs.gmu.edu/~offutt/ softwaretest/ Ch. 4 : Input Space Coverage Four Structures for Modeling

More information

Programming refresher and intro to C programming

Programming refresher and intro to C programming Applied mechatronics Programming refresher and intro to C programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2018 Outline 1 C programming intro 2

More information

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011 Oregon State University School of Electrical Engineering and Computer Science CS 261 Recitation 1 Spring 2011 Outline Using Secure Shell Clients GCC Some Examples Intro to C * * Windows File transfer client:

More information

Important From Last Time

Important From Last Time Important From Last Time Embedded C Ø Pros and cons Macros and how to avoid them Intrinsics Interrupt syntax Inline assembly Today Advanced C What C programs mean How to create C programs that mean nothing

More information

Lab 1: Introduction to C++

Lab 1: Introduction to C++ CPSC 221, Jan-Apr 2017 Lab 1 1/5 Lab 1: Introduction to C++ This is an introduction to C++ through some simple activities. You should also read the C++ Primer in your textbook, and practice as much as

More information

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators Objectives Chapter 4: Control Structures I (Selection) In this chapter, you will: Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)

More information

Pointers, Arrays and Parameters

Pointers, Arrays and Parameters Pointers, Arrays and Parameters This exercise is different from our usual exercises. You don t have so much a problem to solve by creating a program but rather some things to understand about the programming

More information

CS 4387/5387 SOFTWARE V&V LECTURE 4 BLACK-BOX TESTING

CS 4387/5387 SOFTWARE V&V LECTURE 4 BLACK-BOX TESTING 1 CS 4387/5387 SOFTWARE V&V LECTURE 4 BLACK-BOX TESTING Outline 2 Quiz Black-Box Testing Equivalence Class Testing (Equivalence Partitioning) Boundary value analysis Decision Table Testing 1 3 Quiz - 1

More information

Outline. Computer programming. Debugging. What is it. Debugging. Hints. Debugging

Outline. Computer programming. Debugging. What is it. Debugging. Hints. Debugging Outline Computer programming Debugging Hints Gathering evidence Common C errors "Education is a progressive discovery of our own ignorance." Will Durant T.U. Cluj-Napoca - Computer Programming - lecture

More information

Program Verification! Goals of this Lecture! Words from the Wise! Testing!

Program Verification! Goals of this Lecture! Words from the Wise! Testing! Words from the Wise Testing On two occasions I have been asked [by members of Parliament], Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out? I am not able rightly

More information

CSE 374 Final Exam Sample Solution 6/10/10

CSE 374 Final Exam Sample Solution 6/10/10 Question 1. (8 points) (testing) Suppose we are testing a list data structure implementation similar to a Java ArrayList. The list uses a fixed-size array as the underlying data structure to store the

More information

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d. Chapter 4: Control Structures I (Selection) In this chapter, you will: Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)

More information

An Introduction to Systematic Software Testing. Robert France CSU

An Introduction to Systematic Software Testing. Robert France CSU An Introduction to Systematic Software Testing Robert France CSU Why do we need to systematically test software? Poor quality products can Inconvenience direct and indirect users Result in severe financial

More information

https://www.lri.fr/ linaye/gl.html

https://www.lri.fr/ linaye/gl.html Software Engineering https://www.lri.fr/ linaye/gl.html lina.ye@centralesupelec.fr Sequence 3, 2017-2018 1/61 Software Engineering Plan 1 2 3 4 5 2/61 Software Engineering Software Testing 3/61 Software

More information

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6!

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6! Testing The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 6 1 Goals of this Lecture Help you learn about: Internal testing External testing General

More information

Software Testing Lecture 1. Justin Pearson

Software Testing Lecture 1. Justin Pearson Software Testing Lecture 1 Justin Pearson 2017 1 / 50 Four Questions Does my software work? 2 / 50 Four Questions Does my software work? Does my software meet its specification? 3 / 50 Four Questions Does

More information

#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); }

#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); } 1. (9 pts) Show what will be output by the cout s in this program. As in normal program execution, any update to a variable should affect the next statement. (Note: boolalpha simply causes Booleans to

More information

Page 1. Today. Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right? Compiler requirements CPP Volatile

Page 1. Today. Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right? Compiler requirements CPP Volatile Last Time Today Compiler requirements CPP Volatile Advanced C What C programs mean int my_loop (int base) { int index, count = 0; for (index = base; index < (base+10); index++) count++; urn count; my_loop:

More information

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6!

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6! Testing The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 6 1 Words from the Wise On two occasions I have been asked [by members of Parliament],

More information

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

B+ Tree Review. CSE332: Data Abstractions Lecture 10: More B Trees; Hashing. Can do a little better with insert. Adoption for insert

B+ Tree Review. CSE332: Data Abstractions Lecture 10: More B Trees; Hashing. Can do a little better with insert. Adoption for insert B+ Tree Review CSE2: Data Abstractions Lecture 10: More B Trees; Hashing Dan Grossman Spring 2010 M-ary tree with room for L data items at each leaf Order property: Subtree between keys x and y contains

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

CS 31: Intro to Systems C Programming. Kevin Webb Swarthmore College September 13, 2018

CS 31: Intro to Systems C Programming. Kevin Webb Swarthmore College September 13, 2018 CS 31: Intro to Systems C Programming Kevin Webb Swarthmore College September 13, 2018 Reading Quiz Agenda Basics of C programming Comments, variables, print statements, loops, conditionals, etc. NOT the

More information

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams Three General Principles of QA COMP 4004 Fall 2008 Notes Adapted from Dr. A. Williams Software Quality Assurance Lec2 1 Three General Principles of QA Know what you are doing. Know what you should be doing.

More information

Manual Testing. Software Development Life Cycle. Verification. Mobile Testing

Manual Testing.  Software Development Life Cycle. Verification. Mobile Testing 10 Weeks (Weekday Batches) or 12 Weekends (Weekend batches) To become a Professional Software Tester To enable the students to become Employable Manual Testing Fundamental of Testing What is software testing?

More information

Code Coverage Metrics And How to Use (and Misuse) Them

Code Coverage Metrics And How to Use (and Misuse) Them Code Coverage Metrics And How to Use (and Misuse) Them #include main() { int i, n, pp, p, c; printf("enter element count: "); scanf("%d", &n); if (n < 0) { printf("no %d series!\n", n); n = -1;

More information

[2:3] Linked Lists, Stacks, Queues

[2:3] Linked Lists, Stacks, Queues [2:3] Linked Lists, Stacks, Queues Helpful Knowledge CS308 Abstract data structures vs concrete data types CS250 Memory management (stack) Pointers CS230 Modular Arithmetic !!!!! There s a lot of slides,

More information

OHJ-306x: Software Testing Introduction to the Course Project Part 1: General Information and Project phases 1 & 2: Unit testing

OHJ-306x: Software Testing Introduction to the Course Project Part 1: General Information and Project phases 1 & 2: Unit testing 1 OHJ-306x: Software Testing Introduction to the Course Project Part 1: General Information and Project phases 1 & 2: Unit testing Antti Jääskeläinen, leading course assistant Matti Vuori, course assistant

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

Code Coverage Metrics And How to Use Them

Code Coverage Metrics And How to Use Them Code Coverage Metrics And How to Use Them int main(int argc, char* argv[]) { long int i, n=0; ubcd pp, p, c; if (argc > 1) { } else { } if (n < 0) { } else { } n = atol(argv[1]); cout

More information

CS 33. Introduction to C. Part 5. CS33 Intro to Computer Systems V 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CS 33. Introduction to C. Part 5. CS33 Intro to Computer Systems V 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. CS 33 Introduction to C Part 5 CS33 Intro to Computer Systems V 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Basic Data Types int short char -2,147,483,648 2,147,483,647-32,768 32,767-128

More information

Second assignment came out Monday evening. Find defects in Hnefetafl rules written by your classmates. Topic: Code Inspection and Testing

Second assignment came out Monday evening. Find defects in Hnefetafl rules written by your classmates. Topic: Code Inspection and Testing Announcements Second assignment came out Monday evening Topic: Code Inspection and Testing Find defects in Hnefetafl rules written by your classmates Compare inspection, coverage testing, random testing,

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

How to Break Software by James Whittaker

How to Break Software by James Whittaker How to Break Software by James Whittaker CS 470 Practical Guide to Testing Consider the system as a whole and their interactions File System, Operating System API Application Under Test UI Human invokes

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. The doc is

More information

ECE220: Computer Systems and Programming Spring 2018 Honors Section due: Saturday 14 April at 11:59:59 p.m. Code Generation for an LC-3 Compiler

ECE220: Computer Systems and Programming Spring 2018 Honors Section due: Saturday 14 April at 11:59:59 p.m. Code Generation for an LC-3 Compiler ECE220: Computer Systems and Programming Spring 2018 Honors Section Machine Problem 11 due: Saturday 14 April at 11:59:59 p.m. Code Generation for an LC-3 Compiler This assignment requires you to use recursion

More information

EXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist:

EXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist: EXAMINING THE CODE CONTENTS I. Static White Box Testing II. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist: Dynamic White Box Testing

More information

C++ Lab 03 - C++ Functions

C++ Lab 03 - C++ Functions C++ Lab 03 - C++ Functions 2.680 Unmanned Marine Vehicle Autonomy, Sensing and Communications Spring 2018 Michael Benjamin, mikerb@mit.edu Department of Mechanical Engineering Computer Science and Artificial

More information

MTAT : Software Testing

MTAT : Software Testing MTAT.03.159: Software Testing Lecture 03: White-Box Testing (Textbook Ch. 5) Spring 2013 Dietmar Pfahl email: dietmar.pfahl@ut.ee Lecture Chapter 5 White-box testing techniques (Lab 3) Structure of Lecture

More information

TITAN 5300 Software. Unit Test Guidelines. S. Darling, S. Harpster, R. Hite, K. Konecki, W. Martersteck, R. Stewart. Revision 2.0

TITAN 5300 Software. Unit Test Guidelines. S. Darling, S. Harpster, R. Hite, K. Konecki, W. Martersteck, R. Stewart. Revision 2.0 TITAN 5300 Software Unit Test Guidelines S. Darling, S. Harpster, R. Hite, K. Konecki, W. Martersteck, R. Stewart Revision 2.0 1994, Tellabs Operations, Inc., 4951 Indiana Ave., Lisle, IL 60532 (312) 969-8800

More information

CSE 333 Midterm Exam 5/10/13

CSE 333 Midterm Exam 5/10/13 Name There are 5 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed

More information

The testing process. Component testing. System testing

The testing process. Component testing. System testing Software testing Objectives To discuss the distinctions between validation testing and defect testing To describe the principles of system and component testing To describe strategies for generating system

More information

B.31 Specification for program ntree (Document ES7)

B.31 Specification for program ntree (Document ES7) ISERN 95 02 B.31 Specification for program ntree (Document ES7) B.31 Specification for program ntree (Document ES7) Name ntree Functions for managing a tree Usage ntree input-file Description ntree reads

More information

Software testing A.A. 2018/2019

Software testing A.A. 2018/2019 Software testing A.A. 2018/2019 Testing Testing is intended to show that a program does what it is intended to do and to discover program defects before it is put into use. When you test software, you

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #3 C Strings, Arrays, & Malloc 2007-06-27 Scott Beamer, Instructor Sun announces new supercomputer: Sun Constellation CS61C L3 C Pointers

More information

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input CpSc Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input Overview For this lab, you will use: one or more of the conditional statements explained below scanf() or fscanf() to read

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Algorithms & Datastructures Laboratory Exercise Sheet 1

Algorithms & Datastructures Laboratory Exercise Sheet 1 Algorithms & Datastructures Laboratory Exercise Sheet 1 Wolfgang Pausch Heiko Studt René Thiemann Tomas Vitvar

More information

Program Correctness and Efficiency. Chapter 2

Program Correctness and Efficiency. Chapter 2 Program Correctness and Efficiency Chapter 2 Chapter Objectives To understand the differences between the three categories of program errors To understand the effect of an uncaught exception and why you

More information

Testing. Topics. Types of Testing. Types of Testing

Testing. Topics. Types of Testing. Types of Testing Topics 1) What are common types of testing? a) Testing like a user: through the UI. b) Testing like a dev: through the code. 2) What makes a good bug report? 3) How can we write code to test code (via

More information

Program Assignment 2

Program Assignment 2 Program Assignment 2 CMSC 417 Fall 2014 September 16, 2014 1 Deadline September 30, 2014. 2 Objective In this assignment you will write the server program which will communicate using sockets with the

More information

Part 5. Verification and Validation

Part 5. Verification and Validation Software Engineering Part 5. Verification and Validation - Verification and Validation - Software Testing Ver. 1.7 This lecture note is based on materials from Ian Sommerville 2006. Anyone can use this

More information

CS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018

CS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018 CS 31: Intro to Systems Pointers and Memory Kevin Webb Swarthmore College October 2, 2018 Overview How to reference the location of a variable in memory Where variables are placed in memory How to make

More information

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle Boggle If you are not familiar with the game Boggle, the game is played with 16 dice that have letters on all faces. The dice are randomly deposited into a four-by-four grid so that the players see the

More information

QUIZ: What value is stored in a after this

QUIZ: What value is stored in a after this QUIZ: What value is stored in a after this statement is executed? Why? a = 23/7; QUIZ evaluates to 16. Lesson 4 Statements, Expressions, Operators Statement = complete instruction that directs the computer

More information

Computer Science E-119 Fall Problem Set 3. Due before lecture on Wednesday, October 31

Computer Science E-119 Fall Problem Set 3. Due before lecture on Wednesday, October 31 Due before lecture on Wednesday, October 31 Getting Started To get the files that you will need for this problem set, log into nice.harvard.edu and enter the following command: gethw 3 This will create

More information

Please be informed that a new Testwell CTC++ version has been released.

Please be informed that a new Testwell CTC++ version has been released. Offenburg (Germany) / Tampere (Finland), 30 June 2016 Please be informed that a new Testwell CTC++ version 8.0.1 has been released. Testwell Oy CTC++ System Version 8.0.1 Verifysoft Technology GmbH 30

More information

Chapter 11, Testing, Part 2: Integration and System Testing

Chapter 11, Testing, Part 2: Integration and System Testing Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 11, Testing, Part 2: Integration and System Testing Overview Integration testing Big bang Bottom up Top down Sandwich System testing

More information

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/ CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference

More information

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus Testing Prof. Clarkson Fall 2017 Today s music: Wrecking Ball by Miley Cyrus Review Previously in 3110: Modules Specification (functions, modules) Today: Validation Testing Black box Glass box Randomized

More information

4. Java language basics: Function. Minhaeng Lee

4. Java language basics: Function. Minhaeng Lee 4. Java language basics: Function Minhaeng Lee Review : loop Program print from 20 to 10 (reverse order) While/for Program print from 1, 3, 5, 7.. 21 (two interval) Make a condition that make true only

More information

Modern Methods in Software Engineering. Testing.

Modern Methods in Software Engineering. Testing. Modern Methods in Software Engineering Testing www.imit.kth.se/courses/2g1522 Literature used Text book Chapter 11 Introduction Content Terminology Types of errors Dealing with errors Component Testing

More information

Testing & Debugging TB-1

Testing & Debugging TB-1 Testing & Debugging TB-1 Need for Testing Software systems are inherently complex» Large systems 1 to 3 errors per 100 lines of code (LOC) Extensive verification and validiation is required to build quality

More information

Software Testing. Lecturer: Sebastian Coope Ashton Building, Room G.18

Software Testing. Lecturer: Sebastian Coope Ashton Building, Room G.18 Lecturer: Sebastian Coope Ashton Building, Room G.18 E-mail: coopes@liverpool.ac.uk COMP 201 web-page: http://www.csc.liv.ac.uk/~coopes/comp201 Software Testing 1 Defect Testing Defect testing involves

More information

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Unit Testing. Emina Torlak

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Unit Testing. Emina Torlak CSE 403: Software Engineering, Fall 2016 courses.cs.washington.edu/courses/cse403/16au/ Unit Testing Emina Torlak emina@cs.washington.edu Outline Software quality control Effective unit testing Coverage

More information

Outline. iterator review iterator implementation the Java foreach statement testing

Outline. iterator review iterator implementation the Java foreach statement testing Outline iterator review iterator implementation the Java foreach statement testing review: Iterator methods a Java iterator only provides two or three operations: E next(), which returns the next element,

More information

Jtest Tutorial. Tutorial

Jtest Tutorial. Tutorial Jtest Jtest Welcome to the Jtest. This tutorial walks you through how to perform common Jtest tasks using example files. Please note that although the four types of tests (static analysis, white-box testing,

More information

COMPUTER APPLICATION

COMPUTER APPLICATION Total No. of Printed Pages 16 HS/XII/A.Sc.Com/CAP/14 2 0 1 4 COMPUTER APPLICATION ( Science / Arts / Commerce ) ( Theory ) Full Marks : 70 Time : 3 hours The figures in the margin indicate full marks for

More information

MTAT : Software Testing

MTAT : Software Testing MTAT.03.159: Software Testing Lecture 02: Basic Black-Box and White-Box Testing Techniques (Textbook Ch. 4 & 5) Spring 2018 Dietmar Pfahl email: dietmar.pfahl@ut.ee Structure of Lecture 2 Black-Box vs.

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon

More information

Type Conversion. and. Statements

Type Conversion. and. Statements and Statements Type conversion changing a value from one type to another Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Suppose

More information

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011 CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part II) Instructors: Randy H. Katz David A. Patterson http://inst.eecs.berkeley.edu/~cs61c/sp11 Spring 2011 -- Lecture

More information

Learning Objectives. A Meta Comment. Exercise 1. Contents. From CS61Wiki

Learning Objectives. A Meta Comment. Exercise 1. Contents. From CS61Wiki From CS61Wiki Contents 1 Learning Objectives 2 A Meta Comment 3 Exercise 1 3.1 Questions 3.2 Running code and using GDB 3.3 Compiler Optimizations 3.4 hexdump: a handy function 3.4.1 Questions 3.5 Checkpoint

More information

Lecture 17: Testing Strategies. Developer Testing

Lecture 17: Testing Strategies. Developer Testing Lecture 17: Testing Strategies Structural Coverage Strategies (White box testing): Statement Coverage Branch Coverage Condition Coverage Data Path Coverage Function Coverage Strategies (Black box testing):

More information

OHJ-306x: Software Testing Introduction to the Course Project Part 1: General Information and Project Phases 1 & 2: Unit testing

OHJ-306x: Software Testing Introduction to the Course Project Part 1: General Information and Project Phases 1 & 2: Unit testing 1 OHJ-306x: Software Testing Introduction to the Course Project Part 1: General Information and Project Phases 1 & 2: Unit testing Antti Jääskeläinen, leading course assistant Matti Vuori, course assistant

More information

C and C++ Secure Coding 4-day course. Syllabus

C and C++ Secure Coding 4-day course. Syllabus C and C++ Secure Coding 4-day course Syllabus C and C++ Secure Coding 4-Day Course Course description Secure Programming is the last line of defense against attacks targeted toward our systems. This course

More information

Please be informed that a new Testwell CTC++ version 8.2 has been released.

Please be informed that a new Testwell CTC++ version 8.2 has been released. Offenburg (Germany) / Tampere (Finland), 16 May 2017 Please be informed that a new Testwell CTC++ version 8.2 has been released. Testwell CTC++ v8.2 available ----------------------------- CTC++ v8.2 contains

More information