D E V M A T E

Loading

Define Representatives

You are here:
Estimated reading time: 4 min

Now we are going to have a deeper look into how to define and remove representatives. We are also going to show you how you can easily move representatives and copy/paste them.

Define a Representative

You can add a representative to an equivalence class in two ways:

  1. Open the context menu next to the equivalence class and select “Add Representative”.
  2. Highlight the equivalence class row by clicking on it and press “Alt+C”.
Showing how to add representatives from the context menu

Move Representatives Up and Down

If you want to change the order of representatives within your equivalence class you can move them up and down. Again you can do this in the following 2 ways:

  1. Open the context menu of the representative and select “Move Up” or “Move Down”.
  2. Highlight the representative row by clicking on it and press “Alt+↑” or “Alt+↓”.

A representative can only be moved within its equivalence class. So the command “Move Up” does not work on the first representative under the equivalence class and the command “Move Down” does not work on the last representative in an equivalence class.

Copy and Paste a Representative

If you want to define a representative which is quite similar to an already existing one you don’t have to define everything again. You can simply copy and paste them!

Copy a representative in the two following ways:

  1. Open the context menu of the representative and select “Copy”.
  2. Highlight the representative row by clicking on it and press “Ctr+C”

This will copy the representative into the clipboard.

Showing how to copy a representative from the context menu

If you then want to paste a representative you can do this in the following 4 ways:

  1. Open the context menu of that representative after which you want to copy the new one and select “Paste Below”.
  2. Highlight that representative row after which you want to copy the new one and press  “Ctr+V”.
  3. Open the context menu of that equivalence class at which end you want to add the representative and select “Paste” (picture below).
  4. Highlight that equivalence row at which end you want to add the representative and press  “Ctr+V”.
Showing how to paste a representative from the context menu

Remove a Representative

Deleting a representative from an equivalence class can be done in the following 2 ways:

  1. Open the context menu of the representative and select “Remove”.
  2. Highlight the representative row by clicking on it and press “Del”.

If you delete a representative that was already selected in one or more test cases be aware that after the removal no representative for those test cases are chosen and you need to reselect another one again.

Primitive Representatives

We are now going to focus on primitive representatives and how to edit their respective values.

What is a Primitive Representative?

Primitive representatives are representatives of the following types:

  • bool
  • byte
  • sbyte
  • short
  • ushort
  • int
  • uint
  • long
  • ulong
  • decimal
  • float
  • double
  • char
  • string

Change the value of a Primitive Representative

We are now going to show you how to edit an already existing primitive representative in the model view. Since this is similar for most of our types we are going to show you the general method with the type “double”. Data types “char” and “string” work a little bit different.

Let’s say the duration in our AverageSpeed example is defined by a simple parameter duration of the type double instead of a complex interface. We already defined equivalence classes and added representatives. If you add a representative the way we showed you a chapter before then you see that the value of the representative is always 0. That’s because values are initialized with their type’s default value.

There are three ways to change a value:

  1. Open the context menu of the representative and select “Change Value”.
  2. Highlight the representative row by clicking on it and press “F2”.
  3. Double click on the value.
Showing how to edit a representative from the context menu

The selected input field gets highlighted and you can simply edit the value.

Define a Representative of the type “char”

There are special rules for defining char values. If you add a char representative then you will see that you get actually 2 values, the character and its numeric representation in braces.

Showing a representative of type char

There are two ways to define a character value:

  1. Enter a character into the input text field with or without single quotes like ‘a’ or plain a.
  2. Enter the character’s numeric value.

Define a Representative of type “string”

You can enter strings with or without double quotes. There are two exceptions to this rule:

  • To enter a string that contains a double quote you can do so without escaping but your string has to start and end with a double quote. E.g. “He said “Hello!” “
  • To set a string variable to null you set the value to null without double quotes.
Desired valueRequired input
Double quotes“””
Null pointernull
A string containing the word “null”“null”

Complex Representatives

Beside primitive representatives we also have the option to define complex representatives. In our AverageSpeed example we have input factors of types Duration and ITrack.

Change the Value of a Complex Representative

To show you how to and what you can change when it comes to complex representatives we choose the input factor duration with Type Duration from the example.

Adding a representative always adds the default value, which is null for class types. If you want to change the value of a complex representative you have three options:

  1. Open the context menu of the representative and select “Change Value”.
  2. Highlight the representative row by clicking on it and press “F2”.
  3. Double click on the value.

In all three cases the Value Editor for input factor duration opens

Showing the edit window for complex representatives

Select a Constructor

Since complex representatives can have different constructors you first need to choose an appropriate one by using the selector in the Value Editor.

Showing a dropdown of constructors for the complex representative

Fill the Complex Representative with Actual Values

Once you choose a constructor you will see that the view in the Value Editor changes: There is one input field for every argument of the constructor. Primitive types can directly be edited in the top-level view of the Edit Value dialog. Complex types are broken up into a tree of primitive values. The tree is shown on the left hand side of the dialog. You can use it to navigate to different nodes of the value you are editing. Furthermore there is a breadcrumb bar at the top of the dialog that displays the path to the node you are currently editing.

Setting the values of the complex representative

Once you saved your changes, the value of the representative is updated in the test model.

Factory Methods

Defining complex values with the Value Editor can become cumbersome or even impossible. For example you cannot cope with polymorphism nor cyclic data structures. For such situations you can use a factory method that creates these complex values. You can define an arbitrary number of factory methods and reuse them for representatives and expected values in your model.

Define a Factory Method

To define and use a factory method open den Value Editor. Instead of choosing a constructor choose “Add New Factory Method” in the drop down menu.

Showing how to add a new factory method from the dropdown menu

A dialog for defining a new factory method will open. You must choose a name for the factory method and may add parameters.

Showing the dialog for adding a factory method

After saving your changes you will find the new factory method in the drop down menu of the Value Editor.

Showing the newly added factory method in the dropdown list

You can add as many factory methods as you want but be aware that they have to have different names.

Changes to factory methods are only allowed if they are not used to create any other value of your model.

Was this article helpful?
Dislike 0
Views: 146

Continue reading

Previous: Define Equivalence Classes
Next: Define Test Cases

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.

Privacy Settings saved!
Privacy Settings

When you visit any web site, it may store or retrieve information on your browser, mostly in the form of cookies. Control your personal Cookie Services here.

GetResponse, Google Analytics

We use LinkedIn Insight for marketing purposes. You can disable these cookies.

We use Google Analytics for marketing purposes. You can disable these cookies.
  • __utmz
  • __utma
  • _ga
  • _gat

We use GetResponse for marketing purposes. This service cannot be disabled, otherwise the website functions will be limited.

Decline all Services
Accept all Services
Get Free Access Now to
9 eBooks!
All about Automated Software Testing
Proven experts
Learn to save up to 75% of your test efforts
Get Free Access Now!
Get Access Now! & Save 50%
Personal Trainer FREE Nutrition Custom Workout App
Get Access Now!
eBook Download
Enter your details to get your free ebook!
All about Automated Software Testing
Download Free Ebook
SUBSCRIBE
MY WEB
NEWSLETTERS
Lorem ipsum dolor sit amet, consectetur adipiscing