如何为图形库编写测试?
我正在用 Python 编写一个 OpenGL 2D 库。一切都很顺利,代码库也在稳步增长。
现在我想编写单元测试,这样我就不会在修复其他错误/创建新功能时意外引入新错误。但我不知道它们如何与图形库一起使用。
我想到的一些事情:
- 制作参考屏幕截图并将它们与测试中自动生成的屏幕截图进行比较,
- 用日志语句替换 opengl 调用并比较日志
但这两者似乎都是一个坏主意。测试图形库的常用方法是什么?
I'm writing an OpenGL 2D library in Python. Everything is going great, and the codebase is steadily growing.
Now I want to write unit tests so I don't accidently bring in new bugs while fixing others/making new features. But I have no idea how those would work with graphics libraries.
Some things I thought of:
- make reference screenshots and compare them with autogenerated screenshots in the tests
- replace opengl calls with logging statements and compare logs
But both seem a bad idea. What is the common way to test graphics libraries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我过去用于组件级测试的方法是:
正如格雷厄姆所说,内部单元可以不受图形调用的影响进行单元测试。
The approach I have used in the past for component level testing is:
As graham stated, internal units may be unit-testable free from graphics calls.
进一步分解它。
生成图形的调用将依赖于算法 - 测试算法。
Break it down even further.
The calls that make the graphics will rely on algorithms - test the algorithms.