求助:如何在Polarion Live Report页面中使用$mathTool
Polarion Live Report中$mathTool无法使用的解决办法
- 手动实例化MathTool
Live Report的Velocity上下文默认没加载MathTool,直接在脚本开头添加实例化代码即可:
#set($mathTool = new org.apache.velocity.tools.generic.MathTool()) #set($ratio= $mathTool.div($countIn, $countOut))
- 用原生Velocity算术运算替代
不想额外实例化工具的话,直接用Velocity自带的除法运算符,记得处理除数为0的情况:
#if($countOut != 0) #set($ratio = $countIn / $countOut) #else #set($ratio = 0) # 或者根据需求设置默认值 #end
原因说明:Polarion Wiki页面默认加载了完整的Velocity Tools工具集,包含$mathTool;而Live Report为了性能,上下文更精简,默认不包含这个工具,所以需要手动处理。
内容的提问来源于stack exchange,提问作者Florian Straub
相关产品推荐
相关产品推荐

