📅  最后修改于: 2020-12-07 04:43:03             🧑  作者: Mango
Concordion execute命令用于运行Concordion夹具的操作。考虑以下要求-
The sum of two numbers 2 and 3 will be 5.
如果我们要编写一个求和函数的规范,该规范将接受两个数字并输出它们的和,则该规范将如下所示:
The Sum of two numbers 2 and
3 will be
5.
当Concordion解析文档时,它将临时变量#firstNumber设置为值“ 2”,将#secondNumber设置为值“ 3”,然后使用execute执行参数为#firstNumber和#secondNumber的sum()方法。命令并将结果设置为#result变量,并检查#result变量是否等于“ 5”。
让我们拥有一个运行良好的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;
public class System {
public int sum(int firstNumber, int secondNumber) {
return firstNumber + secondNumber;
}
}
以下是SystemFixture.java文件的内容-
package specs.tutorialspoint;
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 int sum(int firstNumber, int secondNumber) {
return system.sum(firstNumber, secondNumber);
}
}
以下是System.html文件的内容-
Calculator Specifications
We are building online calculator support in our website.
Following is the requirement to add two numbers:
Example
The Sum of two numbers 2
and 3 will be
5.
创建完源文件和规范文件后,让我们将应用程序作为JUnit Test运行。如果您的应用程序一切正常,则将产生以下结果-
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\concordion\specs\tutorialspoint\System.html
Successes: 1, Failures: 0
System.html是Concordion测试运行的输出。