寻找能够处理不同平台/版本的测试模式/方法
有“代码”,它正在不断开发。 有一个测试服务器,这个服务器使用“测试代码”来测试不同平台上的“代码”。 我的问题涉及“测试代码”。
正如我所说,服务器针对不同平台进行测试。但要做到这一点,测试代码需要能够处理这些不同的平台。跟踪由于使用这些不同平台而产生的微小“差异”变得非常困难。它变得更加复杂,因为平台可以有不同的版本并且......我必须交替测试这些版本的混合。
现在,我正在做类似的事情:
test1()
if(platform == 'a' && version == '1.4')
assert('bla',bla)
else if(platform == 'a' && version == '1.5')
assert('ble',bla)
else if(version == '1.6')
assert('blu',bla)
.....
现在,想象一下这个复杂 100 倍的情况,你可能会看到我现在正在处理的事情。所以我问是否有人知道一种模式/方法来更优雅或更稳健地处理这个问题,即使它涉及编码一个架构来支持它。
谢谢你们。
There is the 'code', it is being developed continuously.
There is a testing server, this server uses 'test code' to test the 'code' in different platforms.
My question involves the 'test code'.
As I said, the server tests for different platforms. But for that to happen, the test code needs to be able to handle those different platforms. It is getting really hard to keep track of those little 'differences' that arise because of the usage of those different platforms. And it gets more complicated, because the platforms can have different versions and.. I have to test mixing of those interchangeably.
Right now, I am doing something like:
test1()
if(platform == 'a' && version == '1.4')
assert('bla',bla)
else if(platform == 'a' && version == '1.5')
assert('ble',bla)
else if(version == '1.6')
assert('blu',bla)
.....
Now, imagine this but 100x more complicated, and you may see what I am dealing with right now. So I am asking if someone out there knows a pattern/approach to handle this more elegantly or robustly, even if it involves coding an architecture to support it.
Thanks guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将复杂性存储在多态对象中,则可以聚合差异并丢失
if
语句。好处是你可以解耦你的平台与您的测试代码的差异,毕竟它只涉及制作
针对不同环境选择的断言。
下面是一个用 Python 实现的简单示例,说明了我的意思。这个想法是,您为您关心的每个环境配置调用一次
test1
函数。您所期望的细节由多态对象处理。现在您的测试代码很简单 - 只需映射到正确的对象,然后是断言。You can aggregate the differences and lose your
if
statements if you store the complexity within polymorphic objects. The benefit is that you can decouple your platformdifferences from your testing code, which after all is only concerned with making
assertions for different choices of environment.
Here's a simple example of what I mean, implemented in Python. The idea is that you call your
test1
function once for every environment configuration you care about. The details of what you should expect are handled by the polymorphic objects. Now your test code is simple - just a mapping to the correct object, followed by the assertion.