在Powershell进行TDD和单元测试?
问题说明
随着MS将Powershell应用于所有新服务器产品中,我开始(勉强地)认为我需要认真对待它. TDD是认真对待"的一部分.您找到用于对Power Shell脚本进行单元测试的好方法了吗?
With MS ramming powershell into all new server products, I'm starting to (reluctantly) think I need to take it seriously. Part of "taking it seriously" is TDD. Have you found good methods to unit test power shell scripts?
我从 Geek先生那里找到了嘲笑样本噪音-但是我真的很喜欢 RhinoMocks 之类的东西. Brian Hartsock 有一个来自MS Test的关于Powershell字符串的运行测试的示例.有点骇人听闻,但似乎可行.
I've found samples of mocking from Mr Geek Noise - but I'd really like something like RhinoMocks. Brian Hartsock has a sample of running tests on powershell strings from MS Test. A little hacky, but it seems to work.
我想要的是Powershell TDD体验,就像使用真实"语言一样干净.
What I want is a Powershell TDD experience that is as clean as it is in "real" languages.
更新以进行澄清:
前两个答案试图使我远离测试Powershell.意见很有趣.我不想知道在Powershell中测试是否是个好主意.这是一个主观的问题,应该在其他论坛中提出.我想要一个对Powershell进行单元测试的解决方案.如果您认为这是个坏主意(可能是),请将其视为一个有趣的学术问题.
The first two answers attempt to steer me away from testing Powershell. The opinions are interesting. I don't want to know if it's a good idea to test in powershell. That's a subjective question that should be asked in a different forum. I want a solution to unit testing powershell. If you think it's a bad idea (it might be), treat it as a fun academic question.
- 是的,脚本语言将不同的系统粘合在一起.但是,正如已经指出的那样,以动态语言模拟和破坏接缝也很容易.
- 我不是在问调试"问题.调试是一个非常有用的主题.我让别人问.
- 也许PS脚本应该很简单.该语言支持模块化,并且不可避免地会在PS中实现复杂的流程(即使是一个不好的主意).
- 此问题的答案不是您不能".我可以看到(从链接的博客-有点旧了),有些人在解决这个问题上取得了进展.
要重述:如何以xUnit风格实现Powershell逻辑的自动化测试?集成测试很有趣,而打破依赖关系的单元测试则最有趣.
To re-state: How do you implement an automated testing of Powershell logic in the style of xUnit? Integration tests are interesting, unit tests that break dependencies most interesting.
正确答案
Scott Muc启动了一个用于PowerShell的轻量级BDD框架项目Pester:
Scott Muc has started a project for a lightweight BDD framework for PowerShell called Pester:
https://github.com/pester/Pester
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfhggc
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20