Top Banner
TSP: Software Engineering 2017: J Paul Gibson 1 CSC 7003 : Basics of Software Engineering J Paul Gibson, D311 [email protected] http://www-public.telecom-sudparis.eu/~gibson/Teaching/CSC7003/ Testing …/~gibson/Teaching/CSC7003/L7-Testing.pdf
23

Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

Jun 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

TSP: Software Engineering2017: J Paul Gibson 1

CSC 7003 : Basics of Software Engineering

J Paul Gibson, D311

[email protected]

http://www-public.telecom-sudparis.eu/~gibson/Teaching/CSC7003/

Testing

…/~gibson/Teaching/CSC7003/L7-Testing.pdf

Page 2: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

22017: J Paul Gibson TSP: Software Engineering

Why do we need tests?

Page 3: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

32017: J Paul Gibson TSP: Software Engineering

Do we test our software like this?

Page 4: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

42017: J Paul Gibson TSP: Software Engineering

Do we test our software like this?

Page 5: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

52017: J Paul Gibson TSP: Software Engineering

Testing : in the V life cycle

Software Development Life Cycle Software Test Life Cycle

Page 6: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

62017: J Paul Gibson TSP: Software Engineering

Black box or White box Testing

Question: advantages and disadvantages of each?

Page 7: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

72017: J Paul Gibson TSP: Software Engineering

Unit Testing

http://blog.smartbear.com/automated-testing/a-short-lecture-on-the-value-and-practice-of-unit-testing/

JUnit CUnit xUnit etc ….

Most (nearly all) programming languages have automated tool support for unit testing (as well as other types of testing)

Automated Unit testing is very valuable and beginners to programming need to learn it ASAP

Whenever you learn a new programming language, learn the testing tool(s) that come with it

Page 8: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

82017: J Paul Gibson TSP: Software Engineering

Integration Testing

Why do we not just do unit tests?

http://i.imgur.com/qSN5SFR.gifv

“2 unit tests, zero integration tests”

Why do we not just do validation tests?

Page 9: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

92017: J Paul Gibson TSP: Software Engineering

Integration Testing

Fixing problems later in development can cost much more than fixing them earlier - but you have to detect them first

Page 10: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

102017: J Paul Gibson TSP: Software Engineering

System Testing

Never underestimate the users’ ability to surprise

Page 11: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

112017: J Paul Gibson TSP: Software Engineering

Regression Testing

Page 12: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

122017: J Paul Gibson TSP: Software Engineering

Testing Metrics

Page 13: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

132017: J Paul Gibson TSP: Software Engineering

Testing Code Coverage

Most testing tools come/work with coverage tools

Page 14: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

142017: J Paul Gibson TSP: Software Engineering

Test first development

Page 15: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

152017: J Paul Gibson TSP: Software Engineering

Some other testing types

Functional - Nonfunctional Performance Usability Security Accessibility Internationalisation/ localisation etc …

http://testautomation.applitools.com/post/98802238427/41-awesome-quotes-about-software-testing

Page 16: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

162017: J Paul Gibson TSP: Software Engineering

Your test code needs testing?

Page 17: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

172017: J Paul Gibson TSP: Software Engineering

The Line Overlap Problem

Consider the integer number line:

… -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8 …

We can define a segment on this line by a range (minimum … maximum)

… -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8 …

Below, we illustrate 2 segments: (-3, 1) and (0,6)

In this example, the 2 segments are said to overlap on the line because they share at least 1 point in common. The overlap in this case is the segment (0, 1).

Page 18: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

182017: J Paul Gibson TSP: Software Engineering

The Line Overlap Problem

Requirements and Tests

The problem is to write a program that can calculate whether any 2 segments overlap on the integer line. It is to return the segment overlapped as the result of the program (an “empty” segment if there is no overlap)

You are to specify and implement a test set for this problem. You are not to code a working solution until after your tests are coded.

Your test code should be written in the same programming language as the solution(s) which you will be expected to test.

The code (including tests) must be well documented.

Illustrate that your tests can find errors in an incorrect solution

Page 19: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

192017: J Paul Gibson TSP: Software Engineering

The Line Overlap Problem

Complete Tests

Given the minimum and maximum values, how many tests must be executed if we wish to test (exhaustively) every possible case?

Page 20: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

202017: J Paul Gibson TSP: Software Engineering

The Line Overlap Problem: Part 2 - An extra dimension

0,0Segment ((2,7), (6,3)) Segment ((1,4), (6,7))

The problem is to tell whether the 2 segments intersect on the specified integer grid.

In the example, the answer is clearly yes.

Note that we do not need to calculate the point of intersection

8,8Consider a 2-dimensional grid

Page 21: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

212017: J Paul Gibson TSP: Software Engineering

The Line Overlap Problem: Part 2 - An extra dimension

Requirements and Tests

The problem is to write a program that can calculate whether any 2 segments overlap on the integer grid.

You are to specify and implement a test set for this problem. You are not to code a working solution until after your tests are coded.

Your test code should be written in the same programming language as the solution(s) which you will be expected to test.

The code (including tests) must be well documented.

Illustrate that your tests can find errors in an incorrect solution

Page 22: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

222017: J Paul Gibson TSP: Software Engineering

The Line Overlap Problem: Part 2 - An extra dimension

Testing a design hypothesis for re-use of code.

I would like to be able to re-use my code to the first 1-dimensional overlap problem in order to solve the problem in 2 dimensions.

It is suggested that 2 lines overlap in a grid if and only if they ‘overlap vertically’ and ‘overlap horizontally’.

Intuitively, this seems right. However this needs to be tested. For example:

Segment ((2,7), (6,3)) Segment ((1,4), (6,7)) overlap iff (2,6) and (1,6) overlap

and (7,3) and (4,7) overlap

Is this true for all such segments in the grid space?

Page 23: Testing - Webspacesgibson/Teaching/CSC7003/L7-Testing.pdfTesting a design hypothesis for re-use of code. I would like to be able to re-use my code to the first 1-dimensional overlap

232017: J Paul Gibson TSP: Software Engineering

Problem Analysis

What did you learn about testing from this problem?

Did you try to use a testing tool, like JUnit or CUnit? If so, how did you find it? If not, what sort of things would you like such a tool to be able to do?

Did you find any bugs in your test code?

How good are your tests? How do you judge the quality of the tests?

Did your tests help you to find bugs in your solution code?