📜  Concordion-按列表执行

📅  最后修改于: 2020-12-07 04:45:07             🧑  作者: Mango


Concordion execute命令可用于以重复方式运行Concordion夹具的操作。例如,如果我们想以列表的形式用多个示例说明需求,这将很有用。

考虑以下要求-

  • The full name Robert De is to be split as
    • Robert
    • De
  • The full name John Diere is to be split as
    • John
    • Diere

如果我们要编写一个拆分函数的规范,该规范会将一个名称拆分为名字和姓氏,那么规范将如下所示:

  • The full name Robert De is to be splited as
    • Robert
    • De
  • The full name John Diere is to be splited as
    • John
    • Diere

当Concordion解析文档时,它将把特殊变量#TEXT的值设置为当前元素的值“ Robert De”,并将其传递给split函数。然后,它将使用execute命令以#TEXT作为参数执行split()方法,并将结果设置为#result变量,并使用result将firstName和lastName值打印为输出。

让我们拥有一个运行良好的Eclipse IDE,并按照下面给出的步骤创建一个Concordion应用程序-

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

这是System.java文件的内容-

package com.tutorialspoint;
import org.concordion.api.MultiValueResult;

public class System { 
   public MultiValueResult split(String userName){  
      MultiValueResult result = new MultiValueResult();
      String[] words = userName.split(" ");   
      result.with("firstName", words[0]).with("lastName", words[1]);       
      return result;
   }
}

以下是SystemFixture.java文件的内容-

package specs.tutorialspoint;

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

@RunWith(ConcordionRunner.class)

public class SystemFixture {
   System system = new System();
   public MultiValueResult split(String userName){
      return system.split(userName);
   }  
}

以下是System.html文件的内容-


   

   
      

System Specifications

We are building specifications for our online order tracking application.

Following is the requirement to split full name of a logged in user to its constituents by splitting name by whitespace:

Example

  • The full name Robert De is to be splited as
    • Robert
    • De
  • The full name John Diere is to be splited as
    • John
    • Diere

创建完源文件和规范文件后,让我们将应用程序作为JUnit Test运行。如果您的应用程序一切正常,则将产生以下结果-

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

System.html是Concordion测试运行的输出。

手风琴在列表输出上执行