Writing Your First Test Script

In this section we are going to write a very basic automated test script that simply compares two values. For starters we will hard-code the two values. The following is what the script will look like:

<testcase xmlns="jelly:jameleon">
  <ju-session>
      <ju-assert-equals
          functionId="Compare two equaling values"
          expected="value 1"
          actual="value 1"/>
  </ju-session>
</testcase>
        

Save the above code as passingAssertEquals.xml in the jameleon-test-suite/scripts folder. The scripts folder is the default location for test scripts and the Jameleon GUI will display all scripts in that folder.

Line-by-Line Explanation

We will go through the code below line by line and explain in detail what is happening.

1. <testcase xmlns="jelly:jameleon">
2.   <ju-session>
3.      <ju-assert-equals
4.          functionId="Compare two equaling values"
5.          expected="value 1"
6.          actual="value 1"/>
7.   </ju-session>
8. </testcase>
          

Line 1:<testcase xmlns="jelly:jameleon">

Every test script must have a <testcase/> tag. In this case, <testcase/> is our root tag.

Line 2: <ju-session>

Jameleon requires all function tags to be enclosed within a session tag. A session tag is what keeps state of the application between different function tags. In this case we are using a ju-session tag.

Line 3: <ju-assert-equals

The ju-assert-equalstag is the functional point that will perform the actual test. In order for a test to be performed, the script requires a functional point.

Line 4: functionId="Compare two equaling values"

Each functional point requires a functionId attribute. functionId uniquely defines this function from other functions that may also exist in the same script. It is also used to define where the script failed and to auto-generate the test case documentation. You should always try to write a descriptive and accurate functionIdKeep this in mind when writing a test script.

Line 5: expected="value 1"

This is the expected attribute in the ju-assert-equals tag. In this case, we are assigning it the value value 1.

Line 6: actual="value 1"

This is the actual attribute in the ju-assert-equals tag. In this case, we are assigning it the value value 1; the same value as the expected value.

Line 7: </junit-session>

This is the closing junit-session tag. If a tag contains other tags or text, it must have a corresponding closing tag. Since the function tags don't have any nested data, we close them by adding a / before the >.

Line 8: </testcase>

This is the closing testcase tag.

You have now written your first case! Please see the section called Executing Test Scripts for how to execute a test script.