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