命令行自动化——期望等效 [英] Command line automation – expect equivalent

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

问题描述

有一个命令行工具,我们需要为其编写自动化测试.我们的测试框架是用 C# 编写的,我正在寻找可以让我进行自动化的 .NET 库(我知道我可以使用 Process 类;重定向 IO;进行验证,但我不想重新发明轮子如果可能的话).理想情况下,我正在寻找类似 expect 库的东西.有什么建议吗?

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,每次我这样做时,我总是不得不重新发明轮子(即处理类、重定向 StdIO、StdErr 等并解析输出).想一想,我为此目的重用了一个抽象基类.

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.

但是我会发出警告,我已经看到在 .Net 框架中并不总是正确处理重定向 IO 的情况(取决于程序如何写入 stdio 或 stderr,是否隐藏窗口,如果您是多线程和其他一些条件)会导致争用条件,从而导致无限期挂起.

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天全站免登陆