对 SharePoint 工作流进行单元测试
我想知道是否有任何现有的解决方案用于单元测试 Windows 工作流 在 SharePoint 上下文中运行的 Foundation 工作流。
不幸的是,SharePoint 库在设计时并未考虑到测试或模拟的可能性。
此类工作流通常与 SharePoint 类紧密绑定,需要安装并运行 SharePoint 实例,这对于测试来说绝对无效。
以下是我在尝试对现有工作流进行单元测试时遇到的挑战列表:
- 工作流调用静态 SharePoint 对象;
- 模拟所需的一些
EventArgs
类是 SharePoint 程序集的内部类; - 工作流可以使用特殊的 SharePoint 工作流活动,这些活动又会调用 SharePoint;
- 没有方便的 API 用于在 SharePoint 上下文中启动工作流并监视其状态。
我解决了某个工作流程的这些问题,我必须使用 Microsoft Moles 进行测试,并且可能有一天我的解决方案会作为开源发布。
同时,我想知道你们中是否有人对 SharePoint 工作流程进行过单元测试。如果是这样,我想听听您对这些(可能还有其他一些)问题的解决方案。我还想知道如果我发布了我的库,您是否会对它感兴趣。
谢谢。
I was wondering if there are any existing solutions for unit-testing Windows Workflow
Foundation workflows that run in SharePoint context.
Unfortunately, SharePoint libraries were not designed with possibility of testing or mocking in mind.
Such workflows are usually tightly bound to SharePoint classes that require SharePoint instance to be installed and running, which is absolutely ineffective for testing.
Following is a list of challenges I faced while trying to unit-test an existing workflow:
- Workflows make calls to static SharePoint objects;
- Some
EventArgs
classes that are necessary for mocking are internal to SharePoint assembly; - Workflows may use special SharePoint Workflow Activities which in turn make calls to SharePoint;
- There is no convenient API for starting a workflow in SharePoint context and monitoring its state.
I solved these problems for a certain workflow I had to test using Microsoft Moles and probably will someday release my solution as open source.
Meanwhile, I'm wondering if any of you ever unit-tested SharePoint workflows. If so, I'd like to hear about your solutions to these (and probably some other) problems. I'd also like to know if my library, if I release it, would be of interest to you.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单元测试工作流程?一般来说,Sharepoint 的单元测试相当困难。
我将两个框架与 Sharepoint 一起使用:
这些框架都无法测试 Microsoft Sharepoint 活动,特别是使用 SHarepoint Designer 制作的工作流程,因为它们是密封的,无论如何您都应该认为它们“工作” - 微软制造了它们,它们是完美的! :-)
你的库肯定很有趣,因为在我看来,没有多少人尝试对 Sharepoint 进行单元测试,因为在我看来,Sharepoint 的本质是:你使用了很多内置功能,只是自定义,并且可能添加到该功能 - 基本上你只想要测试/单元测试您自己的代码。
抱歉,无法向您提供我遇到的问题的具体信息 - Typemock 绝对更强大,因为它更古老、更成熟 - Pex&Moles 很有趣(我发现 Sharepoint 的教程相当不错:使用 Microsoft Pex 和 Mole 对 SharePoint Foundation 进行单元测试。
Unit Testing Workflows? In general unit-testing Sharepoint is rather hard.
I have used two frameworks together with Sharepoint:
Neither of these frameworks is able to test Microsoft Sharepoint Activities or in particular, Workflows made with SHarepoint Designer as those are sealed and you should consider them "working" anyways - Microsoft made them, they're perfect! :-)
Your library is certainly of great interest as there are not many people trying to unit test Sharepoint due to Sharepoints nature in my eyes: You use lot of built in functionality and just customize and and probably add to that functionality - basically you only want to test/unit test your own code.
Sorry, can't give you specifics on the problems I faced - Typemock was definitely more powerful to use as it is a lot older and mature - Pex&Moles is fun though (I found the tutorial for Sharepoint rather nice: Unit Testing SharePoint Foundation with Microsoft Pex and Mole.