0
我有一個任務將BBD與柑橘毛氈結合起來。 的BBD我們用黃瓜和讀取類似這樣如何整合柑橘框架和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 {
}
public class PersonSteps PersonManager manager;
@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測試
我的柑橘使用測試用例使用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
-->
所以問題我怎麼能整合他們呢?謝謝
在收到您的反饋之前,我已經嘗試了很多方法,並且也使用了dsl。如:Citrus citrus = Citrus.newInstance(); TestDesigner testDesigner = new DefaultTestDesigner(citrus.getApplicationContext(),citrus.createTestContext()); testDesigner.send(HttpClient的).payload( 「」)的http()方法(HttpMethod.GET)。路徑(UR I)。。然後我們收到如下的響應ReceiveHttpMessageBuilder status = testDesigner.receive(httpClient).messageType(MessageType.JSON).http(); status.validateScript(jsonScript); .....我們可以使用groovy腳本併爲內存java對象設置值。 –