📅  最后修改于: 2020-12-07 04:41:36             🧑  作者: Mango
Concordion set命令用于存储可在其他Concordion命令中使用的临时变量。
考虑以下要求-
The Sum of two numbers 2 and 3 will be 5.
如果我们希望数字2和3作为参数并将它们传递给sum函数作为参数,以便可以针对系统返回的结果进行验证,则可以在数字周围的span标记中使用concordion:set命令。
The Sum of two numbers 2
and 3 will be
5
.
当Concordion解析文档时,它将临时变量#firstNumber设置为值“ 2”,将#secondNumber设置为值“ 3”,然后调用参数为#firstNumber和#secondNumber的sum()方法并检查是否结果等于“ 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 the 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 specificiation 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测试。如果您的应用程序一切正常,它将产生以下结果:
C:\DOCUME>1\ADMINI>1\LOCALS>1\Temp\concordion\specs\tutorialspoint\System.html
Successes: 1, Failures: 0
System.html是手风琴测试运行的输出。