Contact at or 8097636691/9323040215
Responsive Ads Here

Sunday, 22 July 2018

Concordion - assertEquals Command

Concordion - assertEquals Command

Concordion assertEquals command is used to check Java bean property or method result against a specified value.
Consider the following requirement −
The sum of two numbers 2 and 3 will be 5.
If we want the numbers 2 and 3 to be as parameters and pass them to sum function as parameter so that it can be verified against the result as 5 returned by the system then we can use concordion:assertEquals command within span tag around the sum function.
<p>The Sum of two numbers <span concordion:set="#firstNumber">2</span> 
   and  <span concordion:set="#secondNumber">3</span> will be 
   <span concordion:assertEquals="sum(#firstNumber, #secondNumber)">5</span>.</p>
When Concordion parses the document, it will set a temporary variable #firstNumber to be the value "2" and #secondNumber to be the value "3" using set command and then call the sum() method with parameters as #firstNumber and #secondNumber and check that the result is equal to "5" using the assertEquals command.


Let us have working Eclipse IDE in place and follow the following steps to create a Concordion application −
1Create a project with a name concordion and create a package com.tutorialspoint under the src folder in the created project.
2Add required Concordion libraries using Add External JARs option as explained in the Concordion - First Application chapter.
3Create Java class System under the com.tutorialspoint package.
4Create Fixture class SystemFixture under the specs.tutorialspoint package.
5Create Specification html System.html under the specs.tutorialspointpackage.
6The final step is to create the content of all the Java files and specificiation file and run the application as explained below.
Here is the content of the file −
package com.tutorialspoint;
public class System {
   public int sum(int firstNumber, int secondNumber) {
      return firstNumber + secondNumber;
Following is the content of the file −
package specs.tutorialspoint;

import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;
import com.tutorialspoint.System;


public class SystemFixture {
   System system = new System();
   public int sum(int firstNumber, int secondNumber) {
      return system.sum(firstNumber, secondNumber);
Following is the content of the System.html file −
<html xmlns:concordion = "">
      <link href = "../concordion.css" rel = "stylesheet" type = "text/css" />

      <h1>Calculator Specifications</h1>
      <p>We are building online calculator support in our website.</p>
      <p>Following is the requirement to add two numbers:</p>
      <div class = "example">
         <p>The Sum of two numbers <span concordion:set = "#firstNumber">2</span> 
            and  <span concordion:set = "#secondNumber">3</span> will be 
            <span concordion:assertEquals = "sum(#firstNumber, #secondNumber)">5</span>.</p>

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 show the following result −
Successes: 1, Failures: 0
System.html is the output of Concordion test run.
Concordion assertEquals command Output
Successes: 1, Failures: 0

No comments:

Post a Comment