命令行自动化 - 预计相当于 [英] Command line automation – expect equivalent

查看:237
本文介绍了命令行自动化 - 预计相当于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个命令行工具,我们需要编写自动测试。我们的测试框架是用C#和我一直在寻找的.NET库这将让我做自动化(我知道我可以使用Process类;重定向IO;做验证,但我不希望推倒重来如果可能的话)。理想的情况是我在寻找的东西像一个期望库。有什么建议?

There is a command line tool for which we need to write automated tests. Our test framework is written in C# and I was looking for .NET libraries which would let me do the automation (I know I can use the Process class; redirect the IO; do the validation, but I don't want to reinvent the wheel if possible). Ideally I'm looking for something like an expect library. Any suggestions?

推荐答案

我意识到这是一个老问题,但没有人接听。

I realize that this is an old question, but no one has answered.

IMO,我一直有每次我做了这一次推倒重来(即Process类,重定向标准输入输出,标准错误等,并解析输出)。想到这里,我已经为了这个目的重用的抽象基类。

IMO, I've always had to reinvent the wheel every time I've done this (i.e. Process class, redirect StdIO, StdErr, etc and parse the output). Thought, I've reused an abstract base class for this purpose.

也许别人知道库要做到这一点,但我没有。

Maybe someone else knows of a library to do this, but i do not.

不过,我会给我看到那里重定向IO并不总是正确地在.NET Framework处理的个案警告(具体取决于程序写入到标准输入或标准错误,如果你隐藏的窗口或没有,如果你是多线程,和一些其他条件),导致竞争状态导致无限期挂起。

However I will give a warning that I have seen cases where redirecting the IO is not always properly handled in the .Net framework (depending on how the program writes to stdio or stderr, if you're hiding the window or not, if you're multi-threading, and a few other conditions) leading to a race condition that results in an indefinite hang.

这篇关于命令行自动化 - 预计相当于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆