用新的编程语言实现 xunit
我们中的一些人仍然“生活”在尚未接受单元测试的编程环境中。 首先,显而易见的第一步是尝试实现一个像样的单元测试框架,我猜 xUnit 是“标准”。
那么,以新的编程语言实现 xUnit 的良好起点是什么?
顺便说一句,因为人们在问:我的目标环境是 Visual Dataflex。
Some of us still "live" in a programming environment where unit testing has not yet been embraced. To get started, the obvious first step would be to try to implement a decent framework for unit testing, and I guess xUnit is the "standard".
So what is a good starting point for implementing xUnit in a new programming language?
BTW, since people are asking: My target environment is Visual Dataflex.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它适用于哪种语言 - 已经有很多了。
Which language is it for - there are quite a few in place already.
如果这阻止您开始编写单元测试,您可以在没有测试框架的情况下开始。
C 风格语言的示例:
Cobol 风格语言的示例:
完成代码更改(并且可能编译)后运行 Main。 每当有人向您的存储库提交代码时,就在服务器上运行 main。
当您着迷时,请更多地寻找框架,或者看看您是否可以将 Main 中的一些部分分解到您自己的框架中。
If this is stopping you from getting started with writing unit tests you could start out without a testing framework.
Example in C-style language:
Example in Cobol-style language:
Run Main after you are finished with a changed (and possibly compile) on your code. Run main on the server whenever someone submits code to your repository.
When you get hooked, Look more for a framework or see if you possibly could factor out some of the bits from Main to your own framework.
我建议一个好的起点是在其他几种语言上使用 xunit,以了解这种类型的单元测试框架的工作原理。 然后,您需要深入研究该行为,并开始研究如何以适合您的新语言的方式重新创建该行为。
I'd suggest that a good starting point would be to use xunit on a couple of other languages to get a feel for how this style of unit test framework works. Then you'll need to go in depth into the behaviour and start working out how to recreate that behaviour in a way that fits with your new language.
我根据 测试驱动开发中的代码在 VFP 中创建了一个不错的单元测试框架:实用指南,作者:David Astels。 通过阅读示例、理解技术并将 Java 代码翻译成您的语言,您将会受益匪浅。
I created a decent unit test framework in VFP by basing it on the code in Test Driven Development: A Practical Guide, by David Astels. You'll get a long way by reading through the examples, understanding the techniques and translating the Java code into your language.
我发现 使用 NUnit 在 C# 中进行实用单元测试< /a> 非常有帮助!
I found Pragmatic Unit Testing in C# with NUnit very helpful!