Software Testing Preparatory Activity 2: Understanding the Practical

The purpose of this activity is to become familiar with the Software Testing Practical, identify any relevant questions, think about what kind of information you might need to know, and to look at the code you are about to test. You should do the following (3 tasks):

  1. Understading the Task. Read the practical handout and mark up with any queries you have — list all relevant questions

  2. Looking for Information. Take some time to read the code you're about to test; read it looking for features that are not understandable without additional information. As you read, decide what additional information you will need to amass in order to start testing the code — list all information you need and then consider where to find it. The code is quite short because there is a considerable overhead in looking at tools and understanding the techniques of software testing. If you want to find additional testing challenges have a look at more code in the JUnit project.

  3. Understanding Software Complexity. Have another look at the code, this time you should be try to read the code considering what aspects of the code might be hard to test list all critical aspects identified.
    • first list things you think might be hard to test, then choose two or three and consider what kinds of inputs you would need to give the function to test the behaviour you have identified.
    • Try to think/construct an erroneous variant of the sortStrings method by changing only one character in the file and then try to work out a test that would uncover the error.

    Source extract for Sorter:
    public class Sorter {
    	public static interface Swapper {
    		public void swap(Vector values, int left, int right);
    	}
    		
    	public static void sortStrings(Vector values , int left, int right, Swapper swapper) { 
    		int oleft= left;
    		int oright= right;
    		String mid= (String)values.elementAt((left + right) / 2); 
    		do { 
    			while (((String)(values.elementAt(left))).compareTo(mid) < 0)  
    				left++; 
    			while (mid.compareTo((String)(values.elementAt(right))) < 0)  
    				right--; 
    			if (left <= right) {
    				swapper.swap(values, left, right); 
    				left++; 
    				right--; 
    			} 
    		} while (left <= right);
    		
    		if (oleft < right) 
    			sortStrings(values, oleft, right, swapper); 
    		if (left < oright) 
    			 sortStrings(values, left, oright, swapper); 
    	}
    }
    
    


Home : Teaching : Courses : St : 2014-15 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh