编写 Cucumber 功能以访问 SVN
我正在开发一个工具,通过运行命令行 SVN 来获取信息并导出来访问 SVN。
我想编写一些 Cucumber 功能,这样我就不必手动测试,但我想模拟 SVN 访问。
我应该改用 Ruby SVN 库吗?如果是的话,选哪个?
或者是否有一个假的 svn.exe 将提供可编程响应?
编辑:
该工具采用文件路径,查找父 URL 的上几级修订版,然后将该修订版的一堆文件和文件夹导出到新目录中。我想写这样的内容:
Given the file "extra1.txt" contains:
"""
extra1
"""
And the file "file.txt" contains:
"""
file
"""
And SVN holds the following files at revisions:
| tests/extras/extra1.txt | 123 | extra1.txt |
| tests/path/part05/file.txt | 73 | file.txt |
When I run "ruby dry_run_create c:\tests\path\part05\file.txt"
Then the file "c:\tests\path\part05\dry_run\extra1.txt" should contain:
"""
extra1
"""
And the file "c:\tests\path\part05\dry_run\file.txt" should contain:
"""
file
"""
通过这些示例,我可以永远更多地演示从 SVN 中提取正确的修订版本,而无需实际创建存储库。
I'm developing a tool that accesses SVN by running the command line SVN to get info and export.
I'd like to write some Cucumber features so I don't have to keep manually testing but I'd like to mock out the SVN accesses.
Should I switch to using a Ruby SVN library and if so, which one?
Or is there a fake svn.exe that will provide programmable responses?
EDIT:
The tool takes a file path, finds the revision of parent URL a few levels up, then exports a bunch of files and folders at that revision into a new directory. I'd like to write something like:
Given the file "extra1.txt" contains:
"""
extra1
"""
And the file "file.txt" contains:
"""
file
"""
And SVN holds the following files at revisions:
| tests/extras/extra1.txt | 123 | extra1.txt |
| tests/path/part05/file.txt | 73 | file.txt |
When I run "ruby dry_run_create c:\tests\path\part05\file.txt"
Then the file "c:\tests\path\part05\dry_run\extra1.txt" should contain:
"""
extra1
"""
And the file "c:\tests\path\part05\dry_run\file.txt" should contain:
"""
file
"""
With examples like these I could demonstrate forever more that the correct revisions were being extracted from SVN without having to actually create a repository.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不需要实际测试 SVN 功能,只需完全模拟调用即可。
Mocha 非常适合此
查看(没有双关语)http:// blog.floehopper.org/articles/2006/09/01/mocha-quickstart
If you don't need to actually test the SVN functionality, just mock out the calls completely.
Mocha is great for this
Check out (no pun intended) http://blog.floehopper.org/articles/2006/09/01/mocha-quickstart
我放弃了寻找和等待,编写了自己的 MockVersion。
这提供了一些基本的 svn 和 svnadmin 功能,以便我可以创建具有特定修订的模拟存储库并验证这些文件是否已导出。
如果有人有兴趣查看更多功能,请在 github 上打开问题。
I gave up looking and waiting and wrote my own, MockVersion.
This provides some basic
svn
andsvnadmin
functionality so that I can create a mock repository with specific revisions and verify that those files are exported.If anyone is interested in seeing more functionality, please open an issue on github.