自动产生的测试用例本就应该由程序自动执行,这其实也就是NModel推荐的模式。先回过头来看看前一篇文章中制作的模型,模型里面将登录、注销、用户名以及密码等要素都抽象出来了,而NModel是以这些抽象出来的动作(登录、注销)和状态(用户名、密码)为依据,产生测试用例的。那么要让NModel自动执行产生的测试用例,那么它需要知道如何才能执行登录和注销这些动作,而且它还需要知道在执行登录操作时,User.Administrator这个抽象出来的用户在实际执行测试用例时,应该采用什么用户名等信息。而这些信息NModel自己是无法“猜测”出来的,需要测试人员的引导才能获得。
因此NModel提供了IStepper这个接口让测试人员提供所需的信息,下面是这个接口的完整定义:
namespace NModel.Conformance { // Summary: // Must be implemented by an IUT for conformance testing public interface IStepper { // Summary: // Make a step according to the given action, the current state becomes the // target state of this transition. If the action is not enabled an exception // is thrown and the resulting state is undefined. An action on null may be // returned. // // Parameters: // action: CompoundTerm DoAction(CompoundTerm action); // // Summary: // Return to the initial state. If Reset is not enabled in the current state, // an exception is thrown and the resulting state is undefined and is thus not // guaranteed to be the initial state void Reset(); } } |