English 中文(简体)
Concordion - verifyRows Command
  • 时间:2024-03-24 19:18:09

Concordion - verifyRows Command


Previous Page Next Page  

协约核查 可以对系统归还的收缴物品进行检查。 例如,如果我们在该系统中建立一套用户,并对用户进行部分搜索,那么该系统就应当归还对应要素,否则我们的接受测试就应当失败。

考虑以下要求:

<table>
   <tr><th>Users</th></tr>
   <tr><td>Robert De</td></tr>
   <tr><td>John Diere</td></tr>
   <tr><td>Jupe Re</td></tr>
</table>

<p>Search for J should return:</p>

<table>
   <tr><th>Matching Users</th></tr>
   <tr><td>John Diere</td></tr>
   <tr><td>Jupe Re</td></tr>
</table>

如果我们想写出这种搜索功能的具体内容,以便搜寻和返还收集,那么具体内容将如下:

<table concordion:execute = "addUser(#username)">
   <tr><th concordion:set = "#username">Username</th></tr>
   <tr><td>Robert De</td></tr>
   <tr><td>John Diere</td></tr>
   <tr><td>Jupe Re</td></tr>
</table>

<p>Search for "<b concordion:set = "#searchString">J</b>" should return:</p>

<table concordion:verifyRows = "#username : search(#searchString)">
   <tr><th concordion:assertEquals = "#username">Matching Usernames</th></tr>
   <tr><td>John Diere</td></tr>
   <tr><td>Jupe Re</td></tr>
</table>

如果《协约》对该文件作了规定,它将在第一桌的每一行上执行添加“User()”,然后将搜寻标准定为J. 其次,《协约》将履行搜索功能,该功能应归还有可预见扰动的物体(例如,清单、联系HashSet或树木Set),核查。 每一件藏书都有罗,并负责指挥。

Example

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

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 the required Concordion pbraries using Add External JARs option as explained in the Concordion - First Apppcation 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 apppcation as explained below.

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

package com.tutorialspoint;

import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

pubpc class System { 
   private Set<String> users = new HashSet<String>();
	
   pubpc void addUser(String username) {
      users.add(username);
   }
	
   pubpc Iterable<String> search(String searchString) {
      SortedSet<String> matches = new TreeSet<String>();
		
      for (String username : users) {
         if (username.contains(searchString)) {
            matches.add(username);
         }
      }
		
      return matches;
   }
}

以下是该系统的内容。 java文档

package specs.tutorialspoint;

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

@RunWith(ConcordionRunner.class)

pubpc class SystemFixture {
   System system = new System();
   pubpc void addUser(String username) {
      system.addUser(username);
   }
	
   pubpc Iterable<String> search(String searchString) {
      return system.search(searchString);
   }
}

以下是该系统的内容。

<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 add a partial search capabipty on user names:</p>
		
      <span class = "example">      
         <h3>Example</h3>
			
         <table concordion:execute = "addUser(#username)">
            <tr><th concordion:set = "#username">Username</th></tr>
            <tr><td>Robert De</td></tr>
            <tr><td>John Diere</td></tr>
            <tr><td>Jupe Re</td></tr>
         </table>
			
         <p>Search for "<b concordion:set = "#searchString">J</b>" should return:</p>
			
         <table concordion:verifyRows = "#username : search(#searchString)">
            <tr><th concordion:assertEquals = "#username">Matching Usernames</th></tr>
            <tr><td>John Diere</td></tr>
            <tr><td>Jupe Re</td></tr>
         </table>
			
      </span> 
		
   </body>

</html>

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

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

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

concordion verifyRows Output Advertisements