Software Testing - Test Data Selection PDF
Document Details
Uploaded by VibrantSwamp
Kaveh Eshraghian
Tags
Summary
This document discusses methods of software testing, including black box and white box test data selection, and examples involving integer addition and string concatenation. It focuses on identifying and addressing critical points in the testing process.
Full Transcript
Software Testing Test Data Selection Instructor: Kaveh Eshraghian Overview Black Box Test Data Selection White Box Test Data Selection Testing Methods Testing Exhaustive Smart White Box Black Box Exhaust...
Software Testing Test Data Selection Instructor: Kaveh Eshraghian Overview Black Box Test Data Selection White Box Test Data Selection Testing Methods Testing Exhaustive Smart White Box Black Box Exhaustive Testing Definition: Brute force testing / Complete Testing A software testing technique in which all possible combinations of scenarios and inputs are tested to confirm that a software system functions properly under every possible situation. Issue: Large number of tests Duplicate tests Sample 1: Consider an addition of two 32-bit integers. Size of each integer: 4,294,967,296 All possible combinations: 18,446,744,073,709,551,616 Exhaustive Testing Sample 2: IE Tools -> Advanced Options Possible selections: 53 Binary Selections 1 condition with 3 options 1 condition with 4 options Combination: 108,086,391,056,891,904 Smart Testing Definition: Acknowledging the fact that some tests are more important than others and reallocating resources to perform them. Pros: Eliminating Duplication Reducing test numbers Black Box White Box Black Box – Integer Addition Non-duplicate Values Adding two identical even values (eg. 12 + 12), Adding an even and an odd value (eg. 14 + 19), Adding an odd and an even value (eg. 23 + 12), Adding two identical odd values (eg. 23 + 23). Error-prone areas Transition points from one area of data to another (moving from positive to negative values) End points of the data values (the maximum and minimum integer values), Special values (0 being a special value for addition), Values immediately adjacent to other special values. Black Box – Integer Addition adding 0 to a number (12 + 0, -13 + 0) adding 1 to a number (12 + 1, -13 + 1) adding -1 to a number (12 + -1, -13 + -1) adding MAXINT to a number (12 + MAXINT, -13 + MAXINT) adding MININT to a number (12 + MININT, -13 + MININT) adding MAXINT-1 to a number (12 + (MAXINT-1), -13 + (MAXINT-1)) adding MININT+1 to a number (12 + (MININT+1), -13 + (MININT+1)) Black Box – String Concatenation String Concatenation void concat(char dest[], const char src[]) { … } Test Data to consider: 1. Routine values 2. Edge conditions Black Box – String Concatenation Edge Conditions concat("", ""); concat("", "a"); concat("", "abc"); concat("a", ""); concat("abc", ""); Routine values concat("a", "a"); concat("a", "abc"); concat("abc", "x"); Black Box – String Concatenation #define MAX_LEN 16 void concat(char dest[], const char src[]) { … } Routine longer strings not exceeding allocated array size of 16 concat("abcdefg", "hijk"), concat("abcdefg", "hijklmn") Longest possible concat("012345678901234", "x") Longer than allocated storage concat("012345678901234", "xy") White Box – String Concatenation void concat(char dest[], const char src[]) { int dp = 0, sp = 0; if (dest != NULL) { for (dp = 0; dest[dp] != '\0'; dp++); if (src != NULL) { for (sp = 0; src[sp] != '\0'; sp++) { dest[dp++] = src[sp]; } dest[dp] = '\0'; } } } concat(NULL, "a") concat(tmp, NULL) Splitting text into words int split(char line[], char words[][MAX_WORD_LEN + 1], int maxWords) { … } Initial Testing: Test String: char line[] = { " The quick\t brown fox " }; Testing Coverage: Blanks at the begging and ending of the string, Single blanks between words, Multiple blanks between words, Combination of blanks and tabs between words. Splitting Text Into Words int split(char line[], char words[][MAX_WORD_LEN + 1], int maxWords) { char ch; char buf[MAX_WORD_LEN + 1] = { 0 }; int lp = 0, bp = 0, wp = 0, result = 0; ch = line[lp]; while (ch != '\0' && result >= 0) { Check to see if the while (ch != '\0' && (ch == ' ' || ch == '\t')) ch = line[++lp]; bp = 0; number of words exceed the maximum size of the while (ch != '\0' && !(ch == ' ' || ch == '\t')) { buf[bp++] = ch; } ch = line[++lp]; array. Add test to check appropriate if (bp > 0) { buf[bp] = '\0'; if (wp >= maxWords) { result = -1; behavior. } else { strcpy(words[wp++], buf); } } } result = (result < 0) ? result : wp; return result; }