Equipe VASCO | LIG | Grenoble University

TOBIAS : a tool for combinatorial testing

    Friday February 22, 2019

Tobias On-Line - Getting Started

This page is a step by step introduction to the use of the Tobias On-Line web site. Alternatively, a short video (3'50") is also available here. It shows how to upload a file on the Tobias web site, and get the results.


Let us first consider a simple java class Purse which handles an electronic purse. It features a constructor, and three operations : credit(int nb), debit(int nb) and getBalance(). The java code for class Purse can be downloaded here and is given at Fig. 5.

In order to test this program, one would like to create an object of class Purse, then to credit it with some amount of money, then to debit some other amount and finally check the resulting balance. Tobias allows to generate tests which follow this sequence and combine various predefined amounts.

1 The input file

Fig. 1 gives the text of the Tobias input file PurseSeq1.txt (available here). It is expressed in the TSLT language (Test Schema Language for Tobias) and stored in an ordinary text file. This input file describes a group named SimpleSequence. This group is tagged as us=true which means that this group will be unfolded by Tobias into a test suite. The group is defined as a sequence of four instructions: a call to the constructor of class Purse, followed by calls to methods credit, debit and getBalance. Methods credit and debit take an integer parameter as input. In group SimpleSequence, three values (10, 50, and 0) are defined for the input parameter of credit, and two values (5 and 15) for the input parameter of debit.


group SimpleSequence[us=true] {
   Purse p = new Purse();
   p.credit([10, 50, 0]);
   p.debit([5,15]);
   p.getBalance();
}

Figure 1: The input file for Tobias : PurseSeq1.txt (available here)

2 Unfolding the group

To unfold the group, the input file should be submitted to the Tobias-on-Line web page at the following url http://tobias.liglab.fr/. Fig. 2 gives the input form for this page. The user must do the following actions:

  1. enter his email address

  2. select the input file

  3. select the types for the input and output files (here TSLT and JUnit)

  4. answer the captcha challenge by entering the text corresponding to the distorded image (After several succeeded attempts, the captcha challenge will no longer be needed).

  5. accept the terms of the licence by checking the corresponding box

  6. click on the “upload button”

Figure 2: The input form for Tobias-on-Line

3 The results of Tobias

Fig. 3 gives the resulting screen when the input file is correct. This screen tells us that 6 test cases were generated. An email is send to the user with a link to the output file. This output file is a zip file which stores the resulting source code of the JUnit files. It will remain on our web site for a limited amount of time. Use the link to access the file and save it on your computer. You can then extract its contents with your favorite unzip tool.

In this case, the unfolding produces a unique JUnit file, TS SimpleSequence.java, given at Fig. 4 (after some reformating of the actual output file). This JUnit file includes 6 test cases, corresponding to all combinations of the input parameters given for methods credit and debit.

Figure 3: The output page corresponding to PurseSeq1.txt

4 Conclusion

This first page has shown how to unfold a simple Tobias input file using Tobias on-Line. The more detailed documentation is provided in a PDF document entitled Tobias Notes .


import junit.framework.TestCase;

public class TS_SimpleSequence extends TestCase {

   public void testSequence_1() throws Exception {
   try{ Purse p = new Purse() ;
     p.credit(10) ; p.debit(5) ; p.getBalance() ;
     } catch (Exception e) { throw e; }
   }
   public void testSequence_2() throws Exception {
   try{ Purse p = new Purse() ;
     p.credit(10) ; p.debit(15) ; p.getBalance() ;
     } catch (Exception e) { throw e; }
   }
   public void testSequence_3() throws Exception {
   try{ Purse p = new Purse() ;
     p.credit(50) ; p.debit(5) ; p.getBalance() ;
     } catch (Exception e) { throw e; }
   }
   public void testSequence_4() throws Exception {
   try{ Purse p = new Purse() ;
     p.credit(50) ; p.debit(15) ; p.getBalance() ;
     } catch (Exception e) { throw e; }
   }
   public void testSequence_5() throws Exception {
   try{ Purse p = new Purse() ;
     p.credit(0) ; p.debit(5) ; p.getBalance() ;
     } catch (Exception e) { throw e; }
   }
   public void testSequence_6() throws Exception {
   try{ Purse p = new Purse() ;
     p.credit(0) ; p.debit(15) ; p.getBalance() ;
     } catch (Exception e) { throw e; }
   }
}

Figure 4: The JUnit file TS SimpleSequence.java corresponding to the unfolding of PurseSeq1.txt


public class Purse {
   private int bal;

   public Purse(){
     bal = 0;
   }

   public int credit(int nb){
     int newBalance = getBalance()+nb;
     if (nb >= 0 && newBalance <= 100 ){
       bal=bal+nb;
       return nb;
     }
     else {return 0;}
   }

   public int debit(int nb){
     int newBalance = getBalance()-nb;
     if (nb >= 0 && newBalance >= 0 ){
       bal=bal-nb;
       return nb;
     }
     else {return 0;}
   }

   public int getBalance(){
     return bal;
   }
}

Figure 5: The java code for Purse.java (available here)