📅  最后修改于: 2020-12-07 04:42:21             🧑  作者: Mango
当夹具需要知道预期结果才能执行测试时,可以使用Concordion assertTrue命令。
考虑以下要求-
User Name : Robert De
The User name starts with R.
The User name starts with S == false.
如果我们要对用户名执行测试,并检查用户名是否以R开头。
User Name :Robert De
The User name starts
with R.
The User name starts
with S.
当Concordion解析文档时,它将把临时变量#userName设置为值“ Robert De”。然后它将检查userName是否以下一个命令中设置的#letter变量指定的字母开头。
让我们拥有一个运行良好的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 specification file and run the application as explained below. |
这是System.java文件的内容-
package com.tutorialspoint;
public class System {
}
以下是SystemFixture.java文件的内容-
package specs.tutorialspoint;
import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;
@RunWith(ConcordionRunner.class)
public class SystemFixture {
}
以下是System.html文件的内容-
System Specifications
We are building specifications for our online order tracking application.
Following is the requirement to split full name of a logged in user to
its constituents by splitting name by whitespace:
Example
User Name :Robert De
The User name starts
with R.
The User name starts
with S.
创建完源文件和规范文件后,让我们将应用程序作为JUnit Test运行。如果您的应用程序一切正常,则将产生以下结果-
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\concordion\specs\tutorialspoint\System.html
Successes: 1, Failures: 1
System.html是Concordion测试运行的输出。