我有一项将 BBD 与 Citrus Frimework 集成的任务。我们使用 Cucumber 的 BBD 并像这样读取特征文件中的测试用例
特点:人员管理
person_management.feature
Scenario: Check the informations from an person
Given the person management system is initialized with the following data
| id |
| 1 |
Then the name of Person will be Patrick.
我们有 PersonTest(使用 Junit)
@RunWith(Cucumber.class)
public class PersonTest {
}
公共类 PersonSteps { PersonManager 经理;
@Given("^the person management system is initialized with the following data$")
public void the_person_management_system_is_initialized_with_the_following_data(final List<Person> persons) throws Throwable {
manager = new PersonManager(persons);
}
@Then("^Then the name of Person will be (\\d+)$")
public void the_name_of_person_will_be(final String name) throws Throwable {
assertThat(manager.getCurrentPersonName(), equalTo(name));
}
}
PersonTest 作为 Junit 测试运行的问题
我的 Citrus 使用带有 TestNG 和 xml 测试用例的测试用例 像这样
@Test
public class PersonCitrusTest extends AbstractTestNGCitrusTest {
/**
* Test find company by id
*/
@CitrusXmlTest(name = "findPersonTestCase")
public void findPersonTestCase() {
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<spring:beans xmlns="http://www.citrusframework.org/schema/testcase"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:http="http://www.citrusframework.org/schema/http/testcase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.citrusframework.org/schema/testcase http://www.citrusframework.org/schema/testcase/citrus-testcase.xsd
http://www.citrusframework.org/schema/http/testcase http://www.citrusframework.org/schema/http/testcase/citrus-http-testcase.xsd">
<testcase name="findPersonTestCase">
<description>Test Find Person</description>
<variables>
<variable name="personId" value="1"></variable>
</variables>
<actions>
<!--
1. Get Person
2. Check the name of person
-->
那么我怎样才能将它们两者结合起来呢?谢谢