我们有一些由步骤组成的测试工作流程。 现在我想构建类来表示它。数据流的设计模式
例如
Step 1: Get edit control for username
Step 2: Write username into the control
Step 3: Get edit control for password
Step 4: Write password into the control
Step 5: Click Login Button
的问题是:我怎么能有这些步骤,方便地交换信息? 如何轻松使用步骤2的代码中的步骤1的编辑控件?
此刻,我只是有下面的代码:
public abstract class TestCase
{
// the Steps to build the test
public IList<TestStep> TestSteps { get; set; }
public TestCase()
{
this.TestSteps = new List<TestStep>();
}
public abstract void Run();
public override string ToString()
{
return this.GetType().Name;
}
}
public class TestStep
{
public int StepNumber { get; set; }
public Func<bool> StepFunc { get; set; }
}
现在我想在第一步的控制,用它在第二步等等。
想到具有不同StepFunc的返回值适合需要 或特定TestStep派生类中的成员。但是可能有更好的方法。
请注意:目前我无法一步完成此操作。
任何想法高度赞赏!
步骤X需要步骤Y *和步骤Z的结果吗?例如,步骤X需要控制用户名和密码。 –
当然,这可能是必要的。只是举了一个简单的例子,让它更容易谈论它。 –
谁应该知道参数的来源?步骤X是否应该知道它需要步骤1和步骤3(而不是2和4)的结果,还是控制器应该知道?我认为你需要以某种方式“硬” - 对它进行编码,你不能为所有参数自动推导出正确的步骤。 –