list of dots

User Manual    [Previous]   [Next]   

Test with Mixset

Tests can be integrated with mixsets to enhance feature-based testing. This allows the user to toggle feature-specific tests using a mixset dedicated for testcases that can be switched on using the use mixsetTest; statement. The following example shows how to create a mixset for testing another mixset. Note the tests can also be embedded in the same mixset or can be defined in a separate one. The only issue that need to be handled is that dependency between mixsets. If your test case contains an instantiated object that uses attribute in a particular mixset then either embed the tests within the mixset to avoid errors or make sure you always switch-on the targeted feature to avoid instantiation errors. Currently, this is not caught by the compiler but will be added.

Example

class Student {
  id;
  name;

  
}


mixset Job {
  class Student {
  job;
Integer  jobRank = 1;  
  
    void promote () {
     this.setJobRank(this.jobRank + 1);
    }
    
  }
  
}


mixset JobTest {
  
  class Student {
    test checkPromotion {
      Student s1 ("ID123", "John", "Director");
      
      assertTrue(s1.getJobRank() == 1);
      
      s1.promote();
      
      assertTrue(s1.getJobRank() == 2);
      
    }
    
  }
  
  
}

use Job;
use JobTest;


      

Load the above code into UmpleOnline