Concordion – assertTrue Command

Concordion assertTrue command is used when the fixture needs to know the expected result in order to perform a test.

Consider the following requirement −

User Name : Zafrul Khan
The User name starts with Z.
The User name starts with S == false.

If we want a test to be executed on the User Name and check whether the user name starts with Z or not.

<p>User Name :<span concordion:set = "#userName">Zafrul Khan</span></p>
<p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
   with <b concordion:set = "#letter">Z</b></span>.</p>
<p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
   with <b concordion:set = "#letter">S</b></span>.</p>   

When Concordion parses the document, it will set a temporary variable #userName to be the value “Zafrul Khan”. Then it will check if the userName starts with the letter specified by #letter variable set in next command.

Example

Let us have a working Eclipse IDE in place and follow the steps given below to create a Concordion application −

StepDescription
1Create a project with a name concordion and create a package com.Adglob under the src folder in the created project.
2Add the required Concordion libraries using Add External JARs option as explained in the Concordion – First Application chapter.
3Create Java class System under the com.Adglob package.
4Create Fixture class SystemFixture under the specs.Adglob package.
5Create Specification html System.html under the specs.Adglob package.
6The final step is to create the content of all the Java files and specification file and run the application as explained below.

Here is the content of the System.java file −

package com.Adglob;
public class System {   
}

Following is the content of the SystemFixture.java file −

package specs.Adglob;

import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;

@RunWith(ConcordionRunner.class)

public class SystemFixture {
}

Following is the content of the System.html file −

<html xmlns:concordion = "http://www.concordion.org/2007/concordion">
   <head>
      <link href = "../concordion.css" rel = "stylesheet" type = "text/css" />
   </head>

   <body>
      <h1>System Specifications</h1>
      <p>We are building specifications for our online order tracking application.</p>
      <p>Following is the requirement to split full name of a logged in user to 
         its constituents by splitting name by whitespace:</p>
   
      <div class = "example">      
         <h3>Example</h3>
         <p>User Name :<span concordion:set = "#userName">Zafrul Khan</span></p>
         <p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
            with <b concordion:set = "#letter">Z</b></span>.</p>
         <p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
            with <b concordion:set = "#letter">S</b></span>.</p>          
      </div>
		
   </body>

</html>

Once you are done with creating source and specification files, let us run the application as JUnit Test. If everything is fine with your application, then it will produce the following result −

C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\concordion\specs\Adglob\System.html
Successes: 1, Failures: 1

Leave a Reply