Software Testing: Preparatory Activity — 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 (4 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.

  3. Understading 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 toRelativeURL 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 toRelativeURL():
    /** This method converts an absolute url to an url relative to a given
     * base-url.  The algorithm is somewhat chaotic, but it works (Maybe rewrite
     * it).  Be careful, the method is ".mm"-specific. Something like this should
     * be included in the librarys, but I couldn't find it. You can create a new
     * absolute url with "new URL(URL context, URL relative)".
     */
    public static String toRelativeURL(URL base, URL target) {
      // Precondition: If URL is a path to folder, then it must end with '/'
      // character.
      if( (base.getProtocol().equals(target.getProtocol())) &&
        (base.getHost().equals(target.getHost()))) {
    
        String baseString = base.getFile();
        String targetString = target.getFile();
        String result = "";
    
          //remove filename from URL
          baseString = baseString.substring(0, baseString.lastIndexOf("/")+1);
    
          //remove filename from URL
          targetString = targetString.substring(0, targetString.lastIndexOf("/")+1);
    
        //Maybe this causes problems under windows
        StringTokenizer baseTokens = new StringTokenizer(baseString,"/");
        //Maybe this causes problems under windows
        StringTokenizer targetTokens = new StringTokenizer(targetString,"/");
    
        String nextBaseToken = "", nextTargetToken = "";
    
        //Algorithm
    
        while(baseTokens.hasMoreTokens() && targetTokens.hasMoreTokens()) {
          nextBaseToken = baseTokens.nextToken();
          nextTargetToken = targetTokens.nextToken();
          if (!(nextBaseToken.equals(nextTargetToken))) {
            while(true) {
              result = result.concat("../");
              if (!baseTokens.hasMoreTokens()) {
                break;
              }
              nextBaseToken = baseTokens.nextToken();
            }
            while(true) {
              result = result.concat(nextTargetToken+"/");
              if (!targetTokens.hasMoreTokens()) {
                break;
              }
              nextTargetToken = targetTokens.nextToken();
            }
            String temp = target.getFile();
            result = result.concat(
                temp.substring(temp.lastIndexOf("/")+1,temp.length()));
            return result;
          }
        }
    
        while(baseTokens.hasMoreTokens()) {
          result = result.concat("../");
          baseTokens.nextToken();
        }
    
        while(targetTokens.hasMoreTokens()) {
          nextTargetToken = targetTokens.nextToken();
          result = result.concat(nextTargetToken + "/");
        }
    
        String temp = target.getFile();
        result = result.concat(
            temp.substring(temp.lastIndexOf("/")+1,temp.length()));
        return result;
      }
      return target.toString();
    }
    

  4. Contribute to the ST Wiki: Tuis is a location for questions and answers concerning the Software Testing Course. Software Testing Wiki


Home : Teaching : Courses : St : 2011-12 : Resource-folder 

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