我想使用规范流测试服务接口。
该服务旨在运行测试以测试其他服务。我想做的是发送一些请求消息并得到响应并进行验证。
假设我有这个数据,我想使用下面的服务合同进行测试。.
var testData = new TestData
{ Definition = new TestDefinition
{
Steps = new List<TestStep>(){ new TestStep{StepId = "1", Actions = new List<TestAction>()
{new TestAction{ActionType = TestActionType.SendRequest, Parameters = new Dictionary<string, string>(){{"MessageId", "1"}}},
}
} ,
new TestStep{StepId="2",Actions=new List<TestAction>
{new TestAction
{ActionType=TestActionType.GetResponse,
Parameters=new Dictionary<string, string>()
{{"MessageId","2"},{"Wait","30000"}} }}}}
},
Requests = new List<Request>()
{new Request(){
MessageId = "1",
Content = new List<Element>()
{ new Element{Key= "TransactionID.Value", Value = "XX0001"},}}},
Response = new List<Response>{new Response
{MessageId="2", ElementValidations = new List<ValidationRule>
{new ValidationRule
{Element=new Element{ Key = "TransactionID.Value",,
Value="XXX0006"},Description="Failed to match [Transaction ID] value",}}}
以下是数据合同:
[DataContract]
public class TestData
{
[DataMember]
public TestDefinition Definition { get; set; }
[DataMember]
public List<Request> Requests { get; set; }
[DataMember]
public List<ExpectedResponse> Response { get; set; }
}
[DataContract]
public class TestDefinition
{
[DataMember]
public string TestId { get; set; }
[DataMember]
public List<TestStep> Steps { get; set; }
}
[DataContract]
public class Request
{
[DataMember]
public string TransactionId { get; set; }
[DataMember]
public string TransactionType { get; set; }
[DataMember]
public List<Element> Content { get; set; }
}
[DataContract]
public class TestStep
{
public TestStep()
{
Timeout = 60000;
}
[DataMember]
public ICollection<TestAction> Actions { get; set; }
}
使用特定关键字的规范流程:场景、给定、何时和然后。我可以将什么设置为场景、给定、何时和然后。
这是我想做的事情:
- 在场景 [Db setup] 之前
- 给定 ["Id 在 (.*) 表中找到"]
- 当 [准备要在表格中发送的数据] 例如。上面的请求数据
- 然后[通过循环验证传入的响应]
有人可以帮助我设计一种解决此问题的好方法。
谢谢你。