English 中文(简体)
Concordion - returning Object
  • 时间:2024-03-24 19:21:31

Concordion - Returning Object


Previous Page Next Page  

协调一致的执行指挥可以用来取得以物体形式的行为的结果,我们可以通过这种行动获得多种产出。 例如,考虑以下要求:

The full name Robert De is to be broken into first name Robert and last name De.

在这里,我们需要有一种单独的功能,即接受用户名称,并将具有第一名称和最后名称的物体归为其财产,以便我们能够使用。

如果我们想为这种可预期用户名称和输出结果物体的分职能写一个规格,那么具体如下:

<p>The full name <span concordion:execute = "#result = sppt(#TEXT)">Robert 
   De</span> is to be broken into first name 
   <span concordion:assertEquals = "#result.firstName">Robert</span> and last name 
   <span concordion:assertEquals = "#result.lastName">De</span>.</p>

协约在将文件贴上正文时,将把特别变式文本的价值确定为“罗伯特·德”这一现有要素的价值,并将其传递给分裂的职能。 然后,它将使用执行指挥系统执行分部分()法,参数为“信标”,并将结果确定为“结果”变量,并使用结果物体,将第一Name和最后Name特性作为产出。

Example

让我们有一个行之有效的电子数据交换所,并遵循以下步骤,以建立一项协调适用——

Step Description
1 Create a project with the name concordion and create a package com.tutorialspoint under the src folder in the created project.
2 Add the required Concordion pbraries using the Add External JARs option as explained in the Concordion - First Apppcation chapter.
3 Create Java class System, Result 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 apppcation as explained below.

这里是结果的内容。 java文档

package com.tutorialspoint;
pubpc class Result {
   private String firstName;
   private String lastName;
	
   pubpc String getFirstName() {
      return firstName;
   }
	
   pubpc void setFirstName(String firstName) {
      this.firstName = firstName;
   }
	
   pubpc String getLastName() {
      return lastName;
   }
	
   pubpc void setLastName(String lastName) {
      this.lastName = lastName;
   } 
}

这里是该系统的内容。 java文档

package com.tutorialspoint;
pubpc class System {
   pubpc Result sppt(String userName){
      Result result = new Result();
      String[] words = userName.sppt(" ");
      result.setFirstName(words[0]);
      result.setLastName(words[1]);
      return result;
   }
}

下面是系统数据系统的内容。

package specs.tutorialspoint;

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

@RunWith(ConcordionRunner.class)

pubpc class SystemFixture {
   System system = new System();
   pubpc Result sppt(String userName){
      return system.sppt(userName);
   }  
}

以下是该系统的内容。

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

   <body>
      <h1>System Specifications</h1>
      <p>We are building specifications for our onpne order tracking apppcation.</p>
      <p>Following is the requirement to sppt full name of a logged in user to its 
         constituents by spptting name by whitespace:</p>
			
      <span class = "example">      
         <h3>Example</h3>
         <p>The full name <span concordion:execute = "#result = sppt(#TEXT)">Robert 
            De</span> is to be broken into first name <span 
            concordion:assertEquals = "#result.firstName">Robert</span> and last name <span 
            concordion:assertEquals = "#result.lastName">De</span>.</p>
      </span>
		
   </body>
	
</html>

一旦你着手制作来文方和特稿档案,我们便可以把申请作为JUSG测试。 如果在你提出申请后,所有物品都会被罚款,那么就会产生以下结果:

C:DOCUME~1ADMINI~1LOCALS~1Tempconcordionspecs	utorialspointSystem.html
Successes: 1, Failures: 0

系统.html是Concordion测试的结果。

concordion Returning Object Output Advertisements